-
-
15 Apr 2022 15:23:52 UTC
- Distribution: Code-TidyAll
- Module version: 0.82
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (22)
- Testers (151 / 46 / 0)
- Kwalitee
Bus factor: 1- 78.35% Coverage
- License: perl_5
- Perl: v5.8.8
- Activity
24 month- Tools
- Download (685.72KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 22 contributors-
Jonathan Swartz
-
Adam Herzog
-
Andreas Vögele
-
Andy Jack
-
Bernhard Schmalhofer
-
Finn Smith
-
George Hartzell
-
Graham Knop
-
Gregory Oschwald
-
Joe Crotty
-
Kenneth Ölwing
-
Mark Fowler
-
Mark Grimes
-
Martin Gruner
-
Mohammad S Anwar
-
Nick Tonkin
-
Olaf Alders
-
Pedro Melo
-
Ricardo Signes
-
Sergey Romanov
-
Shlomi Fish
-
timgimyee
- Dependencies
- Capture::Tiny
- Config::INI::Reader
- Cwd
- Data::Dumper
- Date::Format
- Digest::SHA
- Exporter
- File::Basename
- File::Find
- File::Spec
- File::Which
- File::pushd
- Getopt::Long
- IPC::Run3
- IPC::System::Simple
- List::Compare
- List::SomeUtils
- Log::Any
- Module::Runtime
- Moo
- Moo::Role
- Path::Tiny
- Scalar::Util
- Scope::Guard
- Specio
- Specio::Declare
- Specio::Library::Builtins
- Specio::Library::Numeric
- Specio::Library::Path::Tiny
- Specio::Library::String
- Test::Builder
- Text::Diff
- Text::Diff::Table
- Text::ParseWords
- Time::Duration::Parse
- Try::Tiny
- base
- constant
- strict
- warnings
- Reverse dependencies
- CPAN Testers List
- Dependency graph
Take me over?
The maintainer of this distribution is looking for someone to take over! If you're interested then please contact them via email.- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- NAMING
- CONSTRUCTOR AND ATTRIBUTES
- METHODS
- SUPPORT
- SOURCE
- AUTHORS
- COPYRIGHT AND LICENSE
NAME
Code::TidyAll::Plugin - Create plugins for tidying or validating code
VERSION
version 0.82
SYNOPSIS
package Code::TidyAll::Plugin::SomeTidier; use Moo; extends 'Code::TidyAll::Plugin'; sub transform_source { my ( $self, $source ) = @_; ... return $source; } package Code::TidyAll::Plugin::SomeValidator; use Moo; extends 'Code::TidyAll::Plugin'; sub validate_file { my ( $self, $file ) = @_; die 'not valid' if ...; }
DESCRIPTION
To use a tidier or validator with
tidyall
it must have a corresponding plugin class that inherits from this class. This document describes how to implement a new plugin.The easiest way to start is to look at existing plugins, such as Code::TidyAll::Plugin::PerlTidy and Code::TidyAll::Plugin::PerlCritic.
NAMING
If you are going to publicly release your plugin, call it
Code::TidyAll::Plugin::something
so that users can find it easily and refer to it by its short name in configuration.If it's an internal plugin, you can call it whatever you like and refer to it with a plus sign prefix in the config file, e.g.
[+My::Tidier::Class] select = **/*.{pl,pm,t}
CONSTRUCTOR AND ATTRIBUTES
Your plugin constructor will be called with the configuration key/value pairs as parameters. e.g. given
[PerlCritic] select = lib/**/*.pm ignore = lib/UtterHack.pm argv = -severity 3
then Code::TidyAll::Plugin::PerlCritic would be constructed with parameters
Code::TidyAll::Plugin::PerlCritic->new( select => 'lib/**/*.pm', ignore => 'lib/UtterHack.pm', argv => '-severity 3', );
The following attributes are part of this base class. Your subclass can declare others, of course.
argv
A standard attribute for passing command line arguments.
diff_on_tidy_error
This only applies to plugins which transform source. If this is true, then when the plugin is run in check mode it will include a diff in the return value from
process_source_or_file
when the source is not tidy.is_validator
An attribute that indicates if this is a validator or not; By default this returns true if either
validate_source
orvalidate_file
methods have been implemented.name
Name of the plugin to be used in error messages etc.
tidyall
A weak reference back to the Code::TidyAll object.
weight
A number indicating the relative weight of the plugin, used to calculate the order the plugins will execute in. The lower the number the sooner the plugin will be executed.
By default the weight will be
50
for non validators (anything whereis_validator
returns false) and60
for validators (anything whereis_validator
returns true.)The order of plugin execution is determined first by the value of the
weight
attribute, and then (if multiple plugins have the same weight>) by sorting by the name of module.METHODS
Your plugin may define one or more of these methods. They are all no-ops by default.
$plugin->preprocess_source($source)
Receives source code as a string; returns the processed string, or dies with error. This runs on all plugins before any of the other methods.
$plugin->transform_source($source)
Receives source code as a string; returns the transformed string, or dies with error. This is repeated multiple times if --iterations was passed or specified in the configuration file.
$plugin->transform_file($file)
Receives filename; transforms the file in place, or dies with error. Note that the file will be a temporary copy of the user's file with the same basename; your changes will only propagate back if there was no error reported from any plugin. This is repeated multiple times if --iterations was passed or specified in the configuration file.
$plugin->validate_source($source)
Receives source code as a string; dies with error if invalid. Return value will be ignored.
$plugin->validate_file($file)
Receives filename; validates file and dies with error if invalid. Should not modify file! Return value will be ignored.
$plugin->postprocess_source($source)
Receives source code as a string; returns the processed string, or dies with error. This runs on all plugins after any of the other methods.
SUPPORT
Bugs may be submitted at https://github.com/houseabsolute/perl-code-tidyall/issues.
SOURCE
The source code repository for Code-TidyAll can be found at https://github.com/houseabsolute/perl-code-tidyall.
AUTHORS
Jonathan Swartz <swartz@pobox.com>
Dave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 - 2022 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
The full text of the license can be found in the LICENSE file included with this distribution.
Module Install Instructions
To install Code::TidyAll, copy and paste the appropriate command in to your terminal.
cpanm Code::TidyAll
perl -MCPAN -e shell install Code::TidyAll
For more information on module installation, please visit the detailed CPAN module installation guide.