1
votes

I am trying to publish to Sonar using Gradle on a Java 8 project which is failing with the following error:

    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION FAILURE
    INFO: ------------------------------------------------------------------------
    Total time: 1:18.786s
    Final Memory: 25M/764M
    INFO: ------------------------------------------------------------------------
    ERROR: Error during Sonar runner execution
    ERROR: Unable to execute Sonar
    ERROR: Caused by: Rule 'squid:S1192' can not use 'Constant/issue' remediation function because this rule does not have a fixed remediation cost.

If I select my project to use the FindBugs quality profile then everything works and stats are uploaded to sonar. However if I turn on the sonar way profile the error above is thrown.

Looking at the error it seems it cannot find a remediation cost (which I think is required to work out how many days it will take to fix all tech debt)

I have tried uninstalling other plugins (JavaScript/Python/etc) and just leave Java. I have also tried tweaking the defaults in the Technical Debt settings. I have restored the default profiles also. All have had no effect.

I am using the following versions:

  • sonar 5.0.1 (application)
  • sonar-runner 2.4 (gradle plugin)
  • gradle 2.3
  • java 8 (project to analyse)
  • java plugin 3.1 (sonar plugin)

Does anyone have any ideas please?

3
Looks like that exception is thrown here But I'm not sure what you can do to get around it...tim_yates
Thanks @tim_yates. I'll look into what 'DebtRemediationFunction' type that rule is supposed to be and look into effortToFixDave Whittingham
Could you provide the version of the java plugin used ?benzonico
@benzonico - I have updated my question. ThanksDave Whittingham
Did you upgrade java plugin recently ? from which version ? it seems like the Sqale debt of this rule (S1192) is badly configured hence causing the issue you see. If you have sqale plugin you can update it from interface.benzonico

3 Answers

1
votes

I have managed to get the 4 problematic rules to work by doing the following:

The first tables shows the state of the database from a completely fresh install

╔═════════════╦════════════════════════════╦══════════════════════╗
║ PLUGIN_NAME ║      PLUGIN_RULE_KEY       ║ REMEDIATION_FUNCTION ║
╠═════════════╬════════════════════════════╬══════════════════════╣
║ squid       ║ MethodCyclomaticComplexity ║ (null)               ║
║ squid       ║ S1067                      ║ (null)               ║
║ squid       ║ S1192                      ║ (null)               ║
║ squid       ║ S135                       ║ (null)               ║
╚═════════════╩════════════════════════════╩══════════════════════╝

This table show the state of the database from a fresh install pointing to a cloned database and running the /setup URL.

NOTE: This is still a fresh install and in a new directory so the /es directory will not exist Step 3 followed here

╔═════════════╦════════════════════════════╦══════════════════════╗
║ PLUGIN_NAME ║      PLUGIN_RULE_KEY       ║ REMEDIATION_FUNCTION ║
╠═════════════╬════════════════════════════╬══════════════════════╣
║ squid       ║ MethodCyclomaticComplexity ║ CONSTANT_ISSUE       ║
║ squid       ║ S1067                      ║ CONSTANT_ISSUE       ║
║ squid       ║ S1192                      ║ CONSTANT_ISSUE       ║
║ squid       ║ S135                       ║ CONSTANT_ISSUE       ║
╚═════════════╩════════════════════════════╩══════════════════════╝

To solve this I had set the values in the REMEDIATION_FUNCTION back to null and the rules now work.

update rules
set remediation_function = null
where plugin_name = 'squid'
and plugin_rule_key in ('MethodCyclomaticComplexity', 'S1192', 'S135', 'S1067')
1
votes

When upgrading from SonarQube 4.3 or before, the technical debt definitions of the rules MUST be reset :

Without the SQALE plugin :

  • Execute the SQL query : "UPDATE rules SET characteristic_id=NULL, remediation_function=NULL, remediation_coeff=NULL, remediation_offset=NULL WHERE characteristic_id IS NOT NULL;"
  • Remove the data/es folder (if exists)
  • Restart your server.

With the SQALE plugin :

  • Go to the update center and install the SQALE plugin (if not already installed)
  • Go to the 'Back Up Model' page (Settings -> SQALE -> Back Up / Restore)
  • In the Restore Model section, click on the 'Restore' button -> your quality model will be reset, all overridden rules technical debt definitions will be reset.
  • Go to the update center and uninstall the SQALE plugin (if it was not installed before).

This ticket https://jira.codehaus.org/browse/SONAR-5056 is at the origin of this required change.

0
votes

I have the same problem after update from version 4.2 to 4.5.4. To continue my project analysis I had to deactivate following rules:

  • squid:MethodCyclomaticComplexity
  • squid:S1192
  • squid:S135

All of them throws "can not use 'Constant/issue' remediation function because this rule does not have a fixed remediation cost" error.

My installation use Java 8, sonar-runner 2.4 and following plugins:

  • sonar-checkstyle-plugin-2.2.jar
  • sonar-findbugs-plugin-3.2.jar
  • sonar-java-plugin-3.1.jar
  • sonar-javascript-plugin-2.4.jar
  • sonar-ldap-plugin-1.4.jar
  • sonar-scm-activity-plugin-1.8.jar