Skip to content

Add cacheing to a Perl::Critic subclass

Notifications You must be signed in to change notification settings

uperl/Perl-Critic-Role-Cacheable

Repository files navigation

Perl::Critic::Role::Cacheable static linux

Add caching to a Perl::Critic subclass

SYNOPSIS

package MyCritic {
  use Role::Tiny::With;
  with 'Perl::Critic::Role::Cacheable';
}

DESCRIPTION

This Role::Tiny role modifies a subclass of Perl::Critic so that source files that are already known to have no violations will not be critiqued again. The cache uses a MD5 of the configuration and the Perl source, so if either change then the critique will be run again.

CONSTRUCTOR

new

my $critic = MyCritic->new( -cacheable-filename => $filename, %options );

The constructor will work as normal except a new option -cacheable-filename will be added which allows you to set an alternate location to store the cache in.

  • -cacheable-filename

    The name of the file to store the cache in. Defaults to ~/.perl-critic-role-cacheable.

PROPERTIES

cacheable_filename

my $filename = $critic->cacheable_filename;

The name of the file where the cache will be stored.

METHODS

cacheable_save

$critic->cacheable_save;

Save the cache.

critique

$critic->critique( $source_code );

The critique method will work as normal, except source files that have already been critiqued and had no violations will not be checked again.

CAVEATS

This role will only cache when filenames are provided to the "critique" method. If you provide Perl source as a scalar reference or as a Perl::Critic::Document, then no caching will be done.

AUTHOR

Graham Ollis [email protected]

COPYRIGHT AND LICENSE

This software is copyright (c) 2023 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

About

Add cacheing to a Perl::Critic subclass

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages