Skip to content

Add --diff option to restrict analysis to changed lines#1

Merged
jordikroon merged 3 commits into
mainfrom
feature/diff-check
Apr 23, 2026
Merged

Add --diff option to restrict analysis to changed lines#1
jordikroon merged 3 commits into
mainfrom
feature/diff-check

Conversation

@jordikroon
Copy link
Copy Markdown
Member

Implement unified diff parsing and parent-context-aware violation filtering. Allows users to analyze only violations in modified files/lines by passing a diff.

Violations are reported when the violating element or its children span changed lines.

@jordikroon jordikroon force-pushed the feature/diff-check branch 2 times, most recently from d0d1538 to 206b860 Compare April 23, 2026 19:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

PHPUnit 13.1.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.5.5 with Xdebug 3.5.1
Configuration: /home/runner/work/docbook-cs/docbook-cs/phpunit.xml.dist

...............................................................  63 / 229 ( 27%)
............................................................... 126 / 229 ( 55%)
............................................................... 189 / 229 ( 82%)
........................................                        229 / 229 (100%)

Time: 00:00.758, Memory: 22.00 MB

OK (229 tests, 398 assertions)

Generating code coverage report in Clover XML format ... done [00:00.005]

Generating code coverage report in HTML format ... done [00:00.101]


Code Coverage Report Summary:
  Classes: 100.00% (24/24)
  Methods: 100.00% (123/123)
  Lines:   100.00% (811/811)

Implement unified diff parsing and parent-context-aware violation filtering.
Allows users to analyze only violations in modified files/lines by passing
a diff via --diff=<file>, --diff=-, or piping to stdin. Violations are
reported when the violating element or its children span changed lines.

Key features:
- DiffParser: parses unified diffs to extract changed line numbers per file
- SniffRunner: filters scanned files based on diff paths
- XmlFileProcessor: filters violations to only those affecting changed lines
- Application: adds stdin support and --diff CLI option with help text
- Comprehensive test coverage for diff parsing and filtering logic
Collapse multi-line PHPDoc comments to single-line format for brevity where the comment fits on one line. This improves code readability and follows a more concise documentation style.
@jordikroon jordikroon merged commit ff5fbfa into main Apr 23, 2026
3 checks passed
@jordikroon jordikroon deleted the feature/diff-check branch April 23, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant