Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate HTML reports after upgrade to 4.8.0 #629

Closed
leviem1 opened this issue Nov 30, 2021 · 15 comments · Fixed by #635
Closed

Can't generate HTML reports after upgrade to 4.8.0 #629

leviem1 opened this issue Nov 30, 2021 · 15 comments · Fixed by #635
Labels

Comments

@leviem1
Copy link

leviem1 commented Nov 30, 2021

I'm no longer able to generate HTML reports on 4.8.0 with the following configuration that worked on 4.7.10. Only XML reports are available despite being explicitly disabled. There's also 2 violations detected despite only 1 being detected on 4.7.10.

// Enable spotbugs html reports for source files
spotbugsMain {
    reports {
        xml.required = false
        html.required = true
    }
}

// Enable spotbugs html reports for test files
spotbugsTest {
    reports {
        xml.required = false
        html.required = true
    }
}

The following configuration from #628 gave the same result:

tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
  reports {
    xml {
      required.set(false)
    }
    html {
      required.set(true)
    }
  }
}

This configuration from #628 resulted in no output files at all and only 1 detected violation.

tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
    reports {
        xml {
            enabled = false
        }
        html {
            enabled = true
        }
    }
}

Am I missing something?

@koalalam
Copy link

@KengoTODA
Copy link
Member

Could you share a mcve project to reproduce it in my local?
I guess that you use old SpotBugs core, but not so sure, and need more information to reproduce.

@leviem1
Copy link
Author

leviem1 commented Dec 1, 2021

Holy crap this took way too long...

https://github.com/leviem1/spotbugs-mcve

If you can't reproduce, it's because you're on macOS or Linux, and it probably has to do with path separators being platform dependent.

Nonetheless, unwanted XML files are present on both platforms and I'm able to reproduce no HTML files on my Windows box only.

@KengoTODA
Copy link
Member

I could reproduce the reported issue at GitHub Action:
https://github.com/KengoTODA/spotbugs-mcve/runs/4379950050?check_suite_focus=true

@leviem1
Copy link
Author

leviem1 commented Dec 1, 2021

Glad to hear you were able to reproduce. Seems like it's definitely platform dependent.

I tried to do some bug hunting on my own, but didn't catch anything obvious at first glance.... The path separator comment was a shot in the dark and I haven't found anything to support it. This could easily be an issue in spotbugs core as well. I'll keep looking, but let me know if I need to open an issue in the core project.

@KengoTODA
Copy link
Member

The generated command line options are LGTM. I will try to reproduce on the spotbugs core project side.

2021-12-02T08:58:37.932+0800 [DEBUG] [com.github.spotbugs.snom.internal.SpotBugsRunner] Arguments for SpotBugs are generated: [-pluginList, C:\Users\kengo\.gradle\caches\modules-2\files-2.1\com.h3xstream.findsecbugs\findsecbugs-plugin\1.11.0\909178d9c6e1db06b643daaead382d89fe2334c9\findsecbugs-plugin-1.11.0.jar, -timestampNow, -auxclasspath, C:\Users\kengo\.gradle\caches\modules-2\files-2.1\com.github.spotbugs\spotbugs-annotations\4.5.0\f9d4937cedc54632cd3811bf2629877673116ffa\spotbugs-annotations-4.5.0.jar;C:\Users\kengo\.gradle\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\3.0.2\25ea2e8b0c338a877313bd4672d3fe056ea78f0d\jsr305-3.0.2.jar, -sourcepath, C:\Users\kengo\github\spotbugs-mcve\src\main\resources;C:\Users\kengo\github\spotbugs-mcve\src\main\java, -html=C:\Users\kengo\github\spotbugs-mcve\build\reports\spotbugs\main.html, -xml:withMessages=C:\Users\kengo\github\spotbugs-mcve\build\reports\spotbugs\main.xml, -projectName, spotbugs-mcve (spotbugsMain), -release, 0.1.0, -analyzeFromFile, C:\Users\kengo\github\spotbugs-mcve\build\tmp\spotbugsMain\spotbugs-gradle-plugin2407983638023568280.txt]

@KengoTODA
Copy link
Member

Confirmed that .\gradlew.bat build can pass even on the Windows on https://github.com/spotbugs/spotbugs/compare/build-on-windows

@leviem1
Copy link
Author

leviem1 commented Dec 2, 2021

After spinning around 3 times, standing on my head, and making a prayer to the computer gods, I was able to find a config combo that produces the correct results:

tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
    reports {
        xml {
            enabled = false
        }
        html {
            enabled = true
            stylesheet = 'default.xsl'
        }
    }
}

This leads me to believe that the error was introduced here: spotbugs/spotbugs@6882383#diff-4e11ecc7198156d84146e3ac10b8ce11e0884688746d40b003000c1074dc0468R277-R291

Maybe something to do with when if (index >= 0) is false? Just a guess, not sure by any means.

Doesn't explain why it's not reproduceable on my macOS box though. Totally guessing again, but maybe something to do with closing/flushing streams?

@KengoTODA
Copy link
Member

Aha, possible, Windows has a colon in file path after the drive letter, so current implementation probably have a problem around it. I'll try to write a unit test for reproduction. Thanks!

@KengoTODA
Copy link
Member

Here is the point:

https://github.com/spotbugs/spotbugs/blob/d9df81c51aa51d989df25c9df309f91e6e0e8155/spotbugs/src/main/java/edu/umd/cs/findbugs/config/CommandLine.java#L316-L327

It expects no : we have after =, but on the Windows platform it is possible.

@aburmeis
Copy link

aburmeis commented Dec 6, 2021

Still have the same problem using Gradle 7.3.1 and SpotBugs plugin 5.0.0 under Windows:

  • enabling HTML report seems to create a HTML file with the name of the Windows drive
  • disabling of XML report seems to be impossible
ext {
	gitlabCi = ...
}

spotbugsMain {
	reports {
		html.required = !gitlabCi
		xml.required = gitlabCi
	}
}

@leviem1
Copy link
Author

leviem1 commented Dec 6, 2021

@aburmeis the fix has been merged into the core project and should be available in a future release. It was not included in v5.0.0 based on the release notes.

The workaround of explicitly denoting a stylesheet should work until the fix is released, though I haven't tested it super extensively.

tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
    reports {
        xml {
            enabled = false
        }
        html {
            required.set(true)
            stylesheet = 'default.xsl'
        }
    }
}

Correct me if I'm wrong so I can avoid a breaking update.

Edit: I agree that using xml.required.set(false) should disable XML, but doesn't seem to. Only the deprecated enabled = false approach seems to disable it. Maybe we should open another issue for that? @KengoTODA

@KengoTODA
Copy link
Member

Edit: I agree that using xml.required.set(false) should disable XML, but doesn't seem to. Only the deprecated enabled = false approach seems to disable it. Maybe we should open another issue for that? @KengoTODA

I confirmed this problem in my local :<
I will create a PR to reproduce and fix. Thanks for your notice!

@leviem1
Copy link
Author

leviem1 commented Dec 8, 2021

@aburmeis I just reproduced the issue with the file named "C" you mentioned with this config

tasks.withType(SpotBugsTask) {
    reports {
        xml.required.set(false)
        html.required.set(true)
    }
}

But for some reason, I don't get the issue with this syntax.

tasks.withType(SpotBugsTask) {
    reports {
        xml {
            required.set(false)
        }
        html {
            required.set(true)
        }
    }
}

@KengoTODA Maybe worth investigating or writing a test to check if spotbugs/spotbugs#1842 fixes this case as well? Unless I just don't understand a nuance of Groovy.

Edit 2: Updated to reflect changes made in v5.0.2

Edit 3: My bad, guess I had some cache issues

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

🎉 This issue has been resolved in version 5.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants