Skip to content

Instantly share code, notes, and snippets.

@akzhan akzhan/.perlcriticrc
Last active Apr 4, 2017

Embed
What would you like to do?
YourCompany Perl Prologue
include = BuiltinFunctions::ProhibitBooleanGrep BuiltinFunctions::ProhibitStringyEval BuiltinFunctions::ProhibitStringySplit BuiltinFunctions::ProhibitUniversalCan BuiltinFunctions::ProhibitUniversalIsa ClassHierarchies::ProhibitExplicitISA CodeLayout::ProhibitHardTabs ControlStructures::ProhibitMutatingListFunctions ControlStructures::ProhibitUnreachableCode ErrorHandling::RequireCarping InputOutput::ProhibitBarewordFileHandles InputOutput::RequireCheckedClose InputOutput::RequireCheckedOpen InputOutput::RequireCheckedSyscalls InputOutput::ProhibitInteractiveTest InputOutput::ProhibitOneArgSelect InputOutput::ProhibitTwoArgOpen Miscellanea::ProhibitFormats Modules::ProhibitEvilModules Modules::RequireEndWithOne Objects::ProhibitIndirectSyntax Policy::TestingAndDebugging::RequireUseStrict Policy::TestingAndDebugging::RequireUseWarnings RegularExpressions::ProhibitCaptureWithoutTest Subroutines::ProhibitBuiltinHomonyms Subroutines::ProhibitReturnSort Subroutines::ProhibitSubroutinePrototypes Subroutines::ProhibitUnusedPrivateSubroutines Subroutines::ProtectPrivateSubs TestingAndDebugging::ProhibitNoStrict TestingAndDebugging::ProhibitProlongedStrictureOverride TestingAndDebugging::RequireUseStrict TestingAndDebugging:;ProhibitNoWarnings ValuesAndExpressions::ProhibitCommaSeparatedStatements ValuesAndExpressions::ProhibitLeadingZeros ValuesAndExpressions::ProhibitMagicNumbers ValuesAndExpressions::ProhibitMismatchedOperators ValuesAndExpressions::ProhibitMixedBooleanOperators Variables::ProhibitPerl4PackageNames Variables::ProhibitUnusedVariables Variables::ProtectPrivateVars Variables::RequireInitializationForLocalVars Variables::RequireLexicalLoopIterators Variables::RequireLocalizedPunctuationVars
[TestingAndDebugging::RequireUseStrict]
equivalent_modules = YourCompany::Perl::UTF8 YourCompany::Test::UTF8
[TestingAndDebugging::RequireUseWarnings]
equivalent_modules = YourCompany::Perl::UTF8 YourCompany::Test::UTF8
[ValuesAndExpressions::ProhibitMagicNumbers]
allowed_values = 0 1
[-Subroutines::ProhibitExplicitReturnUndef]
[-Subroutines::RequireFinalReturn]
=encoding utf-8
=head1 NAME
YourCompany::Perl::UTF8
=head1 DESCRIPTION
Common project rules.
Inspired by L<Modern::Perl> but should be extended our own way.
=head1 FEATURES
Features enabled by module usage: say, state, switch, unicode_strings, array_base.
=head1 POLICY
Sets 'c3' method resolution order.
Includes strict, warnings and utf8 pragmata.
=cut
package YourCompany::Perl::UTF8;
use 5.020_003;
use strict;
use warnings;
use mro ();
use feature ();
use utf8 ();
# enable methods on filehandles; unnecessary when 5.14 autoloads them
use IO::File ();
use IO::Handle ();
sub import {
my ($class) = @_;
strict->import;
warnings->import( FATAL => 'all' );
feature->import(':5.20');
utf8->import;
mro::set_mro( scalar caller(), 'c3' );
}
## no critic (Subroutines::ProhibitBuiltinHomonyms)
sub unimport {
utf8->unimport;
feature->unimport;
warnings->unimport;
strict->unimport;
}
## use critic
1;
package YourCompany::Test::UTF8;
use mro ();
use YourCompany::Perl::UTF8;
require Test::More;
require Test::Spec;
require Test::Exception;
my $builder = Test::More->builder;
binmode $builder->output, ":encoding(UTF-8)";
binmode $builder->failure_output, ":encoding(UTF-8)";
binmode $builder->todo_output, ":encoding(UTF-8)";
sub import {
my $class = shift;
my $callpkg = caller;
YourCompany::Perl::UTF8->import;
mro::set_mro( scalar caller(), 'c3' );
eval qq{
package $callpkg;
use parent 'Test::Spec';
# allow Test::Spec usage errors to be reported via Carp
our \@CARP_NOT = qw($callpkg);
};
die $@ if $@;
Test::Spec::ExportProxy->export_to_level( 1, $callpkg );
Test::Spec->export_to_level( 1, $callpkg );
Test::Exception->export_to_level( 1, $callpkg );
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.