The rule 'OCLint:ivar assignment outside accessors or init' does not exist

1.1k Views Asked by At

I am trying to integrate SonarQube to generate report on my iOS project,

I am using Objective-C Sonar plugin

When i run ./run-sonar.sh

OCLint generates a compile_commands.json file in my root directory.

and after that getting following error

11:24:39.782 INFO  - Processing OCLint report /Users/.......app/./sonar-reports/oclint.xml
11:24:39.899 ERROR - Reporting 1073 violations.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 16.240s
Final Memory: 6M/86M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: The rule 'OCLint:ivar assignment outside accessors or init' does not exist.

Can any one help me on this issue? Thanks AMR

Thnaks

3

There are 3 best solutions below

0
On

I am not sure what version of the objective-c-sonar plugin that you were using. I solved similar issue before.

Goto ${SONAR_INSTALLATION_FOLDER}/extensions/plugins/, copy the sonar-objective-c-plugin-${version}.jar to somewhere else.

unzip the jar file, and edit below file org/sonar/plugins/objectivec/profile-oclint.xml
Add the rule you are missing following the layout of the xml file,
may be look similar below

    <rule> 
        <repositoryKey>OCLint</repositoryKey>
        <key>ivar assignment outside accessors or init</key>
    </rule> 

And edit another file org/sonar/plugins/objectivec/rules-oclint.xml

<rule> 
    <key>ivar assignment outside accessors or init</key>
    <name>ivar assignment outside accessors or init</name>
    <priority>MAJOR</priority>
    <description>ivar assignment outside accessors or init</description>
</rule>

And then using zip to package the files unpacked as the new jar file. Override the original plugin jar file in ${SONAR_INSTALLATION_FOLDER}/extensions/plugins/, restart the sonar, issue could be gone.

Repeat the step for all similar issues you encountered.

0
On

I had a similar error. My sonar server had two objective-c code analyser plugin. The Sonar Plugin for Objective C (free) and SonarSource Objective-C plugin (commercial)

When I removed (uninstalled) one of the plugin from sonar server the error stopped to occur

0
On

I had a similar error too with the last version of this plugin which is a fork of the one you used. I downgrade my OCLint version from 0.11 to 0.10.1 and everything work perfectly. It seems that the OCLint rules defined in the plugin was different of the OCLint version installed on my server.