Unable to get metrics to display in SonarQube

Hi all,

Myself and 2 others are working on a very high priority project to create a custom SonarQube plugin that scans Java unit test files one by one to sum up the total ‘assertion’ count and sum up the total class method invocation count. They will be compared at the class level and a ratio is to be output and pushed to SonarQube where the ratio will display next to the scanned class (per test class).
It should also display ‘issues’.

We started by implementing a ‘rule’. “Check” and “Rule” seem interchangable based on information online. The API is poorly documented and we are having a very hard time with this high priority effort.

To explain better:

We have the “Sonar-Example-Plugin” and are trying to now modify it to our needs.
We are coding off of the sonar-example-plugin 7.9.*.

We wrote a “Rule” that only works on a dummy test file.

That rule - after figuring out we needed to have a sensor, are trying to move the logic over to a Sensor to run it against test files in the test directory inside the execute method. The rule implements extends BaseTreeVisitor and implements JavaFileScanner
With the modern sensor we are trying to move it to, we are 100% unsure how to reuse the code we already wrote. How does it work!?

We need to scan file one by one and hit the ‘visitMethod’ where our logic kicks off, and return a result and push that result to sonarqube for each fiie.

Can someone please help! We really need it as soon as possible. Once its done and stable, I plan to try to publish it to the community for use. I was given 1 month from now to get the MVP.

This quarter my company will be upgrading to the Enterprise version of SonarQube.

Would someone like to help please? Thanks!