Преглед на файлове

Enable CompileTime, except for tests

CompileTime reports work in a BEGIN block that has effects beyond the
program, such as I/O and assignments to %ENV, which go wrong in a binary
that B::C compiles.  Nothing in bin/ or lib/ does that.  Every report is
in a test, which writes its fixtures and sets HOME in a BEGIN block
before the SUT loads, because the SUT reads them as it loads.  No
compiled binary is made of a test, so the hook leaves this policy out
for t/, as it does RequireLocalizedPunctuationVars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
troglodyne-bot преди 6 дни
родител
ревизия
8351bc327e
променени са 2 файла, в които са добавени 7 реда и са изтрити 6 реда
  1. 1 1
      .perlcriticrc
  2. 6 5
      git-hooks/pre-commit

+ 1 - 1
.perlcriticrc

@@ -297,4 +297,4 @@ allow_unused_subroutine_arguments = 1
 [Variables::RequireLocalizedPunctuationVars]
 [Variables::RequireNegativeIndices]
 # Extensions to perl -c
-#[CompileTime]
+[CompileTime]

+ 6 - 5
git-hooks/pre-commit

@@ -130,16 +130,17 @@ then
         perlcritic --profile .perlcriticrc $lib_files || critic_failed=1
     fi
 
-    # The same profile for t/, less two policies.  A test is not a module: nobody
-    # runs perldoc on it, so requiring POD of it asks for a page no reader will
-    # ever open.  And a test sets %ENV and %INC for the whole file, in a BEGIN
-    # block before the SUT loads, where a local would end with the block.
+    # The same profile for t/, less three policies.  A test is not a module:
+    # nobody runs perldoc on it, so requiring POD of it asks for a page no
+    # reader will ever open.  And a test sets %ENV and %INC, and writes its
+    # fixtures, in a BEGIN block before the SUT loads, for the whole file: a
+    # local would end with the block, and no compiled binary is made of a test.
     # Everything else in the profile still judges it, which is more than a
     # release does -- all_critic_ok() reads lib/ and not t/, so this hook is the
     # only thing that looks at a test file at all.
     if [ -n "$test_files" ]
     then
-        perlcritic --profile .perlcriticrc --exclude Documentation::RequirePod --exclude Variables::RequireLocalizedPunctuationVars $test_files || critic_failed=1
+        perlcritic --profile .perlcriticrc --exclude Documentation::RequirePod --exclude Variables::RequireLocalizedPunctuationVars --exclude CompileTime $test_files || critic_failed=1
     fi
 
     if [ -n "$critic_failed" ]