RuboCop Analysis for *.html.erb files

In our organization we have a ruby on rails application that uses .html.erb templates for generation of mails and pdfs. Our linter of choice for ruby code is RuboCop combined with the analyzers provided by SonarCloud.

Recently we discovered erb-lint and want to try its inclusion into our development cycle. Erb-lint provides junit and json (similar to RuboCop, but not the same) output.

Neither specifying the additional RuboCop json or the junit report path in the project settings caused the issues to show up in the SonarCloud web interface and the pr decorations of the SonarCloud analysis.

I’m sorry if this is a problem with our configuration, but we see great potential in allowing files to be analyzed by multiple tools and aggregating the results in a unified platform like SonarCloud.


Hello @Luckeu,

Welcome to the SonarCloud community!

I’m trying to understand your problem and I have a first clarification question.

Are you having trouble loading the results of Rubocop into SonarCloud or having trouble loading the results of erb-lint into SonarCloud?

Can you share some logs of your SonarScanner execution?


We have Problems loading the erb-lint results into SonarCloud. Our RuboCop output is loaded by specifying the result file in sonar.ruby.rubocop.reportPaths. But when adding the JSON output of erb-lint as additional element no issues are present.

We suspect the problem might be that the issues regard .html.erb files, which are in the scope of the html analyzer and not in the scope of ruby. But moving the .erb extension from the default HTML language to ruby disables the SonarCloud analyzer which we also want to use.

INFO: Sensor Ruby Sensor [ruby] (done) | time=1884ms
INFO: Sensor Import of RuboCop issues [ruby]
INFO: Importing /home/org/myagent/_work/16/s/spec/rubocop.json
INFO: Importing /home/org/myagent/_work/16/s/spec/erb-rubocop.json
INFO: Sensor Import of RuboCop issues [ruby] (done) | time=541ms

With luck, it could have worked but I guess the format of the JSON output of erb-lint is not exactly the same as the output of Rubocop and we certainly filter out files that do have not a .rb extension to just report issues on Ruby files.
I’ll create a ticket to look at erb-lint and decide if we want to support it out of the box.

Meanwhile, the only solution I can provide is to transform the output of erb-lint into the Generic Issue Data format.

Thanks for the Feedback
Is it possible to get the specification for the expected rubocop.json format that erb-lint would need to export?

We will definitely take a look at generating generic issue data. Can you point us in the direction of any tools that do output in the generic format? Or do we have to build them ourselves?