til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Get Started Linting with Perl::Critic

When you alter your Perl::Critic configuration outlined in the perlcriticrc file, you can run check your source code against the new configuration. This is a good practice when adopting a new Perl::Critic configuration or when starting to use Perl::Critic on a project, which has not been criticized before.

Firstly you have to install Perl::Critic.

cpanm Perl::Critic

Then you can run the following command to check your source code against the new configuration.

perlcritic .

If you want to use a different configuration file, you can use the --profile flag.

perlcritic --profile your_perl_critic_profile .

And if you want to make sure no profiles are used.

perlcritic --noprofile .

When starting to criticize a project, which has not been criticized before, you can get overwhelmed by the sheer number of violations.

Luckily Perl::Critic has a --severity flag, which allows you to only show violations of a certain severity.

  • gentle (5) - default
  • stern (4)
  • harsh (3)
  • cruel (2)
  • brutal (1)

You can use the --severity flag to only show violations of a certain severity.

perlcritic --profile-proto