Adding new language, how to get the metrics to work

Hello there,

I am currently working on adding a new language to SonarQube. I got some rules to work, but the metriks arent working.

Now on the project there is shown that there are 127 lines duplicated. But the Duplication line density is still 0%. Well the number is wrong but I at least expected that the value of the duplication line densitiy would change.

So I want to know, what am I missing?

I am currently using SonarQube 9.8 for testing with the embedded database.
Also I am developing the plugin using ANTLR4 instead of SSLR.

I am using the Sonar-plugin-api I also noticed that when using the .gap function when creating a NewIssue, nothing changes. There is no added technical debt, just nothing.


The screenshot in your OP isn’t showing you that there are 127 duplicated lines, but that 127 lines, total, were found. Since duplication is calculated server-side, IIRC, you’d be better off focusing on other metrics.

You should take a look at some of the open source language analyzers, maybe the Rust plugin, to get an idea of how to calculate metrics.



thanks for the answer! The Rust plugin was easier to understand than the flex plugin I was looking at earlier.

It really helped!

1 Like