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

Fix Perl::Critic::Policy::HashKeyQuotes #53

Merged
merged 1 commit into from
Aug 12, 2024
Merged
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
4 changes: 3 additions & 1 deletion lib/perlcritic/Perl/Critic/Policy/HashKeyQuotes.pm
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 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;
Loading