Debian Codegraph @

t/.perlcriticrc

raw
1 #! /usr/bin/perlcritic
2 #?
3 #? NAME
4 #? .perlcriticrc - configuration for Perl::Critic for O-Saft
5 #?
6 #? SYNOPSIS
7 #? perlcritic <filenames> ...
8 #?
9 #? DESCRIPTION
10 #? This file contains the configuration for Perl::Critic, perlcritic.
11 #? The settings are explained, why they are ENABLED or DISABLED.
12 #?
13 #? ###################################################################
14 #? FIXME: this file is a first attempt, not yet completed.
15 #? ###################################################################
16 #?
17 #? EXAMPLES
18 #? # the usual way
19 #? perlcritic <filenames>
20 #?
21 #? # print policy for each message
22 #? perlcritic <filenames> --verbose 8
23 #?
24 #? # print full description for each message
25 #? perlcritic <filenames> --verbose 10
26 #?
27 #? # check for a single policy (Subroutines::RequireFinalReturn)
28 #? perlcritic <filenames> --single-policy Subroutines::RequireFinalReturn
29 #? perlcritic <filenames> --only --include Subroutines::RequireFinalReturn
30 #?
31 #? # just get a statistic for severity 4 and 5
32 #? perlcritic <filenames> --severity 4 --statistics-only
33 #?
34 #? # get a a quick overview for violations of severity 4 and 5
35 #? perlcritic *.pl *.pm --severity 4 --count
36 #?
37 #? LIMITATIONS
38 #? Do not use perlcritic with an directory as parameter in the development
39 #? directory as there are too much matching files (i.e. SCCS/*) which may
40 #? cause problems. Use list of files instead: *.pl *.pm Net/*.pm
41 #?
42 #? SEE ALSO
43 #? contrib/critic.sh
44 #?
45 #? VERSION
46 #? @(#) .perlcriticrc 1.15 22/11/06 12:22:40
47 #
48 #? AUTHOR
49 #? 06-apr-16 Achim Hoffmann
50 #?
51 # -----------------------------------------------------------------------------
52
53 # global options
54 severity = 5
55 # will change to 4 o 3 later
56
57 verbose = 8
58 # always want to see the policy name
59
60 #program-extensions '.pl .pm'
61 # does not work as described by Perl::Critic :-/
62
63 # theme = o-saft
64
65 [ControlStructures::ProhibitPostfixControls]
66 allow = if unless
67 #allow = foreach
68 # as the severity is already 2, its okay to report foreach violations
69
70
71 # Message
72 # Postfix control "if" used at line ...
73
74 # CHECK adapted
75 # Postfix controls are used often to have the relevant code far left!
76
77
78 [InputOutput::RequireCheckedClose]
79 severity = 1
80
81 # Message
82 # Return value of "close" ignored at line ...
83
84 # CHECK DISABLED
85 # For our purpose it's nice if the files is closed, but not necessary.
86 # hence severity reduced to 1
87
88
89 #[InputOutput::RequireCheckedOpen]
90 #[InputOutput::RequireCheckedSyscalls]
91
92
93 [InputOutput::RequireBriefOpen]
94 lines = 15
95 severity = 2
96
97 # Message
98 # Close filehandles as soon as possible after opening them at line ...
99
100 # CHECK adapted
101 # Because we have more code until close, sometimes.
102 # TODO: lines= seems not to work as descibed, produces false positives
103 # therefore serverity is reduced
104
105
106 [InputOutput::RequireEncodingWithUTF8Layer]
107
108 # Message
109 # I/O layer ":utf8" used at line
110
111 # CHECK ENABLED
112 # CHECK adapted
113 # However ...
114 # The description of Perl::Critic is mainly valid according input. But
115 # Perl::Critic also complains for output and states, cite:
116 # "For consistency's sake, this policy checks files opened for output
117 # as well as input, For complete coverage it also checks `binmode()'
118 # calls, where the direction the operation can not be determined."
119 # This is wrong, as binmode() usually uses the common bare word file
120 # handles like STDOUT, STDERR, STDIN undoublty.
121 # Our code uses binmode() only for output, hence this check is a false
122 # positive. As this check should be active for future changes, we mark
123 # all our binmode() calls with a proper ## no critic .
124
125
126 [InputOutput::ProhibitBacktickOperators]
127 only_in_void_context = 1
128
129 # Message
130 # Backtick operator used at line ...
131
132 # CHECK ENABLED
133 # Literal backticks are not used, but the qx() operator. Backticks are
134 # used in void context, hence the restriction to only_in_void_context.
135
136
137 [InputOutput::ProhibitBarewordFileHandles]
138 [InputOutput::ProhibitTwoArgOpen]
139
140 # Messages:
141 # Bareword file handle opened at line ...
142 # Two-argument "open" used at line ...
143
144 # A bareword is a series of characters (like the FH) without quotes
145 # around them, or without a sigil in-front of them. They can be used in
146 # some places, but in file-handles they are not recommended any more.
147
148 # Recommendation
149 # Always use lexical variables and always use 3-parameter for open.
150
151
152 [-InputOutput::ProhibitExplicitStdin]
153
154 # Message
155 # Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>" at line ...
156
157 # CHECK DISABLED
158 # The reason why "*ARGV behaves like *STDIN" is described as
159 # "is almost always what you want" sounds strange.
160 # In our usage this is never the case, because we also may get data on
161 # STDIN and have command line arguments.
162
163
164 #[InputOutput::ProhibitInteractiveTest]
165 #[InputOutput::ProhibitJoinedReadline]
166 #[InputOutput::ProhibitOneArgSelect]
167
168
169 [InputOutput::ProhibitOneArgSelect]
170
171 # Message
172 # One-argument "select" used at line ...
173
174 # CHECK ENABLED
175 # selectively disabled in souce with ## no critic ..
176
177
178 #[InputOutput::ProhibitReadlineInForLoop]
179 #[InputOutput::RequireBracedFileHandleWithPrint]
180
181
182 [References::ProhibitDoubleSigils]
183
184 # Message
185 # Double-sigil dereference at line ...
186
187 # CHECK ENABLED
188
189
190 [Modules::ProhibitAutomaticExportation]
191
192 # Message
193 # Symbols are exported by default at line ...
194
195 # CHECK ENABLED
196
197
198 [Modules::RequireBarewordIncludes]
199 severity = 3
200
201 # Message
202 # "require" statement with library name as string at line ...
203
204 # CHECK ENABLED
205 # CHECK adapted
206 # FIXME: O-Saft uses require like: require "o-saft-man.pm";
207 # which is necessary because the filename contains a - (dash), without
208 # quotes Perl complains with:
209 # Bareword "saft" not allowed while "strict subs" in use
210 #
211 # To get rid of this critic, the filename needs to be changed. That's
212 # why we leave this violation but reduce the severity to 3.
213
214
215 [RegularExpressions::ProhibitCaptureWithoutTest]
216 [RegularExpressions::ProhibitUnusedCapture]
217
218 # Messages
219 # Capture variable used outside conditional at line ...
220 # Only use a capturing group if you plan to use the captured value at line ...
221
222 # CHECK ENABLED
223 # NOTE: Perl::Critic has a lot of false negatives!
224
225
226 [Modules::ProhibitExcessMainComplexity]
227
228 # Message
229 # Main code has high complexity score (NN) at line ...
230
231 # CHECK ENABLED
232
233
234 [Subroutines::ProhibitExcessComplexity]
235
236 # Message
237 # Subroutine "XXXX" with high complexity score (29) at line ...
238
239 # CHECK ENABLED
240 # TODO: CHECK adapted
241 # Net::SSLinfo.pm max_mccabe = 45
242
243
244 [-Subroutines::ProhibitUnusedPrivateSubroutines]
245
246 # Message
247 # Private subroutine/method 'XXXX' declared but not used at line ...
248
249 # CHECK DISABLED
250
251
252 [-RegularExpressions::RequireDotMatchAnything]
253
254 # Message
255 # Regular expression without "/s" flag at line ...
256
257 # CHECK DISABLED
258 # cause we know about meta character . and /s modifier in RegEx ;-)
259
260
261 [-RegularExpressions::RequireLineBoundaryMatching]
262
263 # Message
264 # Regular expression without "/m" flag at line ...
265
266 # CHECK DISABLED
267 # cause we use /m as needed
268
269
270 [-RegularExpressions::RequireExtendedFormatting]
271
272 # Message
273 # Regular expression without "/x" flag at line ...
274
275 # CHECK DISABLED
276 # because we use /x as needed for human readability
277
278
279 [Subroutines::ProhibitBuiltinHomonyms]
280
281 # Message
282 # Subroutine name is a homonym for builtin function XXXX at line ...
283
284 # CHECK ENABLED
285
286
287 [-Subroutines::ProhibitManyArgs]
288
289 # Message
290 # Too many arguments at line ...
291
292 # CHECK DISABLED
293 # because there are functions with more than 5 paramters
294 # NOTE: this policy has no "allow" option but we need more than 5
295 # arguments, sometimes;hence disabled
296
297
298 [-Subroutines::ProhibitSubroutinePrototypes]
299
300 # Message
301 # Subroutine prototypes used at line ...
302
303 # CHECK DISABLED
304 # Contrary to Perl::Critic we consider prototypes as useful, even if
305 # the compile-time checks of Perl are not perfect, Perl may give some
306 # hints.
307
308
309 [Subroutines::RequireArgUnpacking]
310
311 # Message
312 # Always unpack @_ first at line ...
313
314 # CHECK ENABLED
315
316
317 [Subroutines::RequireFinalReturn]
318
319 # Message
320 #
321
322 # CHECK ENABLED
323
324
325 [-CodeLayout::RequireTidyCode]
326
327 # Message
328 # Code is not tidy at line 1, column 1.
329
330 # CHECK DISABLED
331 # TODO: tidy not yet used
332
333
334 [-CodeLayout::ProhibitParensWithBuiltins]
335
336 # Message
337 # Builtin function called with parentheses at line ...
338
339 # CHECK DISABLED
340 # Contrary to BPB we think that all functions should use parentheses.
341 # Continous use of parentheses makes third-party parsers happy.
342 # However: we miss parentheses, mainly for print builtin function.
343
344
345 [-CodeLayout::RequireTidyCode]
346
347 # Message
348 # Code is not tidy at line 1, column 1.
349
350 # CHECK DISABLED
351 # TODO: tidy not yet used
352
353
354 [CodeLayout::ProhibitHardTabs]
355
356 # CHECK ENABLED
357 # there are leading tabs only, usually
358
359
360 [CodeLayout::ProhibitTrailingWhitespace]
361
362 # Message
363 # Found "\N{SPACE}" at the end of the line ...
364
365 # CHECK ENABLED
366 # We hate unecessary characters too ;-)
367
368
369 [CodeLayout::RequireConsistentNewlines]
370
371 # CHECK ENABLED
372
373
374 [-Variables::ProhibitLocalVars]
375
376 # Message
377 # Variable declared as "local" at line ...
378
379 # CHECK DISABLED
380 # NOTE: Following this critism violates Variables::ProhibitReusedNames
381 # we prefer to check for reused variables
382
383
384 [Variables::ProhibitPackageVars]
385 add_packages = Net::SSLinfo Net::SSLhello Net::SSLeay
386
387 # Message
388 # Package variable declared or used at line ...
389
390 # CHECK adapted
391 # Add our private modules, this leaves unwanted global variables to be
392 # reported only.
393 # Net::SSLeay is configured using its private variables.
394
395
396 [Variables::ProhibitPunctuationVars]
397 allow = $@ $! $? $0 $. $^O $\
398
399 # we make regular use of these variables as we know them;-)
400
401
402 [Variables::RequireLocalizedPunctuationVars]
403 allow = @ENV
404
405 # Message
406 # Magic variable "$ENV" should be assigned as "local"
407
408 # CHECK adapted
409 # @ENV must be changed globally (at least in o-saft.pl)
410 # TODO: need to verify if @INC should be allowed too
411 # Perl::Critic seems to be buggy as it does not honor the allow option
412 # hence an annotation is used in o-saft.pl
413
414
415 [Variables::ProhibitReusedNames]
416 allow = $host $port $legacy $arg
417
418 # Message
419 # Reused variable name in lexical scope: ...
420
421 # CHECK adapted
422 # These variables are often used in subs, but also in main, hence
423 # we allow them for reuse.
424
425
426 [Variables::RequireInitializationForLocalVars]
427
428 # Message
429 # "local" variable not initialized at line ...
430
431 # CHECK ENABLED
432
433
434 [RegularExpressions::ProhibitCaptureWithoutTest]
435
436 # Message
437 # Capture variable used outside conditional at line ...
438
439 # CHECK ENABLED
440
441 # Workaround: disable selectively where appropriate with:
442
443
444 #[RegularExpressions::ProhibitComplexRegexes]
445
446 # Message
447 # Split long regexps into smaller qr// chunks at line ...
448
449 # FIXME: to be discussed
450 # Workaround: disable selectively where appropriate with:
451
452
453 #[ValuesAndExpressions::ProhibitConstantPragma]
454
455 # Message
456 # Pragma "constant" used at line ...
457
458 # CHECK ENABLED
459
460
461 [-ValuesAndExpressions::ProhibitEmptyQuotes]
462
463 # Message
464 # Quotes used with a string containing no non-whitespace characters at line ...
465
466 # CHECK DISABLED
467 # cause we consider following correct and useful: my $var = '';
468 # the recomended use of q{} looks too complex: my $var = q{};
469
470
471 [-ValuesAndExpressions::ProhibitNoisyQuotes]
472
473 # Message
474 # Quotes used with a noisy string at line ... (Severity: 2)
475
476 # CHECK DISABLED
477 # other people, other opinions: "," is better readable than qw(,)
478
479
480 [ValuesAndExpressions::ProhibitEscapedCharacters]
481
482 # Message
483 # Numeric escapes in interpolated string at line ...
484
485 # CHECK ENABLED
486
487
488 [-ValuesAndExpressions::ProhibitImplicitNewlines]
489
490 # Message
491 # Literal line breaks in a string at line ...
492
493 # CHECK DISABLED
494 # yes, there are a lot of constructs using nwelines in texts, that's ok
495
496
497 [ValuesAndExpressions::ProhibitMagicNumbers]
498 allowed_values = 0..99
499 allowed_values = 443
500
501 # allowed_types =
502 # constant_creator_subroutines =
503 # FIXME: to be discussed
504 # Workaround: disable selectively where appropriate with:
505 ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
506
507 # CHECK adapted
508 # we use some integers
509
510
511 [ValuesAndExpressions::ProhibitMismatchedOperators]
512
513 # Message
514 # Mismatched operator at line ...
515
516 # CHECK ENABLED
517
518
519 [ValuesAndExpressions::RequireNumberSeparators]
520 min_value = 100_000
521 # severity is 2
522
523 # Message
524 #
525
526 # CHECK adapted
527 # we use some integers
528
529
530 [ValuesAndExpressions::RequireQuotedHeredocTerminator]
531
532 # Message
533 # Heredoc terminator must be quoted at line ...
534
535 # CHECK ENABLED
536 # Workaround: disable selectively where appropriate
537
538
539 [-ValuesAndExpressions::RequireUpperCaseHeredocTerminator]
540
541 # Message
542 # Heredoc terminator not alphanumeric and upper-case at line ...
543
544 # CHECK DISABLED
545 # other people, other opinions
546
547
548 [RegularExpressions::ProhibitUnusedCapture]
549
550 # Message
551 # Only use a capturing group if you plan to use the captured value at line ...
552
553 # CHECK ENABLED
554
555
556 #[RegularExpressions::ProhibitFixedStringMatches]
557
558 # Message
559 # Use 'eq' or hash instead of fixed-pattern regexps at line ...
560
561 # FIXME: to be discussed
562 # we often use something like: if (m/^$/)
563 # which is hard to be expressed as a hash
564
565
566 #[TestingAndDebugging::ProhibitNoStrict]
567
568 # Message:
569 # Stricture disabled at line ...
570
571 # FIXME: to be discussed
572 # i.g. we want this warning, but strict is also disabled in the code
573 # for good reason, probably use
574 ## no critic qw(TestingAndDebugging::ProhibitNoStrict)
575
576
577 [TestingAndDebugging::ProhibitNoWarnings]
578 severity = 2
579
580 # Message:
581 # Warnings disabled at line
582
583 # CHECK adapted
584 # FIXME: to be discussed; for now severity reduced from 4 to 2
585 # i.g. we want this warning, but some warnings are also disabled in
586 # the code for good reason, probably use
587 ## no critic qw(TestingAndDebugging::ProhibitNoWarnings)
588
589 [TestingAndDebugging::RequireUseStrict]
590
591 # Message:
592 # Code before strictures are enabled at line ...
593
594 # Note:
595 # This check produces false positives in module files, if there is no
596 # "use strict" , but this is not necessary as long as the module is
597 # executed itself.
598 # Anyway, "use strict" and "use warnings" is added to modules too.
599
600
601 [-BuiltinFunctions::ProhibitBooleanGrep]
602
603 # Message
604 # "grep" used in boolean context at line ...
605 # "grep" used in void context at line ...
606
607 # CHECK DISABLED
608 # Perl::Critic is too noicy and may have false positives, see its own
609 # description:
610 # perlcritic --doc BuiltinFunctions::ProhibitBooleanGrep
611
612
613 #[BuiltinFunctions::ProhibitStringyEval]
614
615 # Message:
616 # Expression form of "eval" at line 3117
617
618 # FIXME: to be discussed
619 # This occour for eval("require ..."), so probably use
620 ## no critic qw(BuiltinFunctions::ProhibitStringyEval)
621
622
623 [-BuiltinFunctions::ProhibitSleepViaSelect]
624
625 # Message:
626 # "select" used to emulate "sleep" at line ...
627
628 # BuiltinFunctions::ProhibitSleepViaSelect (Severity: 5)
629 # Conway discourages the use of `select()' for performing non-integer
630 # sleeps. Although documented in perlfunc, it's something that generally
631 # requires the reader to read `perldoc -f select' to figure out what it
632 # should be doing. Instead, Conway recommends that you use the
633 # `Time::HiRes' module when you want to sleep.
634 #
635 # select undef, undef, undef, 0.25; # not ok
636 #
637 # use Time::HiRes;
638 # sleep( 0.25 ); # ok
639
640 # CHECK DISABLED
641 # We do not wish to use too much external modules. select is used
642 # several times in SSLhello.pm
643 # FIXME: write a osaft_sleep() which hides the select, this way the
644 # violation is printed only once. Then we can enable it again.
645
646
647 [-BuiltinFunctions::RequireBlockGrep]
648
649 # Message:
650 # The expression forms of `grep' and `map' are awkward and hard to read.
651
652 # CHECK DISABLED
653 # other people, other opinions
654
655
656
657 [BuiltinFunctions::ProhibitStringySplit]
658
659 # Message:
660 # String delimiter used with "split" at line ...
661
662 # CHECK ENABLED
663
664
665 [Miscellanea::ProhibitUnrestrictedNoCritic]
666
667 # does not make sense to disable it, can even not be disabled :-/
668
669
670 [-Documentation::RequirePodSections]
671 lib_sections = NAME | SYNOPSIS | DESCRIPTION | AUTHOR
672
673 # Message:
674 # Missing "OPTIONS" section in POD at line ...
675
676 # CHECK DISABLED
677 # cause we consider following correct and useful: my $last = '';
678 # Perl::Critic is uses a strange list of required sections in POD.
679 # Also there is no possibility to disable Perl::Critic's required
680 # sections, hence generally disabled.
681
682
683 [-NamingConventions::ProhibitAmbiguousNames]
684
685 # Message:
686 # Ambiguously named variable "last" at line ...
687
688 # CHECK DISABLED
689 # cause we consider following correct and useful: my $last = '';
690 # Perl::Critic is too pedantic here as it is no problem at all with perl.
691