Perl::...oCritic(3pm)

πŸ’– NAME πŸ’–

Okay bestie, this is the page for Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic β€” Forbid a bare ## no critic β€” and it lives under the Perl::...oCritic(3pm) label in User Contributed Perl Documentation. Same iconic Policy, just with the header/footer abbreviation energy. πŸ’…

πŸ¦‹ AFFILIATION πŸ¦‹

This Policy is part of the core Perl::Critic distribution. Periodt. ✨

πŸ’€ DESCRIPTION πŸ’€

So here's the tea: a bare ## no critic annotation will disable all the active Policies. πŸ’€ That creates holes for other, unintended violations to appear in your code. It is better to disable only the particular Policies that you need to get around.

By putting Policy names in a comma-separated list after the ## no critic annotation, then it will only disable the named Policies. Policy names are matched as regular expressions, so you can use shortened Policy names, or patterns that match several Policies. This Policy generates a violation any time that an unrestricted ## no critic annotation appears.

## no critic                     # not ok
## no critic ''                  # not ok
## no critic ()                  # not ok
## no critic qw()                # not ok

## no critic   (Policy1, Policy2)  # ok
## no critic   (Policy1 Policy2)   # ok (can use spaces to separate)
## no critic qw(Policy1 Policy2)   # ok (the preferred style)

Those first four? not ok. πŸ™ˆ The next three? ok, slay. And the qw(...) one is the preferred style, iykyk. 🫢

🫢 NOTE 🫢

Unfortunately, Perl::Critic is very sloppy about parsing the Policy names that appear after a ##no critic annotation. 😭 For example, you might be using one of these broken syntaxes...

## no critic Policy1 Policy2
## no critic 'Policy1, Policy2'
## no critic "Policy1, Policy2"
## no critic "Policy1", "Policy2"

In all of these cases, Perl::Critic will silently disable all Policies, rather than just the ones you requested. πŸ’€ But if you use the ProhibitUnrestrictedNoCritic Policy, all of these will generate violations. That way, you can track them down and correct them to use the correct syntax, as shown above in the DESCRIPTION. If you've been using the syntax that is shown throughout the Perl::Critic documentation for the last few years, then you should be fine. 🫢

πŸŽ€ CONFIGURATION πŸŽ€

This Policy is not configurable except for the standard options. That's it, that's the config. πŸ’…

πŸ‘‘ AUTHOR πŸ‘‘

Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> β€” iconic. πŸ’–

Copyright (c) 2008-2023 Imaginative Software Systems

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.


That's the whole page, bestie 🫢 β€” it's from perl v5.42.0, dated 2024-10-23, and the footer calls it Perl::...oCritic(3pm) (User Contributed Perl Documentation). Byeeee πŸ’–βœ¨

πŸ“¦ where this page comes from