diff --git a/.github/workflows/perl-critic.yml b/.github/workflows/perl-critic.yml new file mode 100644 index 00000000000..840be05091a --- /dev/null +++ b/.github/workflows/perl-critic.yml @@ -0,0 +1,14 @@ +--- +name: 'Perl critic' + +on: [push, pull_request] + +jobs: + perl-critic-checks: + runs-on: ubuntu-latest + name: "Perlcritic" + container: + image: perldocker/perl-tester + steps: + - uses: actions/checkout@v4 + - run: make test-critic diff --git a/.perlcriticrc b/.perlcriticrc deleted file mode 100644 index e6dd3ae5b4e..00000000000 --- a/.perlcriticrc +++ /dev/null @@ -1,9 +0,0 @@ -theme = freenode -severity = 4 - -# TODO: Remove once Perl::Critic::Freenode 0.028 is widely available -[Freenode::DiscouragedModules] -severity = 3 - -[Perl::Critic::Policy::HashKeyQuotes] -severity = 5 diff --git a/.perlcriticrc b/.perlcriticrc new file mode 120000 index 00000000000..48360c8c6a8 --- /dev/null +++ b/.perlcriticrc @@ -0,0 +1 @@ +external/os-autoinst-common/.perlcriticrc \ No newline at end of file diff --git a/Makefile b/Makefile index a013592012a..e370a597a23 100644 --- a/Makefile +++ b/Makefile @@ -293,7 +293,7 @@ endif .PHONY: test-critic test-critic: - PERL5LIB=lib/perlcritic:$$PERL5LIB perlcritic lib + tools/perlcritic lib .PHONY: test-tidy-compile test-tidy-compile: diff --git a/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm b/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm deleted file mode 100644 index 126816103b9..00000000000 --- a/lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm +++ /dev/null @@ -1,32 +0,0 @@ -package Perl::Critic::Policy::HashKeyQuotes; - - -use Mojo::Base 'Perl::Critic::Policy'; - -use Perl::Critic::Utils qw( :severities :classification :ppi ); - -our $VERSION = '0.0.1'; - -sub default_severity { return $SEVERITY_HIGH } -sub default_themes { return qw(openqa) } -sub applies_to { return qw(PPI::Token::Quote::Single PPI::Token::Quote::Double) } - -# check that hashes are not overly using quotes -# (os-autoinst coding style) - -sub violates { - my ($self, $elem) = @_; - - #we only want the check hash keys - return if !is_hash_key($elem); - - my $c = $elem->content; - # special characters - return if $c =~ m/[- \/<>.=_:\\\$]/; - - my $desc = q{Hash key with quotes}; - my $expl = q{Avoid useless quotes}; - return $self->violation($desc, $expl, $elem); -} - -1; diff --git a/tools/perlcritic b/tools/perlcritic new file mode 120000 index 00000000000..cf46f548eb4 --- /dev/null +++ b/tools/perlcritic @@ -0,0 +1 @@ +../external/os-autoinst-common/tools/perlcritic \ No newline at end of file