Closed uhafner closed 3 years ago
BugPattern#getDetailText()
is what you need, but it's same to reading text from messages.xml
. We also read messages.xml
directly to build profiles for SonarQube.
Thanks, that works! At least I get the messages for the core rules:
DetectorFactoryCollection collection = new DetectorFactoryCollection();
BugPattern pattern = collection.lookupBugPattern(
"RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE");
assertThat(pattern.getDetailText())
.contains("This method contains a redundant check of a known non-null value against\n"
+ "the constant null.");
The DetectorFactoryCollection
seems to have only one member so far. How can I include the bugs from https://find-sec-bugs.github.io?
I found something like Plugin.addCustomPlugin()
but that expects a URL which I really don't have in a complex application like Jenkins with its custom class loaders. Should this URL point to the jar file? Or is there a simpler API where I just register the plugin via a given class file?
How can I include the bugs from https://find-sec-bugs.github.io?
You need to add the plugin like below:
This code runs when we specify the plugin file path by -pluginList
option.
Thanks for your pointers!
I feared that this is done using plain files (and not using the class loader). This is kind of difficult in a distributed architecture like Jenkins. But I'll try to get this working. If not, there is still the fallback of parsing the XML files.
I'm reading the bug description messages of the
messages.xml
file in my Jenkins warnings plugin to enhance the warnings visualization with additional details. Currently I am simply copying the xml file from your distribution (and from findbugs-contrib, and find-sec-bugs) and reading it using an own XML parser. Since I am now adding a compile dependency to the latest SpotBugs version in my module anyway, it would make sense to use the official API if possible to get the warnings descriptions.I tried to find the corresponding piece of code but it seems to be not so obvious on how to do it. So my question: how can I get the the detailed description for a bug pattern like
NP_STORE_INTO_NONNULL_FIELD
?