Skip to content

Add file-based inclusion filter for static analysis issues - #3273

Open
panicking wants to merge 1 commit into
jenkinsci:mainfrom
panicking:feat/add-files-list-parser
Open

Add file-based inclusion filter for static analysis issues#3273
panicking wants to merge 1 commit into
jenkinsci:mainfrom
panicking:feat/add-files-list-parser

Conversation

@panicking

Copy link
Copy Markdown
Contributor

This change introduces a FileInclusionFilter that allows users to provide a path to a text file containing a list of filenames (one per line). Only issues found in files that end with a path listed in this file will be reported.

Key changes:

  • Created FileInclusionFilter and FileNameFilter to handle the logic of matching absolute issue paths against relative filenames in the inclusion list.
  • Updated IssuesScanner and ReportPostProcessor to apply this filter during the report scanning and post-processing phases.
  • Added a new 'filesFilter' configuration field to RecordIssuesStep, ScanForIssuesStep, and IssuesRecorder.
  • Integrated the new parameter into the Jenkins UI via Jelly templates and properties.

This functionality helps avoid character limit constraints of traditional regex filters when dealing with large patches in distributed environments.

Testing done

Deployed in the infrastructure and change the pipeline to test it

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@github-actions
github-actions Bot requested a review from uhafner February 18, 2026 11:41
@panicking
panicking force-pushed the feat/add-files-list-parser branch from 0eebb6a to da19b89 Compare February 18, 2026 22:09
@uhafner uhafner changed the title RFC: feat: Add file-based inclusion filter for static analysis issues RFC: Add file-based inclusion filter for static analysis issues Apr 16, 2026
@uhafner uhafner added the feature New features label Apr 16, 2026
@uhafner

uhafner commented Apr 17, 2026

Copy link
Copy Markdown
Member

So I am back on duty now. The idea behind the PR looks reasonable. I wonder if a simpler approach would work as well: create the instances for the existing file filter dynamically. So we do not need to change the filtering, just the creation of the filters? What do you think? That should make the change less intrusive.

@panicking

Copy link
Copy Markdown
Contributor Author

So I am back on duty now. The idea behind the PR looks reasonable. I wonder if a simpler approach would work as well: create the instances for the existing file filter dynamically. So we do not need to change the filtering, just the creation of the filters? What do you think? That should make the change less intrusive.

This is the way I create the list:

git -C firmware diff --name-only ${GIT_COMMIT_firmware}..${GIT_REMOTE_firmware}/${GIT_BRANCH_firmware} > includeFiles.txt

And this is the way how I use it

recordIssues(sourceCodeRetention: 'MODIFIED',
                    tool: valgrind(pattern: "out/test/memcheck.xml"),
                    filesFilter: 'includeFiles.txt',
                    qualityGates: [[threshold: 1, type: 'TOTAL', criticality: 'FAILURE', unstable: false]])

Can you provide an example in what you are look for? Before I have implemented I was thinking several way and I come out with some synthax simpler that can used without so much limit. You have more experience then me so I'm open to rework it

private AnnotatedReport scanWithTool(final Run<?, ?> run, final FilePath workspace, final TaskListener listener,
final Tool tool) throws IOException, InterruptedException {
var issuesScanner = new IssuesScanner(tool, getFilters(), getSourceCodeCharset(),
var issuesScanner = new IssuesScanner(tool, getFilters(), getFilesFilter(), getSourceCodeCharset(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be much simpler if we do not add a new parameter and simply change the existing parameter filters to getFilters() + createFiltersFromFile().

And in the new method createFiltersFromFile() you create additional Exclude/Include FileFilter instances by reading the file and creating a new filter? Or would that not work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uhafner Ok, make sense, let me try.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uhafner can you review the new approach if make sense for you?

@panicking
panicking force-pushed the feat/add-files-list-parser branch 2 times, most recently from 8d71ca2 to 4470dd9 Compare June 13, 2026 22:39
@github-actions
github-actions Bot requested a review from uhafner June 13, 2026 22:56
}
try {
FilePath fileFilterPath = new FilePath(workspace, filePath);
String content = fileFilterPath.readToString();
@panicking
panicking force-pushed the feat/add-files-list-parser branch from 4470dd9 to 986b232 Compare June 14, 2026 13:26
@panicking panicking changed the title RFC: Add file-based inclusion filter for static analysis issues Add file-based inclusion filter for static analysis issues Jun 14, 2026
@panicking
panicking force-pushed the feat/add-files-list-parser branch 5 times, most recently from b1e4b59 to 907cee8 Compare June 14, 2026 18:42
@github-actions

Copy link
Copy Markdown

☀️   Quality Monitor

Tests

   JUnit   Unit Tests: ❌ unstable — 1 failed $\color{red}{\textsf{(+1)}}$, 91 passed $\color{red}{\textsf{(-1)}}$, 2 skipped $\textsf{(±0)}$
   🚀   Integration Tests: ✅ successful — 508 passed $\textsf{(±0)}$, 10 skipped $\textsf{(±0)}$
   ⛔   Architecture Tests: ✅ successful — 15 passed $\textsf{(±0)}$

Coverage for New Code

   〰️   Line Coverage: 60.34% — 23 missed lines
   ➰   Branch Coverage: 44.44% — 10 missed branches

Coverage for Whole Project

   〰️   Line Coverage: 80.54% $\color{red}{\textsf{(-0.29)}}$ — 1218 missed lines
   ➰   Branch Coverage: 64.76% $\color{red}{\textsf{(-0.39)}}$ — 487 missed branches

Style

   CheckStyle   CheckStyle: No warnings $\textsf{(±0)}$
   PMD   PMD: No warnings $\textsf{(±0)}$
   ☕   Java Compiler: 1 warning $\color{green}{\textsf{(+1)}}$ — normal: 1

Bugs

   SpotBugs   SpotBugs: No bugs $\textsf{(±0)}$
   🐛   Error Prone: No bugs $\textsf{(±0)}$

Vulnerabilities

   🛡️   OWASP Dependency Check: 229 vulnerabilities $\color{green}{\textsf{(+229)}}$ — error: 16, high: 57, normal: 149, low: 7

Software Metrics

   🌀   Cyclomatic Complexity: 2663 (total)
   💭   Cognitive Complexity: 865 (total)
   ➿   N-Path Complexity: 3046 (total)
   📏   Lines of Code: 32402 (total)
   📝   Non Commenting Source Statements: 10752 (total)
   🔗   Class Cohesion: 100.00% (maximum)
   ⚖️   Weight of Class: 100.00% (maximum)

📌 Reference Results

Delta reports computed against the reference results of 9c38669 in workflow run 27501886918.

🚦 Quality Gates

Overall Status: ❌ FAILURE

✅ Passed Gates

  • ✅ Potential Bugs in Whole Project: 0.00 <= 0.00

❌ Failed Gates

  • ❌ Overall Tests Success Rate: 99.84 >= 100.00
  • ❌ Line Coverage in New Code: 60.34 >= 90.00
  • ❌ Branch Coverage in New Code: 44.44 >= 90.00
  • ❌ Style Violation in Whole Project: 1.00 <= 0.00

Created by Quality Monitor v4.15.0 (#82d77af). More details are shown in the GitHub Checks Result.

@panicking
panicking force-pushed the feat/add-files-list-parser branch 6 times, most recently from 8982345 to d2be40f Compare June 20, 2026 15:11
Introduce a `FileInclusionFilter` configuration that allows users to provide
a path to a text file containing a list of filenames (one per line).
Static analysis issues are filtered using an "ends-with" match strategy,
ensuring that only issues originating from files specified in the inclusion
list are reported.

This mechanism acts as a viable alternative to traditional regex filters,
avoiding the character limit constraints encountered when processing large
patches or diffs in distributed CI environments.

Key changes:
- Created FileInclusionFilter, FileNameFilter, and FilterConfig to bundle
  and execute file-matching logic against issue paths.
- Updated IssuesScanner and its internal ReportPostProcessor to read and
  apply the new filter during scanning and post-processing.
- Added the 'filesFilter' parameter and data-bound setters to IssuesRecorder,
  RecordIssuesStep, and ScanForIssuesStep.
- Integrated the configuration field into the Jenkins UI via Jelly templates
  and localization properties.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
@panicking
panicking force-pushed the feat/add-files-list-parser branch from d2be40f to 5622a4c Compare June 20, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants