How to add measure on a "virtual resource"?

We want to create a plugin to manage technical debt (about GreenIT and Accessibility) of our Website on SonarQube.

We use two Chrome plugins to generate JSON reports (on our CI with automated scenarios):

Those reports contains list of issues and several metrics against URL, not resources file.

How to add those measures on URLs (not file) on SonarQube?

Here the code of our plugin to save a measure. But we dont know how to create an InputComponent for a URL:



SonarSource products are centered around static code analysis, and reporting issues on source files. So we only support scanning a “real” project, with real files, and reporting issues on those files.
If the URL you get from external reports actually match a file (file://xxx) then in Java you can convert them to Path using something like Paths.get(url.toURI()).toFile().
Then you can use the Sonar Plugin API Filesystem to query the InputFile that correspond to this

Currently, the URL page is generated from multiple source files. But we couldn’t find a way to have a mapping between the URL and the source files. Only develpers can do this job.

When I read the report, can I create on the fly :

  • an empty file (for example, for the URL http://localhost/ui/welcome, I create the file : target/website/localhost/ui/welcome.html)
  • add a mesure to this file ?

→ I don’t know how to add metrics on files other than those located in the src/ folder. It does not work.

This is going in a too hacky direction. Many SonarQube features rely on the analyzed files to be real source code from the SCM.
I don’t think you should try to go against the tool intention, or you will face endless issues, and we could not really support you.

Okay, I understand

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.