jenkinsci/violations-plugin

No violations found when opening file on Windows

Opened this issue · 1 comments

When running on windows and you try to open the page .../job/myjob/2/violations/file/path/to/myfile.py/
you get "No violations found"

The following patch fixes this.
But I don't really know the code and there my be some other places where this problem pops up. So there might be a better place/way to fix this properly.

diff -r 17567a8c09f2 src/main/java/hudson/plugins/violations/ViolationsReport.java
--- a/src/main/java/hudson/plugins/violations/ViolationsReport.java Wed Apr 16 20:21:26 2014 +0100
+++ b/src/main/java/hudson/plugins/violations/ViolationsReport.java Wed May 07 13:59:24 2014 +0200
@@ -211,7 +211,7 @@
if (name.startsWith("/")) {
name = name.substring(1);
}

  •    FileModelProxy proxy = getFileModelProxy(name);
    
  •    FileModelProxy proxy = getFileModelProxy(name.replace("/", File.separator));
     if (proxy != null) {
         return new RecurDynamic(
             "", name, proxy.build(build).contextPath(req.getContextPath()));
    

I came across this issue as well while trying to parse results from subfolders in Windows. I think this is the best place to make the change, as the keys are all generated matching what is contained within the xml files and directory locations. I created pull request 81 for this change.