Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use perlcritic wrapper and plugins from common repo #5841

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions .perlcriticrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
theme = freenode
theme = community + openqa
severity = 4
include = strict ValuesAndExpressions::ProhibitInterpolationOfLiterals

# TODO: Remove once Perl::Critic::Freenode 0.028 is widely available
[Freenode::DiscouragedModules]
verbose = ::warning file=%f,line=%l,col=%c,title=%m - severity %s::[%p] %e\n

# == Perlcritic Policies
# -- Test::Most brings in strict & warnings
[TestingAndDebugging::RequireUseStrict]
equivalent_modules = Test::Most

[TestingAndDebugging::RequireUseWarnings]
equivalent_modules = Test::Most

# -- Avoid double quotes unless there's interpolation or a single quote.
[ValuesAndExpressions::ProhibitInterpolationOfLiterals]
allow_if_string_contains_single_quote = 1
severity = 3

[Perl::Critic::Policy::HashKeyQuotes]
# -- Prohibit deep nesting
[ControlStructures::ProhibitDeepNests]
severity = 4
add_themes = community
max_nests = 4

# == Community Policies
# -- Test::Most brings in strict & warnings
[Freenode::StrictWarnings]
extra_importers = Test::Most

# -- Test::Most brings in strict & warnings
[Community::StrictWarnings]
extra_importers = Test::Most

[Community::DiscouragedModules]
severity = 3

# Test modules have no package declaration
[Community::PackageMatchesFilename]
severity = 1

# == Custom Policies
# -- Useless quotes on hashes
[HashKeyQuotes]
severity = 5

# -- Superfluous use strict/warning.
[RedundantStrictWarning]
equivalent_modules = Test::Most
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ endif

.PHONY: test-critic
test-critic:
PERL5LIB=lib/perlcritic:$$PERL5LIB perlcritic lib
perlcritic lib

.PHONY: test-tidy-compile
test-tidy-compile:
Expand Down
2 changes: 1 addition & 1 deletion external/os-autoinst-common/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = [email protected]:os-autoinst/os-autoinst-common.git
branch = master
commit = 9a505a76f9835862211cdf59e07e2a3865320f49
commit = c9346faed0e4a2516ccbb2c6253804ac8cf5066d
parent = 549ee3ba37e2e65335466e39899ac4321028a01a
method = merge
cmdver = 0.4.6
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ sub violates ($self, $elem, $document) {
# skip anything that's not a hash key
return () unless is_hash_key($elem);

my $k = $elem->literal;
# only some PPI::Token::Quote::* classes implement literal
my $k = $elem->can('literal') ? $elem->literal : $elem->string;

# skip anything that has a special symbol in the content
return () unless $k =~ m/^\w+$/;

Expand Down
6 changes: 5 additions & 1 deletion external/os-autoinst-common/tools/perlcritic
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# perlcritic with auto-injection of custom perlcritic rules.
use strict;
use warnings;
use v5.10;
use experimental 'signatures';
use FindBin '$Bin';

Expand All @@ -16,5 +17,8 @@ sub extra_include_paths (@extra_paths) {
}

$ENV{PERL5LIB} = join(':', (extra_include_paths('lib/perlcritic'), $ENV{PERL5LIB} // ''));

unless (@ARGV) {
say "Usage: $0 files-or-directories";
exit;
}
exec 'perlcritic', @ARGV;
32 changes: 0 additions & 32 deletions lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm

This file was deleted.

1 change: 1 addition & 0 deletions tools/perlcritic
Loading