Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scanning Ruby on Rails Projects with SonarQube

I want to check my Ruby on Rails app with sonarqube. I've added the Web plugin which should work with Ruby but I get the following error during sonarqube exectution:

app/controllers/course_statistics_controller.rb
java.lang.NullPointerException: null
at org.sonar.plugins.web.checks.sonar.UnsupportedTagsInHtml5Check.isUnsupportedTag(UnsupportedTagsInHtml5Check.java:77) ~[na:na]
at org.sonar.plugins.web.checks.sonar.UnsupportedTagsInHtml5Check.startElement(UnsupportedTagsInHtml5Check.java:71) ~[na:na]
at org.sonar.plugins.web.visitor.HtmlAstScanner.scanElementTag(HtmlAstScanner.java:117) ~[na:na]
at org.sonar.plugins.web.visitor.HtmlAstScanner.scanElement(HtmlAstScanner.java:96) ~[na:na]
at org.sonar.plugins.web.visitor.HtmlAstScanner.scan(HtmlAstScanner.java:80) ~[na:na]
at org.sonar.plugins.web.visitor.HtmlAstScanner.scan(HtmlAstScanner.java:59) ~[na:na]
at org.sonar.plugins.web.core.WebSensor.analyse(WebSensor.java:93) ~[na:na]
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67) [sonar-batch-maven-compat-5.1.jar:na]
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) [sonar-runner-batch1741912612400004619.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_65]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_65]
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-runner-dist-2.4.jar:na]
at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_65]
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.api.Runner.execute(Runner.java:100) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.executeTask(Main.java:70) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.execute(Main.java:59) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.main(Main.java:53) [sonar-runner-dist-2.4.jar:na]

What is wrong?

like image 293
Felix Avatar asked May 11 '15 10:05

Felix


People also ask

Does SonarQube support Ruby?

Once SonarQube is upgraded to 7.4, ruby analysis was available by default. No configuration was required on the Admin side/web app. We did the following to do an analysis of our ruby project.

What is the difference between SonarQube and Sonar scanner?

SonarScanner is a separate client type application that in connection with the SonarQube server will run project analysis and then send the results to the SonarQube server to process it. SonarScanner can handle most programming languages supported by SonarQube except C# and VB.

What languages can SonarQube scan?

Overview. SonarQube includes support for the programming languages Java (including Android), C#, C, C++, JavaScript, TypeScript, Python, Go, Swift, COBOL, Apex, PHP, Kotlin, Ruby, Scala, HTML, CSS, ABAP, Flex, Objective-C, PL/I, PL/SQL, RPG, T-SQL, VB.NET, VB6, and XML.


2 Answers

SonarQube has dropped support for Ruby.

If you want to supply code styles check for your application, you take a look into following links:

Ruby Style Guide.

RuboCop - Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community rails-style-guide. Very configurable and well maintained gem.

Guard-ruboCop - allows you to automatically check Ruby code style with RuboCop when files are modified.

Rails best practices - a code metric tool to check the quality of rails cod. Well maintained.

Simplecov - code coverage analysis tool for Ruby (tests).

Reek - is a tool that examines Ruby classes, modules and methods and reports any Code Smells it finds.

like image 93
Andrey Deineko Avatar answered Oct 19 '22 14:10

Andrey Deineko


Looks like SonarQube 7.4 now has support for Ruby!

Ruby Ruby Analysis Has Arrived!

https://www.sonarqube.org/sonarqube-7-4/

like image 45
Stéphane Bruckert Avatar answered Oct 19 '22 14:10

Stéphane Bruckert