App-perl-distrolint

 view release on metacpan or  search on metacpan

lib/App/perl/distrolint/Check/Pod.pm  view on Meta::CPAN

}

=head2 Checks on C<FUNCTIONS> and C<METHODS>

For every C<=head2> inside C<=head1 FUNCTIONS> or C<=head1 METHODS>, the text
is checked to ensure it is a bareword function/method name, optionally
followed by other clarifying text after whitespace.

After every C<=head2> the next paragraph must be a verbatim paragraph,
presumed to contain the function's minsynopsis code. The contents of this
are also checked, to see that the first line looks like an example calling
the named function or method, that ends in a semicolon.

The function name can optionally be preceeded by a variable assignment to
indicate the return value (C<$var = ...> or C<($list, $of, @vars) = ...>),
optionally prefixed with C<my>. It can optionally be preceeded by a variable
containing the invocant name and a method call arrow (C<< $var->... >>). It
can optionally be followed by any other text in parentheses, to indicate the
arguments passed. It can optionally use an C<await> expression, used to
indicate it is a L<Future>-returning asynchronous function or method.

lib/App/perl/distrolint/Check/SubSignatures.pm  view on Meta::CPAN

(method_declaration_statement (signature) ? @signature)
   @method

(anonymous_subroutine_expression (signature) ? @signature)
   @sub

(anonymous_method_expression (signature) ? @signature)
   @method
EOF

my sub proto_looks_like_signature ( $proto )
{
   # prototype must be wrapped in (...)
   $proto =~ s/^\((.*)\)$/$1/ or
      return 0;

   # trim
   $proto =~ s/^\s+//;
   $proto =~ s/\s+$//;

   # Empty string would count as a zero-arg signature

lib/App/perl/distrolint/Check/SubSignatures.pm  view on Meta::CPAN

            if any { $_ eq "signatures" } @features;
      }
      elsif( $node = $capture->{sub} or $node = $capture->{method} ) {
         my $kw = ( $capture->{sub} ) ? "sub" : "method";
         my $has_signature = defined $capture->{signature};
         # tree-sitter-perl can't tell the difference between prototypes
         # and signatures
         if( $context->{use_feature_signatures} and not $has_signature ) {
            my $proto_node = first { $_->type eq "prototype" } $node->child_nodes;

            $has_signature = proto_looks_like_signature( $proto_node->text ) if $proto_node;
         }

         if( $context->{use_feature_signatures} and !$has_signature ) {
            App->diag( App->format_file( $file, $node->start_row + 1 ), " declares a $kw without signature" );
            $ok = 0;
         }
      }
      else {
         my @names = sort keys %$capture;
         die "TODO: Unsure how to handle captures <@names>\n";



( run in 2.264 seconds using v1.01-cache-2.11-cpan-d8267643d1d )