Custom Plugin (Java) created but unable to see results in SonarQube

Developed a custom SonarQube plugin (using Java) per version 7.9.5.

The plugin has been developed by myself and a small team; however the documentation is awful and we’re incredibly lost as to how to see results in SonarQube. The only thing that we have at this point is context.reportIssue() when we want to raise an issue. We believe there is much more being missed but can’t find anything to get us the info we need to know what comes next. Honestly, we need to raise an issue (only at the class level) and I’m not even sure we’re doing that right (and ultimately aggregate the results into a project level measure too). Unable to find resources online to on that either to help realize that one way or the other.

1.) Created a new metric and am unable to find anything useful online as to how to report the measure to SonarQube under the metric.

2.) Ideally, We’d be able to see a project level measure (percentage) and within it, a class level measure (percentage) right in SonarQube. Note that the plugin is loaded into the extensions/plugins folder. Able to see the plugin in SonarQube but nothing from our new rule.

Can anyone help please?

Please note that between myself and the others working with me… we have seen just about every potentially useful piece of documentation that is easy and not easy to find on the internet. Need something that can spell it out like any normal good documentation would.

Example:

  • What should we be studying to accomplish this? e.g.(referral to someone or some specific thorough documentation… Not Sonars Docs as they aren’t so great on this topic or any topic related to the bowels of custom plugin development for this platform).

  • What would be required from a development standpoint? e.g.(separate Sonar project, some form of widget creation in the custom plugin project itself, etc…)

  • Anything else you can refer me to or enlighten me on?

To be honest, if anyone would be up for a short one-on-one, would really appreciate it.

This is first time doing ‘anything’ Sonar** and anything you have helps.

ALSO

What are all the _java.html and _java.json files in the src/main/resources? Can’t find anything online on these that really explain where / how they are used or can be used.

Thank you ‘so’ much in advance for you guidance here.

Hey @jmcnally2020, and welcome to this community!

Sorry for the late replay, posting just before Christmas was maybe not the best time to ask such a big question and get a lot of answers.

It’s not that clear to me what you - and your team - are trying to achieve:

  • Are you trying to write you own SonarQube plugin to do something completely new? (we speak about a “custom plugin”)
  • Are you just trying to add some new rules to the java analyzer, relying on its API (we speak here of a “custom rules plugin”)
  • Are you trying to do both? (providing new metrics, doing some new stuff on top of playing new rules, which would require the Java Analyzer to kick in at some point)

The fact that you want to report some issues (on java code?) make me feels that you are actually writing java rules, but you could also try to raise completely new issues out of the blue directly through the SonarQube API.

Just to be sure before we start, did you explore a bit our example custom plugin, in this repository?
(make sure to use the 7.x branch, as you are obviously targeting a 7.9 SQ instance).

You might also want to have a look at the way of writing custom rules here

It should give you examples of things you try to achieve, and maybe allow you to connect some dots.

Now, regarding your other question:

From where do you see them? From the SonarSource Java Analyzer repository?

Because if it’s the case, then these files are just the ones containing the metadata of all the 600+ rules provided by the SonarSource Java analyzer, to be displayed by SQ when browsing rules.

If you need some guidance about how to make some bit of code work, please provide some code snippet of what is actually not working you would like to, so it would help us to answer (and have the correct people jumping in). For instance, as I’m one of the maintainers of the Java Analyzer, I probably won’t be able to help you a lot with completely independent plugins, but I would gladly help designing and writing rules targeting java.

Hope this helps, for a start,
Michael