user2299739
user2299739

Reputation: 23

sonarqube plugin development: widget can't access metrics

I am trying to develop a custom SonarQube (4.3) plugin that has Decorator part and a widget that should display some sort of project metrics digest, i.e. code quality decision tree. I need it to access the metrics that are already collected by other plugins and stored in database.

I started with my widget just having plain text and something like this:

'Today is <%= Time.now.strftime('%A') %>' got it on the dashboard, no problem.

as soon as I access one of the sonar ruby functions, for example: 'Number of lines <%= measure('lines').value %>'

it throws an error in the browser: An error occurred while trying to display the widget "myWidget". Please contact the administrator.

and respectively, in sonarqube server log I get this:

2015.08.11 11:58:56 ERROR rails Can not render widget myWidget: undefined method `measure' for nil:NilClass

no matter which built in sonar ruby function I try, it seems to have no reference of it.

I have to confess that I don't understand how ruby's objects declared in *.rb files are linked to ruby's templates that reference those objects? None of the examples that I could find for Sonar plugin development can explain how it works? any help is greatly appreciated!!

cheers victor

Upvotes: 0

Views: 588

Answers (1)

You can take a look at our sample plugin to see what you can do.

More precisely, you can check the example_widget.html.erb file. You will see some code like:

<%= format_measure('random') -%>.

Upvotes: 1

Related Questions