config['pre_commit_tests'] ?? false; if (!$pre_commit_tests) { return; } // Check if filename contains -temp before the extension $filename = basename($file_path); // Match files like test-temp.php, module-temp.js, etc. if (preg_match('/^(.+)-temp(\.[^.]+)?$/', $filename, $matches)) { $this->add_violation( $file_path, 0, "Temporary file '{$filename}' detected. Files ending in '-temp' should be removed before commit.", $filename, "The '-temp' suffix indicates this is a temporary file for testing or development.\n" . "These files should not be committed to the repository.\n\n" . "Options:\n" . "1. Remove the file if it's no longer needed\n" . "2. Rename the file without '-temp' if it should be kept\n" . "3. Move to a proper test directory if it's a test file", 'high' ); } } }