GoDaddy-Hosting / ruby-sonar-plugin

Plugin to generate sonar metrics for ruby
MIT License
48 stars 33 forks source link

Does this plugin support the latest version of Sonar(6.4)? #15

Open knotsite15 opened 7 years ago

lylex commented 7 years ago

As documented, 4.5.5 LTS is tested. I have tried with a newer version sonarqube 6.5, and I found it not works.

Error is:

2017.09.05 02:17:46 ERROR web[][o.s.s.p.Platform] Background initialization failed. Stopping SonarQube java.lang.IllegalStateException: Fail to load plugin Sonar Ruby Plugin [ruby] at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:88) at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:531) at org.sonar.server.platform.Platform.start(Platform.java:231) at org.sonar.server.platform.Platform.startLevel34Containers(Platform.java:205) at org.sonar.server.platform.Platform.access$500(Platform.java:46) at org.sonar.server.platform.Platform$1.lambda$doRun$0(Platform.java:119) at org.sonar.server.platform.Platform$AutoStarterRunnable.runIfNotAborted(Platform.java:391) at org.sonar.server.platform.Platform$1.doRun(Platform.java:119) at org.sonar.server.platform.Platform$AutoStarterRunnable.run(Platform.java:375) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.NoClassDefFoundError: org/sonar/api/web/CodeColorizerFormat at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at org.sonar.classloader.ClassRealm.loadClassFromSelf(ClassRealm.java:125) at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:37) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76) at com.godaddy.sonar.ruby.RubyPlugin.getExtensions(RubyPlugin.java:39) at org.sonar.api.SonarPlugin.define(SonarPlugin.java:51) at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:78) ... 9 common frames omitted Caused by: java.lang.ClassNotFoundException: org.sonar.api.web.CodeColorizerFormat at org.sonar.classloader.ParentFirstStrategy.loadClass(ParentFirstStrategy.java:39) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:87) at org.sonar.classloader.ClassRealm.loadClass(ClassRealm.java:76) ... 25 common frames omitted 2017.09.05 02:17:46 INFO web[][o.s.p.StopWatcher] Stopping process

jhgjhtuytdfbnfvmnbgjtuydt commented 7 years ago

Try this other version https://github.com/eresse/ruby-sonar-plugin

hersonalfaro commented 7 years ago

@lylex , @knotsite15 I've worked on one for 6.4 -- https://github.com/hersonalfaro/ruby-sonar-plugin/releases/tag/6.4-rc

jhgjhtuytdfbnfvmnbgjtuydt commented 7 years ago

Hi @hersonalfaro thanks for the fix.

I am getting this error when running metric_fu before calling the SonarQube scanner in Jenkins

Do you have any idea of what the error may be?

Thank-you

23:39:39.256 DEBUG: 'config/routes.rb' generated metadata  with charset 'UTF-8'
23:39:39.260 INFO: Highlighting config/spring.rb
23:39:39.280 INFO: Highlighting db/migrate/20170928153502_devise_create_users.rb
23:39:39.300 DEBUG: 'db/migrate/20170928153502_devise_create_users.rb' generated metadata  with charset 'UTF-8'
23:39:39.306 INFO: Highlighting db/schema.rb
23:39:39.333 DEBUG: 'db/schema.rb' generated metadata  with charset 'UTF-8'
23:39:39.379 INFO: Highlighting db/seeds.rb
23:39:39.383 DEBUG: 'db/seeds.rb' generated metadata  with charset 'UTF-8'
23:39:39.383 INFO: Highlighting test/models/user_test.rb
23:39:39.396 DEBUG: 'test/models/user_test.rb' generated metadata  with charset 'UTF-8'
23:39:39.398 INFO: Highlighting test/test_helper.rb
23:39:39.410 DEBUG: 'test/test_helper.rb' generated metadata  with charset 'UTF-8'
23:39:39.420 INFO: Sensor RubySensor [ruby] (done) | time=1768ms
23:39:39.420 INFO: Sensor org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor [ruby]
23:39:39.420 INFO: Calling analyse for report results: /var/lib/jenkins/workspace/aaa/staging/BACKEND-deployment/tmp/metric_fu/report.yml
23:39:39.420 DEBUG: analyzing functions for classes in the file: channel.rb
23:39:39.420 INFO: functions are set
23:39:39.420 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
23:39:39.804 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from saikuro
23:39:39.804 DEBUG: analyzing functions for classes in the file: connection.rb
23:39:39.804 INFO: functions are set
23:39:39.804 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
23:39:39.881 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from saikuro
23:39:39.881 DEBUG: analyzing functions for classes in the file: application_controller.rb
23:39:39.881 INFO: functions are set
23:39:39.881 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
23:39:39.903 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from saikuro
23:39:39.914 DEBUG: analyzing functions for classes in the file: dashboard_controller.rb
23:39:39.914 INFO: functions are set
23:39:39.914 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
23:39:39.942 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from saikuro
23:39:39.960 INFO: COMPLEXITY are set[name: DashboardController#index complexity: 1 lines: 1]
23:39:39.960 INFO: File complexity 1
23:39:40.041 INFO: ------------------------------------------------------------------------
23:39:40.051 INFO: EXECUTION FAILURE
23:39:40.051 INFO: ------------------------------------------------------------------------
23:39:40.052 INFO: Total time: 20.490s
23:39:40.156 INFO: Final Memory: 50M/120M
23:39:40.156 INFO: ------------------------------------------------------------------------
23:39:40.156 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: Metric 'function_complexity' should not be computed by a Sensor
    at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:248)
    at org.sonar.scanner.index.DefaultIndex.addMeasure(DefaultIndex.java:155)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:150)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:145)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyzeFile(MetricfuComplexitySensor.java:155)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyse(MetricfuComplexitySensor.java:118)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:87)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:81)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:67)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:75)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:259)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:254)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
23:39:40.181 DEBUG: Execution getVersion
23:39:40.181 DEBUG: Execution stop
ERROR: SonarQube scanner exited with non-zero code: 1
jhgjhtuytdfbnfvmnbgjtuydt commented 7 years ago

Hi

Got this solved by disabling Saikuro tests on .metrics file

MetricFu.configuration.configure_metrics.each do |metric|
  if [:saikuro].include?(metric.name)
    metric.enabled = false
  end
end

Thanks for the work, @hersonalfaro

philCryoport commented 7 years ago

To the maintainers:

Would you please update this to at least handle the current LTS of SonarQube (5.6.7)?

jhgjhtuytdfbnfvmnbgjtuydt commented 7 years ago

Hi,

I am having issues with the cane sensor this time. Someone / @hersonalfaro, any chance or free time to have a look at this?

or if you give me clues about where the issue may be (code line and file), I can have a look.

Thank you

The error is:

16:33:07.872 INFO: Sensor RubySensor [ruby] (done) | time=2036ms
16:33:07.872 INFO: Sensor org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor [ruby]
16:33:07.872 INFO: Calling analyse for report results: /var/lib/jenkins/workspace/t/staging/BE-deployment/tmp/metric_fu/report.yml
16:33:07.872 DEBUG: analyzing functions for classes in the file: channel.rb
16:33:07.872 INFO: functions are set
16:33:07.872 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.159 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.159 DEBUG: analyzing functions for classes in the file: connection.rb
16:33:08.160 INFO: functions are set
16:33:08.160 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.243 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.245 DEBUG: analyzing functions for classes in the file: base_controller.rb
16:33:08.245 INFO: functions are set
16:33:08.245 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.274 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.274 DEBUG: analyzing functions for classes in the file: users_controller.rb
16:33:08.274 INFO: functions are set
16:33:08.274 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.348 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.348 DEBUG: analyzing functions for classes in the file: application_controller.rb
16:33:08.348 INFO: functions are set
16:33:08.372 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.406 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.406 DEBUG: analyzing functions for classes in the file: dashboard_controller.rb
16:33:08.406 INFO: functions are set
16:33:08.406 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.423 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.423 DEBUG: analyzing functions for classes in the file: application_helper.rb
16:33:08.423 INFO: functions are set
16:33:08.423 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.428 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.428 DEBUG: analyzing functions for classes in the file: sendgrid_helper.rb
16:33:08.428 INFO: functions are set
16:33:08.428 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
16:33:08.460 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
16:33:08.461 DEBUG: analyzeCane: fileInfoToWorkWith - {:file=app/helpers/sendgrid_helper.rb, :method=SendgridHelper#send, :complexity=17}
16:33:08.470 INFO: COMPLEXITY are set[name: SendgridHelper#send complexity: 17 lines: 0]
16:33:08.470 INFO: File complexity 17
16:33:08.539 INFO: ------------------------------------------------------------------------
16:33:08.539 INFO: EXECUTION FAILURE
16:33:08.539 INFO: ------------------------------------------------------------------------
16:33:08.539 INFO: Total time: 18.560s
16:33:08.639 INFO: Final Memory: 49M/117M
16:33:08.639 INFO: ------------------------------------------------------------------------
16:33:08.639 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: Metric 'function_complexity' should not be computed by a Sensor
    at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:248)
    at org.sonar.scanner.index.DefaultIndex.addMeasure(DefaultIndex.java:155)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:150)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:145)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyzeFile(MetricfuComplexitySensor.java:155)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyse(MetricfuComplexitySensor.java:118)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:87)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:81)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:67)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:75)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:259)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:254)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
16:33:08.640 DEBUG: Execution getVersion
16:33:08.658 DEBUG: Execution stop
hersonalfaro commented 7 years ago

@jhgjhtuytdfbnfvmnbgjtuydt I will take a look at it this soon, do you the files to replicate this problem?

jhgjhtuytdfbnfvmnbgjtuydt commented 7 years ago

@hersonalfaro ,

The error trace is:

22:15:30.246 DEBUG: MetricfuComplexityYamlParserImpl: Start start parse of metrics_fu YAML
22:15:30.273 DEBUG: MetricfuComplexityYamlParserImpl: parsing results from cane
22:15:30.282 DEBUG: analyzeCane: fileInfoToWorkWith - {:file=app/helpers/sendgrid_helper.rb, :method=SendgridHelper#send, :complexity=17}
22:15:30.282 INFO: COMPLEXITY are set[name: SendgridHelper#send complexity: 17 lines: 0]
22:15:30.282 INFO: File complexity 17
22:15:30.392 INFO: ------------------------------------------------------------------------
22:15:30.392 INFO: EXECUTION FAILURE
22:15:30.392 INFO: ------------------------------------------------------------------------
22:15:30.392 INFO: Total time: 20.981s
22:15:30.527 INFO: Final Memory: 49M/116M
22:15:30.527 INFO: ------------------------------------------------------------------------
22:15:30.527 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: Metric 'function_complexity' should not be computed by a Sensor
    at org.sonar.scanner.sensor.DefaultSensorStorage.saveMeasure(DefaultSensorStorage.java:248)
    at org.sonar.scanner.index.DefaultIndex.addMeasure(DefaultIndex.java:155)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:150)
    at org.sonar.scanner.deprecated.DeprecatedSensorContext.saveMeasure(DeprecatedSensorContext.java:145)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyzeFile(MetricfuComplexitySensor.java:155)
    at org.sonar.plugins.ruby.metricfu.MetricfuComplexitySensor.analyse(MetricfuComplexitySensor.java:118)
    at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:87)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:81)
    at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:67)
    at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:75)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:178)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:259)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:254)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:144)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:129)
    at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233)
    at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
    at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
22:15:30.528 DEBUG: Execution getVersion
22:15:30.530 DEBUG: Execution stop
ERROR: SonarQube scanner exited with non-zero code: 1
[DRY] Skipping publisher since build result is FAILURE
[BRAKEMAN] Skipping publisher since build result is FAILURE
Publishing rails stats report...
Build did not succeed and the project is configured to only push after a successful build, so no pushing will occur.
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Sending build status FAILED for commit 73362aa5e633784919b1f2cd074f2e67bb1a4866 to BitBucket is done!
Finished: FAILURE

The file that triggers the error seems to be app/helpers/sendgrid_helper.rb,

the contents of app/helpers/sendgrid_helper.rb are:

require 'sendgrid-ruby'

module SendgridHelper
  include SendGrid
  def send(template_id, receipient_ids, subject, personalization)
    sendgrid = YAML.load_file("#{Rails.root}/config/sendgrid.yml")

    mail = Mail.new
    mail.from = Email.new(email: 'contact@thatch.ie')
    mail.subject = subject
    mail.add_personalization(personalization)
    mail.template_id = sendgrid[Rails.env][template_id.to_s]
    sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
    begin
      response = sg.client.mail._("send").post(request_body: mail.to_json)
    rescue Exception => e
      puts e.message
    end
  end
end

The installed sonarQube information is:

system_info system_info system_info system_info system_info system_info

the .metric file is like so:

MetricFu.configuration.configure_metrics.each do |metric|
  if [:cane].include?(metric.name)
    metric.enabled = true
    metric.abc_max = 15
    metric.line_length = 80
    metric.no_doc = 'y'
    metric.no_readme = 'y'
  end
  if [:churn].include?(metric.name)
    metric.enabled = false
    metric.ignore_files = 'HISTORY.md, TODO.md'
    metric.start_date = '6 months ago'
  end
  if [:flay].include?(metric.name)
    metric.enabled = false
  end
  if [:flog].include?(metric.name)
    # this one fails in ruby
    metric.enabled = false
  end
  if [:roodi].include?(metric.name)
    metric.enabled = false
  end
  if [:reek].include?(metric.name)
    metric.enabled = false
  end
  if [:saikuro].include?(metric.name)
    metric.enabled = false
  end
  if [:rails_best_practices].include?(metric.name)
    metric.enabled = false
    # metric.exclude = ["config/chef"]
  end
end

lastly, the sonar-project.properties file is:

# Project identification
sonar.projectKey=rails-backend
sonar.projectVersion=0.0.1
sonar.projectName=Rails project

# Info required for Sonar
sonar.sources=.
#sonar.tests=spec # optional and the folder can be 'spec' or 'test' due to testing framework used.

# Multi-language/languaje-detection by commenting out next line
# Ser Backend language to ruby-only
sonar.language=ruby

sonar.sourceEncoding=UTF-8

# Info required for Sonar
sonar.simplecovrcov.reportPath=coverage/.resultset.json
sonar.metricfu.reportPath=tmp/metric_fu/report.yml

sonar.zaproxy.reportPath=${WORKSPACE}/zaproxy-report.xml

sonar.exclusions=**/tmp/**,**/bin/**,**/vendor/**.**/log/**

Thanks

daguero commented 6 years ago

I need ruby-sonar-plugin version to support in sonar 6.6 or 6.7, any idea??????

axel3rd commented 6 years ago

SonarQube v6 is now the LTS => will be massively used and previous versions abandoned (not supported, ...). This plugin is the most known for Ruby and referenced in SonarQube plugins contribution. It's too bad it doesn't work with LTS version (NoClassDefFoundError: org/sonar/api/web/CodeColorizerFormat at startup) 🙁.