Class FileNameFilter

java.lang.Object
io.jenkins.plugins.analysis.core.filter.FileNameFilter
All Implemented Interfaces:
Predicate<edu.hm.hafner.analysis.Issue>
Direct Known Subclasses:
NullFileNameFilter

public class FileNameFilter extends Object implements Predicate<edu.hm.hafner.analysis.Issue>
A Predicate that filters Issue instances by checking their file names against a provided collection of allowed paths.

This filter bridges the difference between the absolute paths that static analysis tools often report and the workspace relative paths that SCM tools (like git diff) produce: an entry matches an issue if it is either the complete file name of that issue, or a suffix of it that starts at a path segment boundary. So src/File.ts matches an issue in /var/jenkins/job/src/File.ts, while Test.java does not match an issue in src/MyTest.java.

Because the match does not depend on whether the file names of the issues have already been resolved to absolute paths, the filter yields the same result before and after post processing.

Author:
Michael Trimarchi
  • Constructor Details

    • FileNameFilter

      public FileNameFilter(Collection<String> files)
      Creates a new instance of FileNameFilter.
      Parameters:
      files - the collection of file paths to include in the filter. These are typically retrieved from a version control system's diff output. Blank entries are ignored: an entry that matches every file would silently disable the filter.
  • Method Details

    • test

      public boolean test(edu.hm.hafner.analysis.Issue issue)
      Evaluates this predicate on the given issue.
      Specified by:
      test in interface Predicate<edu.hm.hafner.analysis.Issue>
      Parameters:
      issue - the issue to test
      Returns:
      true if the file name of the issue is allowed, false otherwise