This document summarizes how to customize and extend the static source code analyzer Perl Critic. It discusses customizing Perl Critic by modifying configuration files to ignore or change severity levels of policies. It also covers extending Perl Critic by writing new policy modules to check for additional coding issues. Examples are provided of existing policy extension modules on CPAN and steps to create a new policy module, including the required subroutines and checks.
YAPC::NA 2007 - An Introduction To Perl Criticjoshua.mcadams
If you ever dreamed of having an instant code from some of Perl's top coders, Perl Critic may very well be the closest tool that you'll ever find. This talk will introduce you to Perl Critic, a static source code analyzer for your code. Learn about the ideas behind Perl Critic, the implementation of the system, and how to apply it and improve the quality and consistency of your code.
This document provides an introduction to Perl Critic, which is a tool for static analysis of Perl code. It discusses what Perl Critic checks for, how it works, and how to configure it. Key points include:
- Perl Critic checks code against a set of predefined policies to find stylistic or logic issues
- It parses code as documents rather than executing it
- Policies have severity levels and can be grouped into themes
- Configuration options allow ignoring policies, changing severities, and applying themes
- Perl Critic can be run directly or integrated into testing to catch issues earlier
Test-driven development (TDD) is an iterative process where tests are written before code to validate requirements. It follows the "red-green-refactor" cycle: write a failing test, write code to pass the test, refactor code. The document demonstrates TDD with a palindrome checker function, writing multiple tests to handle different cases before refactoring the code. Unit testing frameworks like unittest, py.test, and nose make TDD easier by automating test discovery and providing features like parallel testing and code coverage reports. Nose is currently the most popular alternative to unittest for Python projects.
The document discusses automated testing in Python and other languages. It covers unit testing, how unit tests work in Python using the unittest module, the benefits of testing like refactoring with confidence and faster debugging. It also briefly mentions test frameworks for other languages like Java, Perl, PHP and Erlang. The key themes are that testing finds bugs, helps refactor code safely, and that when frameworks have shortcomings the better approach is to help fix them rather than starting new ones.
This document provides an overview and summary of Boost and Google Test (gtest). It discusses key Boost libraries like smart pointers, assign, foreach, and bind. It explains how Boost handles memory management and containers. It also covers the basics of gtest like writing assertions and test fixtures. The document recommends gtest as a lightweight unit testing framework compared to Cppunit.
YAPC::NA 2007 - An Introduction To Perl Criticjoshua.mcadams
If you ever dreamed of having an instant code from some of Perl's top coders, Perl Critic may very well be the closest tool that you'll ever find. This talk will introduce you to Perl Critic, a static source code analyzer for your code. Learn about the ideas behind Perl Critic, the implementation of the system, and how to apply it and improve the quality and consistency of your code.
This document provides an introduction to Perl Critic, which is a tool for static analysis of Perl code. It discusses what Perl Critic checks for, how it works, and how to configure it. Key points include:
- Perl Critic checks code against a set of predefined policies to find stylistic or logic issues
- It parses code as documents rather than executing it
- Policies have severity levels and can be grouped into themes
- Configuration options allow ignoring policies, changing severities, and applying themes
- Perl Critic can be run directly or integrated into testing to catch issues earlier
Test-driven development (TDD) is an iterative process where tests are written before code to validate requirements. It follows the "red-green-refactor" cycle: write a failing test, write code to pass the test, refactor code. The document demonstrates TDD with a palindrome checker function, writing multiple tests to handle different cases before refactoring the code. Unit testing frameworks like unittest, py.test, and nose make TDD easier by automating test discovery and providing features like parallel testing and code coverage reports. Nose is currently the most popular alternative to unittest for Python projects.
The document discusses automated testing in Python and other languages. It covers unit testing, how unit tests work in Python using the unittest module, the benefits of testing like refactoring with confidence and faster debugging. It also briefly mentions test frameworks for other languages like Java, Perl, PHP and Erlang. The key themes are that testing finds bugs, helps refactor code safely, and that when frameworks have shortcomings the better approach is to help fix them rather than starting new ones.
This document provides an overview and summary of Boost and Google Test (gtest). It discusses key Boost libraries like smart pointers, assign, foreach, and bind. It explains how Boost handles memory management and containers. It also covers the basics of gtest like writing assertions and test fixtures. The document recommends gtest as a lightweight unit testing framework compared to Cppunit.
This document provides best practices for writing PHPUnit tests, including: do not write tests that do not test anything or test too much; exploit dependencies between tests; use the most specific assertion; decouple test code from test data; organize tests by class; run tests via XML configuration; disable unnecessary PHPUnit features; use code coverage whitelisting; annotate tests to make coverage more meaningful; and avoid unnecessary patterns like singletons.
This document provides an introduction and overview of PHPUnit, a tool for writing and running unit tests for PHP code. It discusses why unit testing and PHPUnit are useful, how to install and run PHPUnit, and best practices for writing effective unit tests with PHPUnit including describing tests clearly, using specific assertions, and decoupling test code and data. The document also addresses using PHPUnit for legacy code and references additional resources.
This document provides an overview of unit testing in PHP using PHPUnit. It discusses some goals of test automation like improving quality and reducing risks. It also covers the testing continuum from unit to integration to functional tests. The document introduces PHPUnit and how it is based on the xUnit family of tools. It then walks through an example of writing the first PHPUnit test to test a ROT13 encoding function in a test-driven way, demonstrating best practices like following the RED-GREEN-REFACTOR process and using assertions. Finally, it discusses principles of good test automation like independence of tests and isolating the system under test.
Unit testing with PHPUnit - there's life outside of TDDPaweł Michalik
Basics of PHPUnit and why is it even more relevant in legacy code. Key points of the framework are explained, along with mocking objects, test organisation, creating documentations with tests and accessing non-public objects (where applicable).
Live version with additional notes available at: http://pawelmichalik.net/presentations/unit-testing-with-phpunit?showNotes=true
Prezentacja dostępna także w języku polskim: http://pawelmichalik.net/prezentacje/testy-jednostkowe-w-phpunit?showNotes=true
This document introduces unit testing with PHPUnit. It discusses what unit testing is, why it's important, and tools like SimpleTest and PHPUnit. It provides examples of basic unit tests for a HelloWorld class using PHPUnit. It also covers more advanced testing techniques like data providers, expected exceptions, fixtures, doubles, mocks, stubs, and database testing using examples like testing a BankAccount class. The document provides hints and tips for unit testing MVC frameworks like Zend Framework.
The document discusses Python's built-in debugger module pdb. It describes how to invoke the debugger using the -m pdb option when running a Python script. It then covers basic debugger commands like list (l), step (s), and quit (q) and how they allow inspecting and stepping through code line by line to debug programs.
PHPUnit is an automated unit testing framework for PHP. It allows developers to write tests for their code in PHP and run those tests to determine if the code is working as expected. Some key aspects of PHPUnit include writing tests in classes that extend the PHPUnit test case class, using assertions to validate expected outcomes, and the ability to test databases and output using PHPUnit extensions. PHPUnit is widely used for test-driven development in PHP projects.
Test your code like a pro - PHPUnit in practiceSebastian Marek
The day you realised that you can’t really tell what your code does is the day you stop being an amateur programmer and you turn into a professional developer. During this workshop you will learn about the most famous unit testing framework – PHPUnit, how it can help you gain confidence in your code and what to do (and what to avoid) to make your code testable. We will discuss unit testing best practices and talk about tools that can help you automate the whole process, so it becomes more of a habit then a necessity.
This document provides an overview of the Python unittest module for writing and running automated tests. It discusses how the unittest.TestCase class is used to define test classes with methods named "test_" that contain assertions. The unittest module then handles running the tests and provides features like test organization, discovery of test methods, and integration with other tools.
The document discusses unit testing and the PHPUnit testing framework. It provides an overview of what unit testing is, why it is useful, and how to get started with PHPUnit. Key points include that unit testing finds bugs early, encourages good coding practices, and makes codebases easier to change and deploy. PHPUnit is introduced as the most popular PHP testing framework. Instructions are given for installing PHPUnit via PEAR and writing basic tests, including test fixtures, assertions, and annotations. More advanced topics like mock objects, data providers, and exception testing are also covered.
This document provides an overview of PHPUnit, a unit testing framework for PHP. It introduces Sebastian Bergmann, the creator of PHPUnit, and describes some of PHPUnit's key features like test frameworks, integration with other tools, code coverage, and more. Examples are provided of writing unit tests with PHPUnit using the PHPUnit_Framework_TestCase class. Additional features like annotations, data providers, exceptions, groups, and behavior-driven development styles are also demonstrated.
This document provides an overview of test driven development with PHPUnit. It discusses what unit testing is, the benefits of testing, and how to get started with PHPUnit. Key topics covered include writing tests, assertions, dependencies, data providers, testing errors and exceptions, fixtures, and database testing. The document also mentions test output, incomplete/skipped tests, test doubles, code coverage analysis, and the skeleton generator.
- The document discusses best practices for writing PHPUnit tests, including writing tests, upgrading to PHPUnit 3.7, installing PHPUnit via different methods like PHAR, Composer, and PEAR, using specific assertions, and having a fast test suite.
- It recommends separating tests by folder structure or config file, only testing relevant behaviors of classes rather than internal methods, and not testing simple getters and setters. The goal is writing clean, testable code and tests that verify class behaviors rather than implementation details.
- A repo should keep code, config, deploy, and documentation matched through versioning and CI/CD tools. Code should be written for others, not just oneself.
- Documentation serves to explain implementation, purpose, context, decisions, and how components work together. Extended documentation includes code comments, docstrings, tests, commits, dev docs, ADRs, specs, and more.
- Maintaining clean organization, code style, testing, security, and extended documentation allows a repo to be understood and maintained over time by many contributors.
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策kwatch
The document discusses issues with the Test::More module for testing in Perl and proposes solutions. It notes that Test::More does not encourage writing tests based on specifications, does not structure tests well, and makes it hard to distinguish assertions. It recommends writing tests according to specifications rather than code, using structures like contexts and descriptions to organize tests, and printing output lines on a per-specification rather than per-assertion basis to improve readability. It also proposes functions like spec() and subtest() to help write more specification-based tests with Test::More.
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
This document provides an overview of GoogleMock, a mocking framework for C++. It defines what a mock object is and why they are useful for testing. GoogleMock allows specifying expectations for mock method calls, including how many times a method will be called and what it will return. It provides matchers to check arguments and actions to define return values or behaviors. The document demonstrates how to write mock classes, set expectations, and use mocks in tests to verify code interactions and behavior.
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
This document discusses different types of software testing including unit testing and integration testing. Unit testing involves writing code to test individual units or modules in isolation with few dependencies. Integration testing evaluates how modules function together as a group in a black box manner. The benefits of testing include facilitating code changes, enhancing software quality by catching bugs, serving as documentation, and improving code quality. Test-driven development is introduced as an approach where tests are written before code to drive the design. Continuous integration is also discussed as a way to fully automate testing, build, and code quality checks.
A story of how we went about packaging perl and all of the dependencies that our project has.
Where we were before, the chosen path, and the end result.
The pitfalls and a view on the pros and cons of the previous state of affairs versus the pros/cons of the end result.
Managing Perl Installations: A SysAdmin's ViewBaden Hughes
This document discusses managing Perl installations from a system administrator's perspective. It outlines various tools that come with Perl to help administrators manage modules, including which modules are installed (perldoc, ExtUtils::Installed, pmtools), installing and removing modules (CPAN.pm, PPM), and creating bundles of modules. It also describes how users can install modules to their own spaces using alternative module locations, PERL5LIB, and a customized CPAN configuration via MyConfig.pm. The goal is to empower users while reducing the administrative overhead for system administrators.
This document provides best practices for writing PHPUnit tests, including: do not write tests that do not test anything or test too much; exploit dependencies between tests; use the most specific assertion; decouple test code from test data; organize tests by class; run tests via XML configuration; disable unnecessary PHPUnit features; use code coverage whitelisting; annotate tests to make coverage more meaningful; and avoid unnecessary patterns like singletons.
This document provides an introduction and overview of PHPUnit, a tool for writing and running unit tests for PHP code. It discusses why unit testing and PHPUnit are useful, how to install and run PHPUnit, and best practices for writing effective unit tests with PHPUnit including describing tests clearly, using specific assertions, and decoupling test code and data. The document also addresses using PHPUnit for legacy code and references additional resources.
This document provides an overview of unit testing in PHP using PHPUnit. It discusses some goals of test automation like improving quality and reducing risks. It also covers the testing continuum from unit to integration to functional tests. The document introduces PHPUnit and how it is based on the xUnit family of tools. It then walks through an example of writing the first PHPUnit test to test a ROT13 encoding function in a test-driven way, demonstrating best practices like following the RED-GREEN-REFACTOR process and using assertions. Finally, it discusses principles of good test automation like independence of tests and isolating the system under test.
Unit testing with PHPUnit - there's life outside of TDDPaweł Michalik
Basics of PHPUnit and why is it even more relevant in legacy code. Key points of the framework are explained, along with mocking objects, test organisation, creating documentations with tests and accessing non-public objects (where applicable).
Live version with additional notes available at: http://pawelmichalik.net/presentations/unit-testing-with-phpunit?showNotes=true
Prezentacja dostępna także w języku polskim: http://pawelmichalik.net/prezentacje/testy-jednostkowe-w-phpunit?showNotes=true
This document introduces unit testing with PHPUnit. It discusses what unit testing is, why it's important, and tools like SimpleTest and PHPUnit. It provides examples of basic unit tests for a HelloWorld class using PHPUnit. It also covers more advanced testing techniques like data providers, expected exceptions, fixtures, doubles, mocks, stubs, and database testing using examples like testing a BankAccount class. The document provides hints and tips for unit testing MVC frameworks like Zend Framework.
The document discusses Python's built-in debugger module pdb. It describes how to invoke the debugger using the -m pdb option when running a Python script. It then covers basic debugger commands like list (l), step (s), and quit (q) and how they allow inspecting and stepping through code line by line to debug programs.
PHPUnit is an automated unit testing framework for PHP. It allows developers to write tests for their code in PHP and run those tests to determine if the code is working as expected. Some key aspects of PHPUnit include writing tests in classes that extend the PHPUnit test case class, using assertions to validate expected outcomes, and the ability to test databases and output using PHPUnit extensions. PHPUnit is widely used for test-driven development in PHP projects.
Test your code like a pro - PHPUnit in practiceSebastian Marek
The day you realised that you can’t really tell what your code does is the day you stop being an amateur programmer and you turn into a professional developer. During this workshop you will learn about the most famous unit testing framework – PHPUnit, how it can help you gain confidence in your code and what to do (and what to avoid) to make your code testable. We will discuss unit testing best practices and talk about tools that can help you automate the whole process, so it becomes more of a habit then a necessity.
This document provides an overview of the Python unittest module for writing and running automated tests. It discusses how the unittest.TestCase class is used to define test classes with methods named "test_" that contain assertions. The unittest module then handles running the tests and provides features like test organization, discovery of test methods, and integration with other tools.
The document discusses unit testing and the PHPUnit testing framework. It provides an overview of what unit testing is, why it is useful, and how to get started with PHPUnit. Key points include that unit testing finds bugs early, encourages good coding practices, and makes codebases easier to change and deploy. PHPUnit is introduced as the most popular PHP testing framework. Instructions are given for installing PHPUnit via PEAR and writing basic tests, including test fixtures, assertions, and annotations. More advanced topics like mock objects, data providers, and exception testing are also covered.
This document provides an overview of PHPUnit, a unit testing framework for PHP. It introduces Sebastian Bergmann, the creator of PHPUnit, and describes some of PHPUnit's key features like test frameworks, integration with other tools, code coverage, and more. Examples are provided of writing unit tests with PHPUnit using the PHPUnit_Framework_TestCase class. Additional features like annotations, data providers, exceptions, groups, and behavior-driven development styles are also demonstrated.
This document provides an overview of test driven development with PHPUnit. It discusses what unit testing is, the benefits of testing, and how to get started with PHPUnit. Key topics covered include writing tests, assertions, dependencies, data providers, testing errors and exceptions, fixtures, and database testing. The document also mentions test output, incomplete/skipped tests, test doubles, code coverage analysis, and the skeleton generator.
- The document discusses best practices for writing PHPUnit tests, including writing tests, upgrading to PHPUnit 3.7, installing PHPUnit via different methods like PHAR, Composer, and PEAR, using specific assertions, and having a fast test suite.
- It recommends separating tests by folder structure or config file, only testing relevant behaviors of classes rather than internal methods, and not testing simple getters and setters. The goal is writing clean, testable code and tests that verify class behaviors rather than implementation details.
- A repo should keep code, config, deploy, and documentation matched through versioning and CI/CD tools. Code should be written for others, not just oneself.
- Documentation serves to explain implementation, purpose, context, decisions, and how components work together. Extended documentation includes code comments, docstrings, tests, commits, dev docs, ADRs, specs, and more.
- Maintaining clean organization, code style, testing, security, and extended documentation allows a repo to be understood and maintained over time by many contributors.
What is wrong on Test::More? / Test::Moreが抱える問題点とその解決策kwatch
The document discusses issues with the Test::More module for testing in Perl and proposes solutions. It notes that Test::More does not encourage writing tests based on specifications, does not structure tests well, and makes it hard to distinguish assertions. It recommends writing tests according to specifications rather than code, using structures like contexts and descriptions to organize tests, and printing output lines on a per-specification rather than per-assertion basis to improve readability. It also proposes functions like spec() and subtest() to help write more specification-based tests with Test::More.
The presentation explains the PHP unit testing framework and provides a basic training on Testing with PHPunit. It Covers fundamental of unit testing, unit testing benefits and best practices. Starting ground up from PHP unit fundamentals, features of unit testing tries to explore advanced topics like Data providers, Fuxtures, Test doubles and more...
This document provides an overview of GoogleMock, a mocking framework for C++. It defines what a mock object is and why they are useful for testing. GoogleMock allows specifying expectations for mock method calls, including how many times a method will be called and what it will return. It provides matchers to check arguments and actions to define return values or behaviors. The document demonstrates how to write mock classes, set expectations, and use mocks in tests to verify code interactions and behavior.
Unit testing, everyone talks about it and wants to do it but never gets around to actually start testing. Complex spaghetti code and time / budget pressures are often the reasons why nobody dives in and gets started with testing. But when the application breaks, and people loose money or worse it's often too late.
In this talk I will take you on a journey with real examples that will show you how you can set up your tests, how to test complex situations with legacy spaghetti code, test web services, database interactions and how to gradually build a solid foundation to safeguard the core code base and everything around it.
Don't you want to be confident when you walk out the office?
phpunit is testing framework for php testing.
A browser is able to give the syntax error but what if in case of some logical error.
Phpunit testing enables you to check your logic.
It is fully object oriented framework.
It also can be enabled in Netbeans.
you can find the option of phpunit testing in Netbeans
This document discusses different types of software testing including unit testing and integration testing. Unit testing involves writing code to test individual units or modules in isolation with few dependencies. Integration testing evaluates how modules function together as a group in a black box manner. The benefits of testing include facilitating code changes, enhancing software quality by catching bugs, serving as documentation, and improving code quality. Test-driven development is introduced as an approach where tests are written before code to drive the design. Continuous integration is also discussed as a way to fully automate testing, build, and code quality checks.
A story of how we went about packaging perl and all of the dependencies that our project has.
Where we were before, the chosen path, and the end result.
The pitfalls and a view on the pros and cons of the previous state of affairs versus the pros/cons of the end result.
Managing Perl Installations: A SysAdmin's ViewBaden Hughes
This document discusses managing Perl installations from a system administrator's perspective. It outlines various tools that come with Perl to help administrators manage modules, including which modules are installed (perldoc, ExtUtils::Installed, pmtools), installing and removing modules (CPAN.pm, PPM), and creating bundles of modules. It also describes how users can install modules to their own spaces using alternative module locations, PERL5LIB, and a customized CPAN configuration via MyConfig.pm. The goal is to empower users while reducing the administrative overhead for system administrators.
The document provides guidance on packaging applications for the Maemo platform. It discusses finding software to package, creating the initial package files and structure using dh_make, the necessary files like changelog, copyright and control, how debhelper automates common packaging tasks, tracking dependencies, and other tools that can help like pbuilder and cowbuilder. While Maemo uses Debian packaging tools, it is not Debian and has its own build systems and conventions that allow it to innovate independently from Debian.
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
The document provides information on modern Puppet module development best practices. It discusses what modules are and common patterns like package, config, service that address 80% of module needs. It also covers validation of module parameters using Kwalify schemas, testing modules with rspec-puppet, and packaging modules for release on the Puppet Forge using the puppet-module tool. The document emphasizes the importance of coding style, linting with puppet-lint, and following patterns and best practices to create high quality, reusable modules.
The document provides various ways to work with Perl modules from the command line and within Perl scripts. Some of the key points discussed include:
1. Using the perl command with various options like -M, -T, -l, and -w to list installed Perl modules from the command line.
2. Using the ExtUtils::Installed module to get a list of installed modules within a Perl script.
3. Using the perldoc command to view documentation for built-in and installed Perl modules.
4. Configuring the CPAN module to install additional Perl modules from the command line.
5. Checking if a specific module is installed and viewing its version number.
Covered some of the Best Practices.
Reference:
http://www.brandonsavage.net/essential-ini-settings/
http://shiflett.org/blog/2005/feb/my-top-two-php-security-practices
http://www.php.net/manual/en/security.php
This document summarizes best practices for PHP coding standards, documentation, version control, and security. It recommends using an established coding standard like Zend or PEAR for consistency. It also recommends the PHP_CodeSniffer tool to check standards, and phpDocumentor for documenting code. Subversion is presented as an option for version control. For security, it emphasizes filtering all input and escaping all output.
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
Behavior-Driven Development and Acceptance Testing are heavily intertwined and in many aspects are one and the same. Both focus on starting at the outer layers of your application by concentrating on what matter to users; behavior. In this session/workshop we'll talk about how testing can be used both for specifying your application yet to be develop expected behavior and as accurate, running documentation that can be used to validate your stakeholder's acceptance criteria. We'll talk about the different types of testing and do a few hands-on exercises to flesh out a Rails application with RSpec and Capybara.
- Perlbrew is a tool for managing multiple perl installations on a system. It allows installing different versions of perl and switching between them.
- It isolates perl installations so that installing a new version does not affect existing site libraries or upgrade dependent modules. This avoids conflicts between applications.
- Perlbrew provides benefits like not requiring sudo for cpan, easier cleanup of perl environments, and ability to set up isolated perl environments for different applications to avoid incompatible issues.
perl often doesn't get updated because people don't have a way to know if their current code works with the new one. The problem is that they lack unit tests. This talk describes how simple it is to generate unit tests with Perl and shell, use them to automate solving problems like missing modules, and test a complete code base.
This document provides an overview of aspect-oriented programming (AOP) in Perl using the Aspect.pm module. It defines key AOP terminology like join points, pointcuts, advice, and aspects. It describes the features of Aspect.pm like creating pointcuts with strings, regexes, or code references to select subroutines, and writing before, after, and around advice. Examples show creating reusable aspects for logging, profiling, and enforcing design patterns.
Perl::Tidy formats Perl code to make it more readable by indenting, reformatting and applying coding standards. Perl::Critic analyzes Perl code and detects violations of best practices and coding standards to help improve code quality. Both tools can be configured using options and configuration files to customize formatting styles and select which coding standards to enforce.
This document discusses various code quality tools such as FindBugs, PMD, and Checkstyle. It provides information on what each tool is used for, how to install plugins for them in Eclipse, and how to configure them for use with Ant builds. FindBugs looks for potential bugs in Java bytecode. PMD scans source code for coding mistakes, dead code, complicated expressions, and duplicate code. Checkstyle checks that code complies with coding style rules. The document explains how to download and configure each tool so it can be run from Eclipse or as part of an Ant build.
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010singingfish
The document discusses improving documentation for Perl modules like Moose and Catalyst by focusing on providing working code examples and minimizing extraneous information. It advocates for an incremental, "git-based" approach to introducing concepts one by one and advertising examples. Key points made include assuming readers have minimal knowledge, reducing cognitive load, and crowdsourcing documentation improvements through a standard Pod format. Contributors are tasked with improving specific documentation areas by these principles.
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet
The document discusses test driven development (TDD) approaches for Puppet modules. It recommends:
1) Writing unit tests using Rspec-puppet before writing any Puppet code to validate requirements are met;
2) Using TDD practices like writing just enough code to pass tests and refactoring to develop Puppet modules;
3) Testing all resources, parameters, validation, and module logic to ensure high quality and prevent regressions.
This document discusses automated testing of Puppet code. It describes using RSpec-puppet for unit testing Puppet manifests and ensuring resources are properly configured. It also discusses performing "after testing" by executing tests in the user environment to check the final configuration and catch issues not found by Puppet reports. Post-provision checks (PPC) is presented as a framework for writing these types of integration tests and automating their execution after Puppet runs via tools like TeamCity.
Automated Puppet Testing - PuppetCamp Chicago '12 - Scott NottinghamPuppet
This document discusses automated testing of Puppet code. It describes using RSpec-puppet for unit testing Puppet manifests and ensuring resources are defined correctly. It also discusses performing "after testing" by executing tests on systems after Puppet runs to check configurations are applied as expected. Post Provision Checks (PPC) is introduced as a framework for these user space tests that can integrate with monitoring tools and be extended with plugins. The document emphasizes the importance of testing beyond just Puppet reports and provides examples of issues user space tests can find that manifest tests may miss.
This document discusses Open Flash Chart and Perl. It describes charting options in Perl like GD::Graph and Chart::OFC. It also shows samples of Open Flash Chart and explains the lifecycle of a chart request, from a web page requesting chart data to the chart being rendered and returned to the page. Finally, it discusses adding a chart to a web page using Open Flash Chart.
Slides from a talk on getting started with testing in Perl. The presentation was given at Frozen Perl 2008. This slideshow is a preview of a course taught be Stonehenge Consulting (http://www.stonehenge.com)
Josh McAdams discusses how starting with a simple one-line Perl script to tweet from the command line expanded over time into a full fledged module as more features and capabilities were added. The one-liner grew to include storing credentials, adding security, debugging, testing, documentation and packaging for CPAN. Perl and CPAN make what starts small easily expandable for sharing and reuse by others.
The document discusses the Eclipse Perl Development Tool (EPIC), which is an Eclipse plugin for Perl development. It provides several features for Perl coding within the Eclipse IDE, including syntax highlighting, syntax checking, code assistants, integration with Perl documentation, outlines of modules and subroutines, formatting code with perltidy, HTML export, code templates, a regex plugin, and Perl debugging. EPIC allows managing Perl projects and files within the Eclipse workspace and is most useful for large projects with multiple files.
Scrum is an agile development methodology that focuses on roles, backlogs, and time-boxed meetings. There are three core roles: the Scrum Master enforces practices and removes roadblocks, the Product Owner maintains the backlog and user stories, and the self-organizing Team delivers working software each sprint. Artifacts include the Product Backlog of prioritized user stories and the Sprint Backlog of selected stories. Sprints are 30-day cycles where selected stories are demonstrated as shippable at the end. Meetings include Planning, Daily Scrums, a Sprint Review, and Retrospective.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-und-domino-lizenzkostenreduzierung-in-der-welt-von-dlau/
DLAU und die Lizenzen nach dem CCB- und CCX-Modell sind für viele in der HCL-Community seit letztem Jahr ein heißes Thema. Als Notes- oder Domino-Kunde haben Sie vielleicht mit unerwartet hohen Benutzerzahlen und Lizenzgebühren zu kämpfen. Sie fragen sich vielleicht, wie diese neue Art der Lizenzierung funktioniert und welchen Nutzen sie Ihnen bringt. Vor allem wollen Sie sicherlich Ihr Budget einhalten und Kosten sparen, wo immer möglich. Das verstehen wir und wir möchten Ihnen dabei helfen!
Wir erklären Ihnen, wie Sie häufige Konfigurationsprobleme lösen können, die dazu führen können, dass mehr Benutzer gezählt werden als nötig, und wie Sie überflüssige oder ungenutzte Konten identifizieren und entfernen können, um Geld zu sparen. Es gibt auch einige Ansätze, die zu unnötigen Ausgaben führen können, z. B. wenn ein Personendokument anstelle eines Mail-Ins für geteilte Mailboxen verwendet wird. Wir zeigen Ihnen solche Fälle und deren Lösungen. Und natürlich erklären wir Ihnen das neue Lizenzmodell.
Nehmen Sie an diesem Webinar teil, bei dem HCL-Ambassador Marc Thomas und Gastredner Franz Walder Ihnen diese neue Welt näherbringen. Es vermittelt Ihnen die Tools und das Know-how, um den Überblick zu bewahren. Sie werden in der Lage sein, Ihre Kosten durch eine optimierte Domino-Konfiguration zu reduzieren und auch in Zukunft gering zu halten.
Diese Themen werden behandelt
- Reduzierung der Lizenzkosten durch Auffinden und Beheben von Fehlkonfigurationen und überflüssigen Konten
- Wie funktionieren CCB- und CCX-Lizenzen wirklich?
- Verstehen des DLAU-Tools und wie man es am besten nutzt
- Tipps für häufige Problembereiche, wie z. B. Team-Postfächer, Funktions-/Testbenutzer usw.
- Praxisbeispiele und Best Practices zum sofortigen Umsetzen
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/building-and-scaling-ai-applications-with-the-nx-ai-manager-a-presentation-from-network-optix/
Robin van Emden, Senior Director of Data Science at Network Optix, presents the “Building and Scaling AI Applications with the Nx AI Manager,” tutorial at the May 2024 Embedded Vision Summit.
In this presentation, van Emden covers the basics of scaling edge AI solutions using the Nx tool kit. He emphasizes the process of developing AI models and deploying them globally. He also showcases the conversion of AI models and the creation of effective edge AI pipelines, with a focus on pre-processing, model conversion, selecting the appropriate inference engine for the target hardware and post-processing.
van Emden shows how Nx can simplify the developer’s life and facilitate a rapid transition from concept to production-ready applications.He provides valuable insights into developing scalable and efficient edge AI solutions, with a strong focus on practical implementation.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
National Security Agency - NSA mobile device best practices
Extending Perl Critic
1. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Customizing and Extending Perl Critic Josh McAdams
2. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 A Quick Review - What is Perl Critic ... a static source code analyzer for Perl code ... a system of policies that are enforced on your code ... written by Jeffrey Ryan Thalhammer #!/usr/bin/perl print “Hallo, Denmark”;
3. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 A Quick Review --(0)> perlcritic hello_denmark.pl Code before strictures are enabled at line 3, column 1. See page 429 of PBP. (Severity: 5) ... is the jarring your memory? Running perlcritic...
4. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Customizing Perl Critic - How do you customize Perl Critic ... we saw much of this in the “Introduction” talk ... you can ... ignore policies ... assign new severities to policies ... group policies into themes ... pass constructor arguments to policies
5. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Customizing Perl Critic --(0)> cat ~/.perlcriticrc severity = 2 top = 5 exclude = Editor::RequireEmacsFileVariables Miscellanea::RequireRcsKeywords [ControlStructures::ProhibitPostfixControls] severity = 4 allow = if unless theme = iffy Looking into a .perlcriticrc file... ... but what about extending Perl Critic? The default severity to report How many violations to report Policies to ignore Change the default severity for a policy Pass arguments to the policy constructor, in this case telling it to allow trailing ifs and unlesses Apply a new theme
6. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Extending Perl Critic - Customizing is out-of-the-box easy, how do I extend Perl Critic? ... extending Perl Critic is as easy as adding new policy modules ... you can write your own, or grab some pre-written extensions from CPAN
7. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Surveying The Land - First, let's see what all policies Perl Critic provides for us ... there are 98 policies that you get in the core distribution ... the policies are all in the Perl::Critic::Policy namespace ... the policies are divided into 16 categories
8. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Core Policy Categories (1-4) - BuiltinFunctions ... fun with builtins like ProhibitStringyEval - ClassHierarchies ... oo rules like ProhibitExplicitISA - CodeLayout ... picky stuff like RequireTidyCode - ControlStructures ... control structure rules like ProhibitUnlessBlocks
9. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Core Policy Categories (5-8) - Documentation ... POD rules like RequirePodAtEnd - ErrorHandling ... the singular RequireCarping - InputOutput ... I/O related like ProhibitTwoArgOpen - Miscellanea ... random pickiness like RequireRcsKeywords
10. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Core Policy Categories (9-12) - Modules ... module rules like RequireEndWithOne - NamingConventions ... includes MyFavorite ProhibitMixedCaseSubs - References ... the one and only ProhibitDoubleSigils - RegularExpressions ... regex goodness like RequireExtendedFormatting
11. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Core Policy Categories (13-16) - Subroutines ... subroutine related like RequireFinalReturn - TestingAndDebugging ... tends to be prama-related things like RequireUseStrict - ValuesAndExpressions ... rhs rules such as ProhibitEmptyQuotes - Variables ... variable rules such as ProhibitLocalVars
12. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Core Policy Categories (the end) - hey, stop complaining, I could have done all 98 :) - so what if these polices aren't enough or just don't fit your organization? ... use someone else's extensions!
13. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::Bangs - a collection of Perl Critic policies written by Andy Lester - readily available on CPAN - adds the following policies: ... ProhibitCommentedOutCode ... because your not really using it and it's in svn anyway ... ProhibitFlagComments ... don't TODO, JFDI ... ProhibitNoPlan ... plan your tests, test your plan
14. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::Bangs (cont'd) - and a few more: ... ProhibitNumberedNames ... because $my_variable2 isn't very creative ... ProhibitRefProtoOrProto ... ref($proto) || $proto for determining class name is typically wrong ... ProhibitVagueNames ... $data, $info, $wtf? ... is that still not enough for you? The fully qualified name is Perl::Critic::Policy::Bangs::ProhibitNumberedNames
15. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::More - then how about more, Chris Dolan's Perl::Critic::More that is: ... CodeLayout::RequireASCII ... no high-bit code characters for you! ... Editor::RequireEmacsFileVariables ... special emacs variables... I'll have to take your word on this one ... Modules::PerlMinimumVersion ... how backwards-compatible are you? ... Modules::RequirePerlVersion ... use 5.8.0 ... how about one more set?
16. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::Lax - is Perl Critic too strict, the try Ricardo Signes's Perl::Critic::Lax: ... ProhibitEmptyQuotes::ExceptAsFallback ... $got || ''; looks too good not to use ... ProhibitStringyEval::ExceptForRequire ... stringy evals are bad and all, but sometimes you just gotta use them ... RequireEndWithTrueConst ... because sometimes humor is more important ... RequireExplicitPackage::ExceptForPragmata ... because your not always in need of a package, but you can always use warnings and strict
17. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 CPAN'd Extensions - we've seen a pretty good mix of Perl Critic extensions that are available on CPAN: ... Perl::Critic::Bangs ... Perl::Critic::More ... Perl::Critic::Lax ... but these won't always do the trick
18. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Creating Your Own Policies - Sometimes you just have to warm up the editor and code your own ... how difficult is it? - It is actually surprisingly easy to create your own policies, you just need to create a module in the Perl::Critic::Policy namespace that has some required subroutines. ... let's see what it takes
19. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - We'll start by looking at a core Policy that requires that you use the block form of grep - Here's what it is looking for: @matches = grep /pattern/, @list; #not ok @matches = grep { /pattern/ } @list; #ok ... real code please!
20. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - There's a little administrative overhead: package Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep; use strict; use warnings; use Perl::Critic::Utils qw{ :severities :classification :ppi }; use base 'Perl::Critic::Policy'; our $VERSION = 1.051; Declare your package Import some handy utilities Inherit from the core Policy class
21. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Some information required by Perl Critic: my $desc = q{Expression form of "grep"}; my $expl = [ 169 ]; A description of what you policy does Either a page reference for “Perl Best Practices” or an explaination of what the offending code is doing and instructions on how to fix it.
22. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Some information required by Perl Critic: sub supported_parameters { return() } sub default_severity { return $SEVERITY_HIGH } * See ControlStructures::ProhibitPostfixControls for an example Returns a list of constructor parameters that the module supports, in this case none* Returns a numeric value that indicates the default severity for the module. There are five constants exported from a Perl Critic utility module: $SEVERITY_HIGHEST = 5 $SEVERITY_HIGH = 4 $SEVERITY_MEDIUM = 3 $SEVERITY_LOW = 2 $SEVERITY_LOWEST = 1 Why these aren't 'brutal' through 'gental' I don't know
23. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Some information required by Perl Critic: sub default_themes { return qw( core bugs pbp ) } sub applies_to { return 'PPI::Token::Word' } Returns a list of default themes that identify this policy; you probably won't be using core Returns a list of PPI package names that the policy is applied to. Since all of the PPI DOM objects could be potentially analyzed by every Perl Critic policy, this provides a filter that gets passes your policy only the elements that you care about.
24. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - And now the method that does all of the work: sub violates { my ( $self, $elem, undef ) = @_; return if $elem ne 'grep'; return if ! is_function_call($elem); my $arg = first_arg($elem); return if !$arg; return if $arg->isa('PPI::Structure::Block'); return $self->violation( $desc, $expl, $elem ); } The method is passed the policy object, a PPI document object representing the current element in the code, and the entire PPI document. If a problem is found, the violation method is called with the the policy description, explanation of the issue, and offending PPI object as arguments... I guess you can tweak the description and explanation if you want.
25. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Let's take a closer look at the meat of the subroutine: return if $elem ne 'grep'; return if ! is_function_call($elem); We know we are getting PPI::Token::Words, which are subclasses of PPI::Element, which in turn overrides 'ne' to return the actual content of the element... in this case the actual word. We only want to consider 'grep' is_function_call is one of those handy subroutines exported by Perl::Critic::Utils. In this case, it does the dirty work involved in determining if a given word is a function call based on the PPI::Token::Word's context in the document. We only want to consider grep if it is actually the function call to grep.
26. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Only a little more to go my $arg = first_arg($elem); return if !$arg; return if $arg->isa('PPI::Structure::Block'); first_arg is another one of those Perl Critic utility methods. In this case, it is plucking the first argument passed to the grep function. If there is no argument, we can't tell if it is null, so assume it's not wrong. Finally we see if the first argument to grep is a block. If it is, then everything is okay.
27. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Let's look at the code one more time sub violates { my ( $self, $elem, undef ) = @_; return if $elem ne 'grep'; return if ! is_function_call($elem); my $arg = first_arg($elem); return if !$arg; return if $arg->isa('PPI::Structure::Block'); return $self->violation( $desc, $expl, $elem ); }
28. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 BuiltinFunctions::RequireBlockGrep - Do you see the basic idea behind the code? ... We try to find every excuse for why the code is not in violation ... are you a grep? ... are you a grep function? ... do you have any arguments? ... is your first argument a block? ... and finally, we return a violation ... innocent until proven guilty ... your code doesn't have to flow this way, but it tends to be a good way to approach the problem
29. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 What Did We Learn - Building custom policies is pretty easy; it requires: ... a little bit of setup code ... a package name (Perl::Critic::Policy::) ... a description of the policy ... an explanation of the issue ... a default set of themes ... a default severity ... a list of PPI elements to consider ... an optional list of accepted constructor arguments ... a violates method to do all of the work ... but this is typically a small amount of work ... most policies can be implemented in tens of lines of code
30. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::Utils and PPI - So what makes policy building tricky? ... working with Perl::Critic::Utils and PPI ... both are easy to use, but it takes some time to remember all of the functionality that they provide
31. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Perl::Critic::Utils - Provides 33 importable subroutines for analyzing and working with PPI elements ... some examples: ... is_hash_key ... is_label_pointer ... is_perl_bareword ... is_perl_builtin_with_optional_argument - Provides 21 importable constants ... some examples: ... $COMMA ... $FATCOMMA ... you really just have to RTFM
32. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 PPI - Provides 62 types of PDOM objects representing pieces of ... some examples: ... PPI::Document::Fragment ... PPI::Statement::Package ... PPI::Structure::ForLoop ... PPI::Token::Whitespace ... PPI::Token::QuoteLike::Backtick - Any of the PDOM types could be included in your applies_to() list of elements that you want to consider in your policy ... there are so many of these that you really have to RTFM
33. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 PPI::Element - Most of the PPI PDOM objects you'll be interested in inherit from PPI::Element, which provides it's own set of utility methods to help you poke around the PDOM passed to your violates() method. ... some examples: ... significant – is the element really significant to the code ... next_sibling – next element in the PDOM ... snext_sibling – same as above, only skips insignificant elements ... previous_token – previous PPI::Token element - There are a lot of these that let you walk around the code
34. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Testing Your Policies - Testing policies is actually quite easy also... if you peek into the Perl Critic source and borrow code from them that is :) - All that you have to do is create a Perl::Critic object and your policy object and then just run the policy on a suite of code samples
35. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Testing Your Policies - First set use some modules and then set up some tests use warnings; use strict; use Test::More; use Perl::Critic; my @to_validate = ( 'grep {}', 'grep { 1 }', 'grip ""', ); my @to_violate = ( 'grep ""', 'grep "1"', ); plan tests => @to_validate + @to_violate; I like setting up pieces of code that I expect to be valid and pieces that I expect to violate my policy And dynamically creating my test plan based on the number of code samples I'm using
36. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Testing Your Policies - Then create a Perl::Critic object and an object of your policy my $c = Perl::Critic->new( -profile => 'NONE' ); my $policy = Perl::Critic::Policy::BuiltinFunctions::RequireBlockGrep ->new(); $c->add_policy( -policy => $policy ); Just create the two objects and add your policy as the one-and-only policy
37. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Testing Your Policies - And finally apply your policy to the code samples ok( ( scalar $c->critique( _ ) == 0 ), 'policy on valid code' ) for (@to_validate); ok( ( scalar $c->critique( _ ) > 0 ), 'policy on invalid code' ) for (@to_violate);
38. Customizing and Extending Perl Critic Nordic Perl Workshop 2007 Testing Your Policies - We have tests! --(0)> prove test.pl test....ok All tests successful. Files=1, Tests=6, 1 wallclock secs ( 0.86 cusr + 0.18 csys = 1.04 CPU )