octo-technology / sonar-objective-c

Sonar Plugin for Objective C
517 stars 206 forks source link

No coverage or violations report data for v0.3 or v0.4 #72

Closed jamesreeve closed 9 years ago

jamesreeve commented 9 years ago

Hello,

I have been trying to get both v0.3 and 0.4 of your plugin working with Sonar but to no avail at all. I get the info on how many classes and it picks up changes when i put in code changes. But it claims there are no violations in the code but i even tried to put some in manually in the code to cause violations but they never get picked up.

I have tried running against different git projects too that I know do contain violations, but all come up with no violations and code coverage reports.

Let me know if you need anything else from me to help diagnose the issues I am getting.

First i will cover off what I have tried with version 0.4:

When i call run-sonar.sh -v i get:

`..
..
..
** CLEAN SUCCEEDED ** (3712 ms)
+ returnValue=0
+ set +x
+ xctool -workspace iOctocat.xcworkspace -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -scheme iOctocat -reporter json-compilation-database:compile_commands.json build
Skipping tests as no test scheme has been provided!
Running OCLint...
Path included in oclint analysis is: --include '.*/ioctocat/Classes'
+ oclint-json-compilation-database --include ''\''.*/ioctocat/Classes'\''' -- -max-priority-1 10000 -max-priority-2 10000 -max-priority-3 10000 -report-type pmd -o sonar-reports/oclint.xml
+ returnValue=0
+ set +x
Running SonarQube using SonarQube Runner
+ sonar-runner
SonarQube Runner 2.4
Java 1.7.0_17 Oracle Corporation (64-bit)
Mac OS X 10.9.5 x86_64
INFO: Runner configuration file: /usr/local/Cellar/sonar-runner/2.4/libexec/conf/sonar-runner.properties
INFO: Project configuration file: /Users/jimmy/ioctocat/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /Users/jimmy/ioctocat/./.sonar
INFO: SonarQube Server 4.5.2
23:04:46.185 INFO  - Load global referentials...
23:04:46.345 INFO  - Load global referentials done: 165 ms
23:04:46.356 INFO  - User cache: /Users/jimmy/.sonar/cache
23:04:46.367 INFO  - Install plugins
23:04:46.567 INFO  - Install JDBC driver
23:04:46.573 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
23:04:47.740 INFO  - Initializing Hibernate
23:04:49.560 INFO  - Load project referentials...
23:04:49.755 INFO  - Load project referentials done: 195 ms
23:04:49.755 INFO  - Load project settings
23:04:50.284 INFO  - Loading technical debt model...
23:04:50.300 INFO  - Loading technical debt model done: 16 ms
23:04:50.302 INFO  - Apply project exclusions
23:04:50.505 INFO  - -------------  Scan iOctocat
23:04:50.511 INFO  - Load module settings
23:04:50.736 INFO  - Language is forced to objc
23:04:50.737 INFO  - Loading rules...
23:04:51.173 INFO  - Loading rules done: 436 ms
23:04:51.193 INFO  - Configure Maven plugins
23:04:51.264 INFO  - Compare to previous analysis (2015-01-11)
23:04:51.271 INFO  - Compare over 30 days (2014-12-12, analysis of 2015-01-11 22:59:13.069)
23:04:51.271 INFO  - No quality gate is configured.
23:04:51.382 INFO  - Base dir: /Users/jimmy/ioctocat/.
23:04:51.383 INFO  - Working dir: /Users/jimmy/ioctocat/./.sonar
23:04:51.383 INFO  - Source paths: Classes
23:04:51.383 INFO  - Source encoding: UTF-8, default locale: en_US
23:04:51.383 INFO  - Index files
23:04:51.604 INFO  - 249 files indexed
23:04:52.323 INFO  - Quality profile for objc: OCLint
23:04:52.470 INFO  - Sensor QProfileSensor...
23:04:52.476 INFO  - Sensor QProfileSensor done: 6 ms
23:04:52.476 INFO  - Sensor ObjectiveCSquidSensor...
23:04:53.097 INFO  - Sensor ObjectiveCSquidSensor done: 621 ms
23:04:53.097 INFO  - Sensor Objective-C SurefireSensor...
23:04:53.097 INFO  - parsing sonar-reports
23:04:53.171 INFO  - Sensor Objective-C SurefireSensor done: 74 ms
23:04:53.171 INFO  - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@7252537b...
23:04:53.184 INFO  - Processing coverage report /Users/jimmy/ioctocat/./sonar-reports/coverage.xml
23:04:53.186 INFO  - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@7252537b done: 14 ms
23:04:53.186 INFO  - Sensor org.sonar.plugins.objectivec.violations.OCLintSensor@7ae6eadf...
23:04:53.186 INFO  - Processing OCLint report /Users/jimmy/ioctocat/./sonar-reports/oclint.xml
23:04:53.187 ERROR - Reporting 0 violations.
23:04:53.187 INFO  - Sensor org.sonar.plugins.objectivec.violations.OCLintSensor@7ae6eadf done: 1 ms
23:04:53.187 INFO  - Sensor InitialOpenIssuesSensor...
23:04:53.191 INFO  - Sensor InitialOpenIssuesSensor done: 4 ms
23:04:53.191 INFO  - Sensor ProjectLinksSensor...
23:04:53.195 INFO  - Sensor ProjectLinksSensor done: 4 ms
23:04:53.196 INFO  - Sensor VersionEventsSensor...
23:04:53.204 INFO  - Sensor VersionEventsSensor done: 8 ms
23:04:53.205 INFO  - Sensor FileHashSensor...
23:04:53.216 INFO  - Sensor FileHashSensor done: 11 ms
23:04:53.216 INFO  - Sensor CPD Sensor (wrapped)...
23:04:53.216 INFO  - DefaultCpdEngine is used for objc
23:04:53.224 INFO  - Cross-project analysis disabled
23:04:53.573 INFO  - Sensor CPD Sensor (wrapped) done: 357 ms
23:04:53.852 INFO  - Execute decorators...
23:04:55.268 INFO  - Store results in database
23:04:55.959 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/iOctocat
23:04:55.978 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
23:04:55.979 INFO  - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
23:04:55.987 INFO  - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
23:04:55.994 INFO  - -> Keep one snapshot per day between 2014-12-14 and 2015-01-10
23:04:55.995 INFO  - -> Keep one snapshot per week between 2014-01-12 and 2014-12-14
23:04:55.995 INFO  - -> Keep one snapshot per month between 2010-01-17 and 2014-01-12
23:04:55.996 INFO  - -> Delete data prior to: 2010-01-17
23:04:56.000 INFO  - -> Clean iOctocat [id=962]
23:04:56.007 INFO  - <- Clean snapshot 5059
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 10.711s
Final Memory: 12M/111M
INFO: ------------------------------------------------------------------------
+ returnValue=0
+ set +x

Then I have also tried v0.3 of the plugin:

When i call run-sonar.sh -v i get:

'..
..
..
** CLEAN SUCCEEDED ** (3683 ms)

+ returnValue=0
+ set +x

+ xctool -workspace iOctocat.xcworkspace -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -scheme iOctocat -reporter json-compilation-database:compile_commands.json build
+ returnValue=0
+ set +x
Skipping tests as no test scheme has been provided!
Running OCLint...
Path included in oclint analysis is: --include '.*/ioctocat/Classes'
+ oclint-json-compilation-database --include ''\''.*/ioctocat/Classes'\''' -- -max-priority-1 10000 -max-priority-2 10000 -max-priority-3 10000 -report-type pmd -o sonar-reports/oclint.xml
+ returnValue=0
+ set +x
Running SonarQube using SonarQube Runner
+ sonar-runner
SonarQube Runner 2.4
Java 1.7.0_17 Oracle Corporation (64-bit)
Mac OS X 10.9.5 x86_64
INFO: Runner configuration file: /usr/local/Cellar/sonar-runner/2.4/libexec/conf/sonar-runner.properties
INFO: Project configuration file: /Users/jimmy/ioctocat/sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: /Users/jimmy/ioctocat/./.sonar
INFO: SonarQube Server 3.7.4
23:09:47.787 INFO  - Load batch settings
23:09:47.896 INFO  - User cache: /Users/jimmy/.sonar/cache
23:09:47.900 INFO  - Install plugins
23:09:48.320 INFO  - Install JDBC driver
23:09:48.328 WARN  - H2 database should be used for evaluation purpose only
23:09:48.328 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
23:09:49.217 INFO  - Initializing Hibernate
23:09:51.522 INFO  - Load project settings
23:09:51.591 INFO  - Apply project exclusions
23:09:51.705 INFO  - -------------  Scan iOctocat
23:09:51.709 INFO  - Load module settings
23:09:51.996 INFO  - Quality profile : [name=OCLint,language=objc]
23:09:52.009 INFO  - Excluded tests: 
23:09:52.009 INFO  -   **/package-info.java
23:09:52.037 INFO  - Configure Maven plugins
23:09:52.082 INFO  - Compare to previous analysis (2015-01-11)
23:09:52.096 INFO  - Compare over 30 days (2014-12-12, analysis of 2015-01-11 21:53:29.555)
23:09:52.108 INFO  - Compare to previous version
23:09:52.163 INFO  - Base dir: /Users/jimmy/ioctocat/.
23:09:52.163 INFO  - Working dir: /Users/jimmy/ioctocat/./.sonar
23:09:52.163 INFO  - Source dirs: /Users/jimmy/ioctocat/Classes
23:09:52.163 INFO  - Source encoding: UTF-8, default locale: en_US
23:09:52.217 INFO  - Sensor ObjectiveCSourceImporter...
23:09:53.281 INFO  - Sensor ObjectiveCSourceImporter done: 1064 ms
23:09:53.281 INFO  - Sensor ObjectiveCSquidSensor...
23:09:53.702 INFO  - Sensor ObjectiveCSquidSensor done: 421 ms
23:09:53.702 INFO  - Sensor Objective-C SurefireSensor...
23:09:53.703 INFO  - parsing /Users/jimmy/ioctocat/./.sonar/build/surefire-reports
23:09:53.703 INFO  - Sensor Objective-C SurefireSensor done: 1 ms
23:09:53.703 INFO  - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@42d01e76...
23:09:53.711 INFO  - Processing coverage report /Users/jimmy/ioctocat/./sonar-reports/coverage.xml
23:09:53.782 INFO  - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@42d01e76 done: 79 ms
23:09:53.782 INFO  - Sensor org.sonar.plugins.objectivec.violations.OCLintSensor@6d7ff73e...
23:09:53.782 INFO  - Processing OCLint report /Users/jimmy/ioctocat/./sonar-reports/oclint.xml
23:09:53.786 ERROR - Reporting 0 violations.
23:09:53.786 INFO  - Sensor org.sonar.plugins.objectivec.violations.OCLintSensor@6d7ff73e done: 4 ms
23:09:53.786 INFO  - Sensor CpdSensor...
23:09:53.786 INFO  - SonarBridgeEngine is used
23:09:53.802 INFO  - Cross-project analysis disabled
23:09:54.267 INFO  - Sensor CpdSensor done: 481 ms
23:09:54.267 INFO  - Sensor InitialOpenIssuesSensor...
23:09:54.273 INFO  - Sensor InitialOpenIssuesSensor done: 6 ms
23:09:54.273 INFO  - Sensor ProfileSensor...
23:09:54.331 INFO  - Sensor ProfileSensor done: 58 ms
23:09:54.331 INFO  - Sensor ProfileEventsSensor...
23:09:54.351 INFO  - Sensor ProfileEventsSensor done: 20 ms
23:09:54.351 INFO  - Sensor ProjectLinksSensor...
23:09:54.357 INFO  - Sensor ProjectLinksSensor done: 6 ms
23:09:54.357 INFO  - Sensor VersionEventsSensor...
23:09:54.366 INFO  - Sensor VersionEventsSensor done: 9 ms
23:09:54.630 INFO  - Execute decorators...
23:09:57.016 INFO  - Store results in database
23:09:57.190 INFO  - ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/iOctocat
23:09:57.261 INFO  - Executing post-job class org.sonar.plugins.core.issue.notification.SendIssueNotificationsPostJob
23:09:57.262 INFO  - Executing post-job class org.sonar.plugins.core.batch.IndexProjectPostJob
23:09:57.331 INFO  - Executing post-job class org.sonar.plugins.dbcleaner.ProjectPurgePostJob
23:09:57.341 INFO  - -> Keep one snapshot per day between 2014-12-14 and 2015-01-10
23:09:57.342 INFO  - -> Keep one snapshot per week between 2014-01-12 and 2014-12-14
23:09:57.342 INFO  - -> Keep one snapshot per month between 2010-01-17 and 2014-01-12
23:09:57.342 INFO  - -> Delete data prior to: 2010-01-17
23:09:57.345 INFO  - -> Clean iOctocat [id=1]
23:09:57.349 INFO  - <- Clean snapshot 1
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 10.951s
Final Memory: 11M/113M
INFO: ------------------------------------------------------------------------
+ returnValue=0
+ set +x
zippy1978 commented 9 years ago

Hi,

What analysis profile do you use ? And does it contain rules ?

The plugin install the OCLint profile, Make sure that it is the one used by your projects.

jamesreeve commented 9 years ago

Hi i am using OCLint and yes it contains rules see screenshots here:

screen shot 2015-01-12 at 9 41 41 am

screen shot 2015-01-12 at 9 43 43 am

screen shot 2015-01-12 at 9 49 06 am

zippy1978 commented 9 years ago

Ok,

Could you show me your OCLint output file (in sonar-reports dir of your project) ?

cyrilpicat commented 9 years ago

I would complemtent the analysis with:

You can make a Gist with all those files.

That being said, your issue looks similar to #52. There was a mean to fix it suggested by Drew, but it was using a deprecated API (index). If we could get your help and design a proper fix, that would be great.

thanks,

rompic commented 9 years ago

what may also help and helped us during analysis of a similar issue: add the -X Flag to running sonar runner (maybe this could be combined with the -v flag in an adapted version of the sh file)

jamesreeve commented 9 years ago

Hi all, thanks for your fast responses. Lets try and fix this issue together :)

Glist with the files you were asking for: https://gist.github.com/1c950bade93dafe8f67b.git

rompic - I was unable to run sonar runner with a -X Flag, can you explain how i can do this? It did not recognise -X

cyrilpicat commented 9 years ago

regarding the test coverage being 0%, it's normal as you did not provide a test target. See the output log 'Skipping tests as no test scheme has been provided!'.

This has to be defined via the parameter 'sonar.objectivec.testScheme' in sonar-project.properties:

Scheme to build and run your tests (comment following line of you don't have any tests)

sonar.objectivec.testScheme=myApplicationTests

And regarding your Gist, I dont' know why but I do get a blank page. Is it working on your side?

jamesreeve commented 9 years ago

Hi, yes i have turned off the test coverage. At this stage I am only interested in the code violations.

git clone my repo and then you will have access to the files.

csibug commented 9 years ago

i think we are facing the same problem. can we somehow help to solve this issue? the oclint.xml generated by the run-sonar.sh is almost empty: <?xml version="1.0" encoding="UTF-8"?>

from the log this fragment seems relevant:

12:04:33.324 INFO - Sensor org.sonar.plugins.objectivec.violations.OCLintSensor@b89b904... 12:04:33.324 INFO - Processing OCLint report /Users/xzy/Desktop/Jenkins/workspace/myproject_ios/./sonar-reports/oclint.xml 12:04:33.324 ERROR - Reporting 0 violations.

we have tried the OCLint profile (63 Rules) and also the Sonar Way, and we set the Sonar Way profile to extend the OCLint profile, so we can use both of them at the same time.

test scheme also commented out from our sonar-project.properties.

cyrilpicat commented 9 years ago

OK, I get it, sorry for this regression introduced by the fix #64. The problem was on the OCLint command line generated by the run-sonar.sh script, not on the plugin part. It should work with an old run-sonar.sh, with both 0.3 and 0.4 plugin versions.

I committed a new run-sonar.sh, so if you update yours it should work again. Can you verify it?

Beware that when you update the plugin you should update both the plugin JAR AND run-sonar.sh (for all projects, or in a central place if you have it this way). I updated the documentation to make this clearer and recommend putting run-sonar.sh in a central place.

jamesreeve commented 9 years ago

Fantastic! it is all working for me now. Great work! I do however have issues with how run-sonar.sh is written when my sonar.sources contains spaces in the folder name.

I have just run the oclint rules and noticed that currently the library only has 2 rules in the major/blocker/critical rule list.

Do i have the latest copy of your rules? There these 2 rules the only ones you currently have for critical/blocker/major?

cyrilpicat commented 9 years ago

For the space issue, create a new issue and we will make sure to fix it