logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Documentation::ProhibitLinkToSelf - don't L<> link to own POD

Description

       This policy is part of the "Perl::Critic::Pulp" add-on.  It asks you not to use "L<>" markup to refer to
       a POD document itself.

           =head1 NAME

           My::Package - something

           =head1 DESCRIPTION

           L<My::Package> does blah blah ...     # bad

           =head1 SEE ALSO

           L<My::Package>                        # bad

       The idea is that it doesn't make sense to link to a document from within itself.  If rendered as a
       clickable link then it may suggest there's somewhere else to go to read about the module when in fact
       you're already looking at it.

       This is only a minor thing though, so this policy is low severity and under the "cosmetic" theme (see
       "POLICY THEMES" in Perl::Critic).

       In ordinary text the suggestion is plain "C<>" or similar for one's own module name,

           C<My::Package> does something something ...   # ok

       In a "SEE ALSO" a link to self in very likely a typo, or too much cut and paste, or at least pretty
       unnecessary since there's no need to "see also" what you've just read.

       If linking to a particular section within one's own document then use "L<>" with just the section part.
       This will probably give better looking output from the formatters too,

           L<My::Package/SECTION>      # bad

           L</SECTION>                 # ok

       For this policy the name of the POD is picked out of the "=head1 NAME" section, so doesn't depend on the
       filename or directory where "perlcritic" is run.  In the current code multiple names can be given in man-
       page style.  Not sure if that's a good idea.

           =head1 NAME

           My::Package -- blah

           My::Package::Parser -- and its parser

           =head1 DESCRIPTION

       It's always possible an "L<>" is right and in fact the "NAME" appearing is wrong.  A violation on the
       "L<>" will at least show there's something fishy in the one or the other.

   Disabling
       If you don't care about this then you can always disable "ProhibitLinkToSelf" from your .perlcriticrc
       file in the usual way (see "CONFIGURATION" in Perl::Critic),

           [-Documentation::ProhibitLinkToSelf]

       If you like to almost always put "L<>" on module names, including in the module's own POD, then disable
       this policy.  Maybe an option in the future could allow links to self in ordinary text but prohibit in
       "SEE ALSO".

Home Page

Name

       Perl::Critic::Policy::Documentation::ProhibitLinkToSelf - don't L<> link to own POD

See Also

       Perl::Critic::Pulp, Perl::Critic

       Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName,
       Perl::Critic::Policy::Documentation::ProhibitAdjacentLinks

See Also