@@ -5,6 +5,178 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## [ 1.0.73] - 2026-01-02
9+
10+ ### Added
11+ - ** DRY Violations in HTML Reports** - HTML reports now display DRY violations section
12+ - Added dedicated "DRY Violations" section showing all detected violations
13+ - Added DRY violations count to summary stats card
14+ - Shows pattern name, duplicated string, file count, and total occurrences
15+ - Lists all locations with clickable file paths
16+ - ** Impact:** DRY violations are now visible in HTML reports (previously only in JSON/text)
17+
18+ ### Changed
19+ - ** HTML Template** - Updated ` report-template.html ` to include DRY violations section
20+ - Added ` {{DRY_VIOLATIONS_COUNT}} ` placeholder for summary stats
21+ - Added ` {{DRY_VIOLATIONS_HTML}} ` placeholder for violations content
22+ - Styled violations with medium severity (yellow border)
23+
24+ - ** HTML Generation** - Enhanced ` generate_html_report() ` function
25+ - Extracts DRY violations from JSON output
26+ - Formats violations with pattern details and location lists
27+ - Generates "No violations" message when none detected
28+
29+ ### Testing
30+ - Verified with debug-log-manager plugin (6 DRY violations detected)
31+ - HTML report displays all violations with proper formatting
32+ - Clickable file paths work correctly
33+
34+ ## [ 1.0.72] - 2026-01-02
35+
36+ ### Fixed
37+ - ** Critical: Path Quoting Bug** - Fixed unquoted ` $PATHS ` variable in grep command
38+ - ** Impact:** DRY violation detection was completely broken for paths with spaces
39+ - ** Symptom:** Grep returned 0 matches even when violations existed
40+ - ** Fix:** Added quotes around ` "$PATHS" ` in line 1333
41+ - ** Result:** ✅ DRY violation detection now works correctly
42+
43+ - ** Shell Syntax Error** - Removed ` local ` keyword from non-function context
44+ - ** Impact:** Script threw errors: "local: can only be used in a function"
45+ - ** Location:** Lines 3278, 3283, 3284 (violation counting logic)
46+ - ** Fix:** Changed to regular variable assignments
47+ - ** Result:** ✅ No more shell errors
48+
49+ ### Verified
50+ - ✅ Pattern extraction working (75-character regex patterns extracted correctly)
51+ - ✅ Grep finding matches (38 raw matches found in test plugin)
52+ - ✅ Aggregation logic working (2 violations detected correctly)
53+ - ✅ Debug logging working (` /tmp/wp-code-check-debug.log ` shows full details)
54+
55+ ### Testing
56+ Tested against real WordPress plugin:
57+ - ** Plugin:** woocommerce-all-products-for-subscriptions
58+ - ** Path:** ` /Users/noelsaw/Local Sites/1-bloomzhemp-production-sync-07-24/app/public/wp-content/plugins/woocommerce-all-products-for-subscriptions `
59+ - ** Results:**
60+ - Duplicate transient keys: ✓ No violations
61+ - Duplicate capability strings: ✓ No violations (3 matches, below threshold)
62+ - Duplicate option names: ⚠ Found 2 violations (38 matches)
63+
64+ ## [ 1.0.71] - 2026-01-01
65+
66+ ### Fixed
67+ - ** Pattern Extraction Bug** - Fixed Python JSON extraction in ` pattern-loader.sh `
68+ - Changed from inline Python command to heredoc format for better reliability
69+ - Prevents issues with special characters in file paths
70+ - Adds proper error handling and stderr capture
71+ - ** Impact:** Aggregated patterns should now load correctly
72+
73+ ### Added
74+ - ** Debug Logging** - Added comprehensive debug logging to ` process_aggregated_pattern() `
75+ - Logs to ` /tmp/wp-code-check-debug.log ` for troubleshooting
76+ - Shows pattern metadata, search pattern length, grep results
77+ - Helps diagnose pattern loading and matching issues
78+ - ** Usage:** Check ` /tmp/wp-code-check-debug.log ` after running the scanner
79+
80+ - ** Enhanced Output** - Improved DRY violation detection output
81+ - Shows pattern search string in output (for debugging)
82+ - Shows count of violations found per pattern
83+ - Better visual feedback for debugging pattern issues
84+
85+ ### Changed
86+ - ** Pattern Loader** - Rewrote Python JSON extraction logic
87+ - Uses heredoc instead of inline command
88+ - Better error handling with try/catch
89+ - Falls back to grep/sed if Python fails
90+ - More robust handling of complex regex patterns
91+
92+ ### Known Issues
93+ - Terminal output may be truncated on some systems (use ` --format json ` for full output)
94+ - Pattern extraction still needs testing with real-world WordPress plugins
95+
96+ ## [ 1.0.70] - 2026-01-01
97+
98+ ### Added
99+ - ** DRY Violation Detection (Aggregated Patterns)** - New pattern type for detecting code duplication
100+ - Added ` detection_type ` field to pattern schema (` direct ` or ` aggregated ` )
101+ - Created 3 aggregated patterns for detecting duplicate string literals:
102+ - ` dist/patterns/duplicate-option-names.json ` - Duplicate WordPress option names across files
103+ - ` dist/patterns/duplicate-transient-keys.json ` - Duplicate transient keys across files
104+ - ` dist/patterns/duplicate-capability-strings.json ` - Duplicate capability strings across files
105+ - Aggregated patterns group matches by captured string and report violations when:
106+ - String appears in >= 3 distinct files (configurable via ` min_distinct_files ` )
107+ - String appears >= 6 total times (configurable via ` min_total_matches ` )
108+ - ** Purpose:** Detect DRY violations where hardcoded strings should be constants
109+ - ** Example:** Option name ` 'my_plugin_settings' ` used in 5 files (8 times) → suggests creating a constant
110+
111+ - ** JSON Output Enhancement** - Extended JSON schema to include DRY violations
112+ - Added ` dry_violations ` array to JSON output with structure:
113+ - ` pattern ` : Pattern title (e.g., "Duplicate option names across files")
114+ - ` severity ` : Pattern severity (MEDIUM/HIGH/CRITICAL)
115+ - ` duplicated_string ` : The duplicated string literal
116+ - ` file_count ` : Number of distinct files containing the string
117+ - ` total_count ` : Total occurrences across all files
118+ - ` locations ` : Array of ` {file, line} ` objects showing all occurrences
119+ - Added ` dry_violations ` count to summary section
120+ - ** Example Output:**
121+ ``` json
122+ {
123+ "summary" : {
124+ "dry_violations" : 2
125+ },
126+ "dry_violations" : [
127+ {
128+ "pattern" : " Duplicate option names across files" ,
129+ "severity" : " MEDIUM" ,
130+ "duplicated_string" : " my_plugin_settings" ,
131+ "file_count" : 5 ,
132+ "total_count" : 8 ,
133+ "locations" : [
134+ {"file" : " includes/admin.php" , "line" : 42 },
135+ {"file" : " includes/settings.php" , "line" : 15 }
136+ ]
137+ }
138+ ]
139+ }
140+ ```
141+
142+ - **Pattern Loader Enhancement** - Improved JSON parsing for complex patterns
143+ - Added Python-based JSON extraction for reliable parsing of patterns with special characters
144+ - Falls back to grep/sed if Python is not available
145+ - Properly handles escaped characters in search patterns (e.g., `\(`, `\"`, `['\"]`)
146+ - Extracts `detection_type` field to distinguish direct vs aggregated patterns
147+
148+ ### Changed
149+ - **Pattern Schema** - Extended pattern definition schema
150+ - Added `detection_type` field (required): `"direct"` or `"aggregated"`
151+ - Added `aggregation` section for aggregated patterns:
152+ - `enabled`: Boolean to enable/disable aggregation
153+ - `group_by`: Field to group by (currently only `"capture_group"` supported)
154+ - `min_total_matches`: Minimum total occurrences to report (default: 6)
155+ - `min_distinct_files`: Minimum number of files to report (default: 3)
156+ - `top_k_groups`: Maximum number of violations to report (default: 15)
157+ - `report_format`: Template for violation messages
158+ - `sort_by`: Sort order for violations (`"file_count_desc"` or `"total_count_desc"`)
159+
160+ - **Text Output** - Added DRY Violation Detection section
161+ - New section displayed after all direct pattern checks
162+ - Shows pattern title and violation status for each aggregated pattern
163+ - Displays "✓ No violations" or "⚠ Found violations" for each pattern
164+
165+ ### Technical Details
166+ - **Aggregation Algorithm:**
167+ 1 . Run grep with pattern's search_pattern across all PHP files
168+ 2 . Extract captured group (e.g., option name from `get_option('name')`)
169+ 3 . Group matches by captured string
170+ 4 . Count distinct files and total occurrences for each string
171+ 5 . Report strings exceeding both thresholds
172+ - **Performance:** Aggregation runs after all direct checks to avoid duplicate grep operations
173+ - **Memory:** Uses temporary files for aggregation to handle large codebases
174+
175+ ### Known Issues
176+ - Pattern extraction may fail on systems without Python if patterns contain complex escaped characters
177+ - Aggregation currently only supports single capture group (group_by: "capture_group")
178+ - HTML report does not yet display DRY violations (JSON output only)
179+
8180## [1.0.69] - 2026-01-01
9181
10182### Added
0 commit comments