Skip to content

Commit c4c26c1

Browse files
baloghadamsoftwareiloveeclipse
authored andcommitted
Fix for test detector ViewCFG
The ViewCFG detector generates files with names containing the `<` and the `>` characters for classes containing more than one constructor. Since these characters are illegal in file names on `Windows` the analysis fails with an exception. Since all the detectors (even those which are disabled by default) are enabled during testing, the build fails on `Windows`. See issue [#2209](#2209). This PR fixes this issue.
1 parent 77b7da7 commit c4c26c1

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Currently the versioning policy of this project follows [Semantic Versioning v2.
1313
- Bump up log4j2 binding to `2.19.0`
1414
- Bump ObjectWeb ASM from 9.3 to 9.4 supporting JDK 20 ([#2200](https://github.com/spotbugs/spotbugs/pull/2200))
1515
- Bump up commons-text to 1.10.0 ([#2197](https://github.com/spotbugs/spotbugs/pull/2197))
16+
- Fixed debug detector `ViewCFG` to generate file names that are also valid on Windows ([#2209](https://github.com/spotbugs/spotbugs/issues/2209))
1617

1718
## 4.7.2 - 2022-09-02
1819
### Fixed

spotbugs/src/main/java/edu/umd/cs/findbugs/detect/ViewCFG.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@ private void analyzeMethod(ClassContext classContext, Method method, Path classD
171171
}
172172

173173
private Path getMethodFile(Path classDir, String methodName) {
174-
String methodFileName = SPECIAL_METHOD.matcher(methodName).replaceAll("____$1");
174+
String methodFileNameBase = SPECIAL_METHOD.matcher(methodName).replaceAll("____$1");
175175
Path methodFile;
176176
int index = 0;
177177

178+
String methodFileName = methodFileNameBase;
178179
do {
179180
methodFile = Paths.get(classDir.toString(), methodFileName + ".dot");
180-
methodFileName = methodName + ++index;
181+
methodFileName = methodFileNameBase + ++index;
181182
} while (Files.exists(methodFile));
182183
return methodFile;
183184
}

0 commit comments

Comments
 (0)