Thanks. All those points have helped.
Here is an initial idea for getting ProhibitLeadingZeros to recognize make_path. I am certainly missing something obvious. I have only tested it against the following:
#!/usr/bin/perl use File::Path qw(make_path); my $path1 = 'foo'; my $path2 = 'foo'; make_path($path1, { mode => 0775}); make_path($path1, $path2, { mode => 0775}); make_path('apath3', { mode => 0775}); make_path('apath4' 'apath5', { mode => 0775});
Here is what I have tried in Utils.pm and ProhibitLeadingZeros.pm.
12c12 < our $VERSION = '1.157'; --- > our $VERSION = '1.156'; 47d46 < return if _is_key_in_make_path($elem); 114,126d112 < sub _is_key_in_make_path { < my ($elem) = @_; < my $previous_token = < _previous_token_that_is_a_key($elem); < return if not $previous_token and $previous_token ne 'mode'; < < $previous_token = _previous_token_that_is_a_function($elem); < print qq(LLL "),$previous_token->content(),qq("\n); < < state $is_make_path = { hashify( 'make_path', 'File::Path::make_ +path' ) }; < return $is_make_path->{$previous_token->content()}; < } < 222,263d207 < return $previous_token; < } < < sub _previous_token_that_is_a_key { < my ($elem) = @_; < < state $is_not_key = { hashify( $OPENING_BRACE, $CLOSING_BRACE, < $COMMA, $SPACE, '=>' ), }; < < my $previous_token = $elem->previous_token(); < while ( < $previous_token < and < not $previous_token->significant() < or $is_not_key->{$previous_token->content()} < ) { < $previous_token = $previous_token->previous_token(); < } < return $previous_token; < } < < sub _previous_token_that_is_a_function { < my ($elem) = @_; < < state $is_not_key = { hashify( $LEFT_PAREN, $RIGHT_PAREN, < $OPENING_BRACE, $CLOSING_BRACE, < $COMMA, $SPACE, '=>' ), }; < state $is_key = { hashify( 'group', 'uid', 'user', 'owner', 'err +or', < 'verbose', 'chmod', 'mode' ), }; < < my $previous_token = $elem->previous_token(); < while ( < $previous_token < and ( < $is_not_key->{$previous_token->content()} < or $is_key->{$previous_token->content()} < or $previous_token->content() =~ m/^\$\w+$/ < or $previous_token->content() =~ m/^(\p{Quotation_Mark}).+\ +1$/ < ) < ) { < $previous_token = $previous_token->previous_token(); < }
and
25c25 < our $VERSION = '1.157'; --- > our $VERSION = '1.156'; 62,63d61 < $OPENING_BRACE < $CLOSING_BRACE 143,144d140 < $OPENING_BRACE < $CLOSING_BRACE 196,215c192,209 < Readonly::Scalar our $COMMA => q{,}; < Readonly::Scalar our $EQUAL => q{=}; < Readonly::Scalar our $FATCOMMA => q{=>}; < Readonly::Scalar our $COLON => q{:}; < Readonly::Scalar our $SCOLON => q{;}; < Readonly::Scalar our $QUOTE => q{'}; < Readonly::Scalar our $DQUOTE => q{"}; < Readonly::Scalar our $BACKTICK => q{`}; < Readonly::Scalar our $PERIOD => q{.}; < Readonly::Scalar our $PIPE => q{|}; < Readonly::Scalar our $SPACE => q{ }; < Readonly::Scalar our $SLASH => q{/}; < Readonly::Scalar our $BSLASH => q{\\}; < Readonly::Scalar our $LEFT_PAREN => q{(}; < Readonly::Scalar our $RIGHT_PAREN => q{)}; < Readonly::Scalar our $OPENING_BRACE => q{\{}; < Readonly::Scalar our $CLOSING_BRACE => q{\}}; < Readonly::Scalar our $EMPTY => q{}; < Readonly::Scalar our $TRUE => 1; < Readonly::Scalar our $FALSE => 0; --- > Readonly::Scalar our $COMMA => q{,}; > Readonly::Scalar our $EQUAL => q{=}; > Readonly::Scalar our $FATCOMMA => q{=>}; > Readonly::Scalar our $COLON => q{:}; > Readonly::Scalar our $SCOLON => q{;}; > Readonly::Scalar our $QUOTE => q{'}; > Readonly::Scalar our $DQUOTE => q{"}; > Readonly::Scalar our $BACKTICK => q{`}; > Readonly::Scalar our $PERIOD => q{.}; > Readonly::Scalar our $PIPE => q{|}; > Readonly::Scalar our $SPACE => q{ }; > Readonly::Scalar our $SLASH => q{/}; > Readonly::Scalar our $BSLASH => q{\\}; > Readonly::Scalar our $LEFT_PAREN => q{(}; > Readonly::Scalar our $RIGHT_PAREN => q{)}; > Readonly::Scalar our $EMPTY => q{}; > Readonly::Scalar our $TRUE => 1; > Readonly::Scalar our $FALSE => 0;
(PS. The site is hard to reach. Sometimes the browser gives a site unavailable error but mostly it just times out. Can't the LLM bots be banned with NFTables or PF there?)
In reply to Re^2: Perl::Critic versus File::Path
by mldvx4
in thread Perl::Critic versus File::Path
by mldvx4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |