Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into remove-line-range
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 20, 2024
2 parents c55d0d4 + 7248084 commit ee276a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ public void run(final FullTextFingerprint algorithm, final Report report, final
}

private boolean hasAllowedExtension(final String fileName) {
return !NON_SOURCE_CODE_EXTENSIONS.contains(StringUtils.lowerCase(FilenameUtils.getExtension(fileName)));
try {
return !NON_SOURCE_CODE_EXTENSIONS.contains(StringUtils.lowerCase(FilenameUtils.getExtension(fileName)));
}
catch (IllegalArgumentException exception) {
return false; // if the file name is invalid, we assume that it is not a source code file

Check warning on line 60 in src/main/java/edu/hm/hafner/analysis/FingerprintGenerator.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 59-60 are not covered by tests
}
}

private int computeFingerprint(final Issue issue, final FullTextFingerprint algorithm, final Charset charset,
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/edu/hm/hafner/analysis/FingerprintGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ void shouldUseFallbackFingerprintOnNonSourceFiles(final String fileName) {
assertThatIssueHasDefaultFingerprint(report);
}

@ParameterizedTest(name = "[{index}] Skip illegal source code files on Windows {0}")
@ValueSource(strings = {"prefix::suffix.txt", ":"})
void shouldUseFallbackFingerprintOnIllegalFilenamesOnWindows(final String fileName) {
assumeThatTestIsRunningOnWindows();

var report = createReportWithOneIssueFor(fileName);

FingerprintGenerator generator = new FingerprintGenerator();
generator.run(createFullTextFingerprint("fingerprint-two.txt"),
report, CHARSET_AFFECTED_FILE);

assertThatIssueHasDefaultFingerprint(report);
}

private Report createReportWithOneIssueFor(final String fileName) {
Report report;
try (IssueBuilder issueBuilder = new IssueBuilder()) {
Expand Down

0 comments on commit ee276a8

Please sign in to comment.