Dist/Zilla/Plugin/DROLSKY/PerlLinterConfigFiles.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 50 CC 1 SCAR 6.9
CC
1
Cov
0%
before_build
2.0
_perltidyrc
2.0
_perlcriticrc
2.0
CRAP 2.0
1 package Dist::Zilla::Plugin::DROLSKY::PerlLinterConfigFiles;
2  
3 use v5.10;
4  
5 use strict;
6 use warnings;
7 use autodie;
8 use namespace::autoclean;
9  
10 our $VERSION = '1.25';
11  
12 use Path::Tiny qw( path );
13 use Path::Tiny::Rule;
14  
15 use Moose;
16  
17 with qw(
18 Dist::Zilla::Plugin::DROLSKY::Role::MaybeFileWriter
19 Dist::Zilla::Role::BeforeBuild
20 );
21  
22 sub before_build {
23 my $self = shift;
24  
25 $self->_maybe_write_file( 'perltidyrc', $self->_perltidyrc );
26 $self->_maybe_write_file( 'perlcriticrc', $self->_perlcriticrc );
27  
28 return;
29 }
30  
31 my $perltidyrc = <<'EOF';
32 -l=78
33 -i=4
34 -ci=4
35 -se
36 -b
37 -bar
38 -boc
39 -vt=0
40 -vtc=0
41 -cti=0
42 -pt=1
43 -bt=1
44 -sbt=1
45 -bbt=1
46 -nolq
47 -npro
48 -nsfs
49 --blank-lines-before-packages=0
50 --opening-hash-brace-right
51 --no-outdent-long-comments
52 --iterations=2
53 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="
54 EOF
55  
56 sub _perltidyrc {$perltidyrc}
57  
58 my $perlcriticrc = <<'EOF';
59 severity = 3
60 verbose = 11
61 theme = (core && (pbp || bugs || maintenance || cosmetic || complexity || security || tests)) || moose
62 program-extensions = pl psgi t
63  
64 exclude = Subroutines::ProhibitCallsToUndeclaredSubs
65  
66 [BuiltinFunctions::ProhibitStringySplit]
67 severity = 3
68  
69 [CodeLayout::RequireTrailingCommas]
70 severity = 3
71  
72 [ControlStructures::ProhibitCStyleForLoops]
73 severity = 3
74  
75 [InputOutput::RequireCheckedSyscalls]
76 functions = :builtins
77 exclude_functions = sleep
78 severity = 3
79  
80 [RegularExpressions::ProhibitComplexRegexes]
81 max_characters = 200
82  
83 [RegularExpressions::ProhibitUnusualDelimiters]
84 severity = 3
85  
86 [Subroutines::ProhibitUnusedPrivateSubroutines]
87 private_name_regex = _(?!build)\w+
88  
89 [TestingAndDebugging::ProhibitNoWarnings]
90 allow = redefine
91  
92 [ValuesAndExpressions::ProhibitEmptyQuotes]
93 severity = 3
94  
95 [ValuesAndExpressions::ProhibitInterpolationOfLiterals]
96 severity = 3
97  
98 [ValuesAndExpressions::RequireUpperCaseHeredocTerminator]
99 severity = 3
100  
101 [Variables::ProhibitPackageVars]
102 add_packages = Carp Test::Builder
103  
104 [-Subroutines::RequireFinalReturn]
105  
106 # This incorrectly thinks signatures are prototypes.
107 [-Subroutines::ProhibitSubroutinePrototypes]
108  
109 [-ErrorHandling::RequireCarping]
110  
111 # No need for /xsm everywhere
112 [-RegularExpressions::RequireDotMatchAnything]
113 [-RegularExpressions::RequireExtendedFormatting]
114 [-RegularExpressions::RequireLineBoundaryMatching]
115  
116 # http://stackoverflow.com/questions/2275317/why-does-perlcritic-dislike-using-shift-to-populate-subroutine-variables
117 [-Subroutines::RequireArgUnpacking]
118  
119 # "use v5.14" is more readable than "use 5.014"
120 [-ValuesAndExpressions::ProhibitVersionStrings]
121  
122 # Explicitly returning undef is a _good_ thing in many cases, since it
123 # prevents very common errors when using a sub in list context to construct a
124 # hash and ending up with a missing value or key.
125 [-Subroutines::ProhibitExplicitReturnUndef]
126  
127 # Sometimes I want to write "return unless $x > 4"
128 [-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions]
129 EOF
130  
131 sub _perlcriticrc {$perlcriticrc}
132  
133 __PACKAGE__->meta->make_immutable;
134  
135 1;
136  
137 # ABSTRACT: Creates default perltidyrc and perlcriticrc files if they don't yet exist
138  
139 __END__