---
name: "Perl::Critic::Annotation"
section: "3pm"
platform: "linux"
package: "perl-perl-critic"
version: "1.156-3"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Perl::Critic::Annotation"
---

# Perl::Critic::Annotation(3pm)

A "## no critic" annotation in a document.

## NAME

Perl::Critic::Annotation - A "## no critic" annotation in a document.

## SYNOPSIS

```
  use Perl::Critic::Annotation;
  $annotation = Perl::Critic::Annotation->new( -element => $no_critic_ppi_element );
  $bool = $annotation->disables_line( $number );
  $bool = $annotation->disables_policy( $policy_object );
  $bool = $annotation->disables_all_policies();
  ($start, $end) = $annotation->effective_range();
  @disabled_policy_names = $annotation->disabled_policies();
```

## DESCRIPTION

`"Perl::Critic::Annotation"` represents a single `"## no critic"` annotation in a PPI::Document.  The Annotation takes care of parsing the annotation and keeps track of which lines and Policies it affects. It is intended to encapsulate the details of the no-critic annotations, and to provide a way for Policy objects to interact with the annotations (via a Perl::Critic::Document).

## INTERFACE SUPPORT

This is considered to be a non-public class.  Its interface is subject to change without notice.

## CLASS METHODS

- create\_annotations( -doc =\> $doc )

  Given a Perl::Critic::Document, finds all the `"## no critic"` annotations and constructs a new `"Perl::Critic::Annotation"` for each one and returns them.  The order of the returned objects is not defined.  It is generally expected that clients will use this interface rather than calling the `"Perl::Critic::Annotation"` constructor directly.

## CONSTRUCTOR

- "new( -element =\> $ppi\_annotation\_element )"

  Returns a reference to a new Annotation object.  The **-element** argument is required and should be a `"PPI::Token::Comment"` that conforms to the `"## no critic"` syntax.

## METHODS

- disables\_line( $line )

  Returns true if this Annotation disables `$line` for any (or all) Policies.

- disables\_policy( $policy\_object )

  - disables\_policy( $policy\_name )

  Returns true if this Annotation disables `$polciy_object` or `$policy_name` at any (or all) lines.

- disables\_all\_policies()

  Returns true if this Annotation disables all Policies at any (or all) lines.  If this method returns true, `"disabled_policies"` will return an empty list.

- effective\_range()

  Returns a two-element list, representing the first and last line numbers where this Annotation has effect.

- disabled\_policies()

  Returns a list of the names of the Policies that are affected by this Annotation.  If this list is empty, then it means that all Policies are affected by this Annotation, and `disables_all_policies()` should return true.

- element()

  Returns the PPI::Element where this annotation started.  This is typically an instance of PPI::Token::Comment.

## AUTHOR

Jeffrey Ryan Thalhammer \<jeff@imaginative-software.com\>

## COPYRIGHT

Copyright (c) 2005-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.
