Просмотр исходного кода

Enable four more policies, naming the parts that stay lowercase

ProhibitRegexForSimpleSubstring, ProhibitMisplacedMethods and
ProhibitConditionalUseStatements were left off when the profile was
adopted, and the earlier changes to the tree removed everything they
reported.  They report nothing now, so turn them on.

NamingConventions::Capitalization reported ten names.  One is a lexical
in username2classname whose mixed case meant nothing, and it is now
$classname.  The other nine are packages: each renderer is named for the
content type that it renders, and the two scripts' packages are named for
the scripts.  The policy tests each part of a package name on its own, so
package_exemptions lists those parts.  A lowercase part that is not on
the list still fails: package Trog::bogus does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
troglodyne-bot 6 дней назад
Родитель
Сommit
fd08e8ae95
2 измененных файлов с 12 добавлено и 8 удалено
  1. 8 4
      .perlcriticrc
  2. 4 4
      lib/Trog/Auth.pm

+ 8 - 4
.perlcriticrc

@@ -78,7 +78,7 @@ formats = #!/usr/bin/env perl
 # Performance
 [logicLAB::ProhibitShellDispatch]
 [ProhibitPipeOpen]
-#[Performance::ProhibitRegexForSimpleSubstring]
+[Performance::ProhibitRegexForSimpleSubstring]
 [RegularExpressions::ProhibitRegexToStripAffix]
 [RegularExpressions::ProhibitRegexToChomp]
 [BuiltinFunctions::ProhibitChainingSameListSub]
@@ -128,7 +128,7 @@ allow = re Exporter
 # Perl::Critic::Distribution, as ProhibitUnusedDefinitions does, so the two
 # share one parse.  A library whose subclasses live in other distributions
 # names in allow_subs each hook that only one of its own subclasses uses.
-#[ProhibitMisplacedMethods]
+[ProhibitMisplacedMethods]
 [ProhibitPrintSTDERR]
 [InputOutput::ProhibitRepeatedPrints]
 # Perl::Critic's own policies.  only = 1 loads nothing that is not named, so
@@ -214,11 +214,15 @@ stop_words_file = .pod_stopwords
 [Miscellanea::ProhibitUnrestrictedNoCritic]
 #[Miscellanea::ProhibitUselessNoCritic]
 [Modules::ProhibitAutomaticExportation]
-#[Modules::ProhibitConditionalUseStatements]
+[Modules::ProhibitConditionalUseStatements]
 [Modules::RequireBarewordIncludes]
 [Modules::RequireFilenameMatchesPackage]
 [Modules::RequireNoMatchVarsWithUseEnglish]
-#[NamingConventions::Capitalization]
+[NamingConventions::Capitalization]
+# tCMS: each renderer is named for the content type it renders, and each
+# script's package for the script.  The policy tests each part of a package
+# name on its own, so these are the parts.
+package_exemptions = main tcms login useradd blob css email html javascript json text
 [RegularExpressions::ProhibitCaptureWithoutTest]
 #[RegularExpressions::ProhibitComplexRegexes]
 [RegularExpressions::ProhibitEnumeratedClasses]

+ 4 - 4
lib/Trog/Auth.pm

@@ -142,10 +142,10 @@ sub username2classname ($name) {
 
     # Users are always self-authored, you see
 
-    my $user_obj = List::Util::first { ( $_->{user} || '' ) eq $name } @userposts;
-    my $NNname   = $user_obj->{id} || '';
-    $NNname =~ tr/-/_/;
-    return "a_$NNname";
+    my $user_obj  = List::Util::first { ( $_->{user} || '' ) eq $name } @userposts;
+    my $classname = $user_obj->{id} || '';
+    $classname =~ tr/-/_/;
+    return "a_$classname";
 }
 
 =head2 acls4user(STRING username) = ARRAYREF