NAME

Dist::Conformance::Check::CriticProfile - The perlcritic profile is its template, with the overrides of the repository

VERSION

version 0.008

DESCRIPTION

The profile is not edited by hand. It is the template, with the variables filled in, and with the overrides of the repository applied. So the standards decide every policy and every parameter, and a repository says where it departs from them in .conformance.yml, where a reviewer sees it. The comments of the profile are those of the template. A note about an override goes in .conformance.yml, beside it.

Each entry of overrides names a policy, with or without the prefix Perl::Critic::Policy::, and says one of these. A name that is the last parts of a name in the template, such as ProhibitLeadingZeros for Plicease::ProhibitLeadingZeros, is that policy, as Perl::Critic reads it.

off

The profile turns the policy off with [-Name], whether the template enables it or does not name it. A profile that sets severity low runs every installed policy that it does not turn off.

a mapping of parameters

The profile enables the policy, with the parameters of the template and these over them. A parameter whose value is ~ is removed. An empty mapping enables the policy with the parameters of the template, so it adds a policy that the template does not name, or turns on one that the template turns off.

settings does the same for the global settings, the keys before the first section, such as severity: each key replaces the setting of the template, and ~ removes it.

The overrides change the text of the template in place. A parameter that an override changes stays on its line, a new parameter goes after the last parameter of its section, and a policy that the template does not name goes at the end of the file.

The check passes when the profile is that text. It fails when the file is missing, and when it differs in what Perl::Critic reads: a policy that it lacks, a policy that neither the template nor the overrides name, a policy that it turns on or off otherwise, a parameter, or a global setting. The detail names each. A profile that differs only in comments or layout is info. A profile that does not parse fails.

So when the standards add a policy, drop one, turn one off or change a parameter, every profile that does not follow fails, and the update brings it along. A policy that the template drops leaves every profile, unless an override names it.

The update writes the text whenever the file differs from it, also in the comments. It replaces whatever the file had, so run conformance adopt before the first update of a profile that has changes of its own. See "adopt". A template with a placeholder that nothing fills is not written: the update says which variables it needs.

METHODS

overrides

The entries of overrides, by the short name of each policy. Dies on a name that is not that of a policy, and on two entries for one policy.

expected

The text that the profile must be: the template, its placeholders filled in, with the overrides and the settings applied, as "DESCRIPTION" says. Dies when a placeholder has no variable, and when the template does not parse.

check

($snapshot). The status and the detail that "DESCRIPTION" says, for the profile in $snapshot.

update

Writes "expected" to the profile when the file differs from it.

adopt

($snapshot). The overrides and settings that make "expected" read as the profile in $snapshot reads now, as a hash reference with the keys that hold something. Nothing when the profile is missing, or needs neither. A policy that the template names and the profile lacks is not adopted: the profile lacked it because the template gained it later. A policy that the profile names by the last parts of a name that the template gives in full, such as ProhibitLeadingZeros for Plicease::ProhibitLeadingZeros, is the policy of the template, as Perl::Critic reads it, and is adopted by the full name. Dies when either does not parse, and when a placeholder has no variable.

FUNCTIONS

policy_of

($section). Whether the header $section of a profile turns its policy off, and the short name of the policy.

profile_of

($text, $where). What Perl::Critic reads from the profile $text, as a hash reference: settings, the global settings, and policies, from the short name of each policy that a section names to a hash reference with off, whether it turns the policy off, and parameters. Dies, naming $where, when it does not parse.

header_of

($line). The section that the line $line of a profile starts, as Config::Tiny reads it, with its inline ; comment: undef when it starts none.

parameter_of

($line). The key and the value that the line $line of a profile sets, as Config::Tiny reads them, or nothing for a line that sets none.

rewrite

(\@lines, \%overlay). The lines @lines of a section, without its header, with the parameters of %overlay over theirs: a key that it sets to a value has that value on its line, a key that it sets to undef loses its line, and a key that the lines lack gets a line after their last parameter, or first when they have none. The other lines stay as they were.

differences

($have, $want). How the profile $have differs from $want, both as "profile_of" returns them, as phrases for a person. Empty when Perl::Critic reads both the same.

full_name

($name, \%policies). The name in %policies that ends with ::$name, when $name is not a key there and exactly one name ends so. $name otherwise.

overlay

(\%from, \%to). The overlay that turns the parameters %from into %to: each key of %to whose value differs, and undef for each key that only %from has.

IN A FLAVOR

checks:
  CriticProfile:
    file: .perlcriticrc
    template: templates/perlcriticrc

IN .conformance.yml

checks:
  CriticProfile:
    overrides:
      logicLAB::RequireSheBang:
        formats: '#!/usr/bin/env perl'
      Subroutines::ProhibitExcessComplexity:
        max_mccabe: 30
      ValuesAndExpressions::ProhibitMagicNumbers: off
      Some::Policy::OfItsOwn: {}
    settings:
      severity: 3

CONFIGURATION

file

Required. The path of the profile.

template

Required. The template of the profile.

overrides

What the repository sets otherwise than the template, by policy, as "DESCRIPTION" says. Default none.

settings

The global settings that the repository sets otherwise. Default none.

replace
retired
outdated

Deprecated, and ignored. The profile is always the template with the overrides, so it is always replaced, and a policy that the template drops goes without a list. They are accepted so that a flavor that names them still loads.

SEE ALSO

Please see those modules/websites for more information related to this module.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/Troglodyne-Internet-Widgets/Dist-Conformance/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHORS

Current Maintainers:

  • George S. Baugh <george@troglodyne.net>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Troglodyne LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.