octo-technology / sonar-objective-c

Sonar Plugin for Objective C
517 stars 208 forks source link

Code duplication is not being analyzed for Objective-C #96

Closed zfattuhi closed 8 years ago

zfattuhi commented 8 years ago

Hi,

I am trying to setup sonar-objective-c, and I am unable to get the code duplication work. Env details:

OS - 10.10.5 Xcode - 6.4 SonarQube - 5.1.2 Sonar-runner - 2.4 sonar-objective-c - 0.4.0 Oclint version: 0.8.1

I ran the following:

  1. run-sonar.sh
  2. sonar-runner

I was testing the following code duplication (both methods in the same class):

-(void)copy{ int a = 20; int b = 30; int total = a + b; NSLog(@"Total is %i",total); }

-(void)copyDuplicate{ int a = 20; int b = 30; int total = a + b; NSLog(@"Total is %i",total); }

But getting 0 Duplication (no duplication) in Sonar Report. I checked the rules in Sonar for objective-C plugin but it didn't exist for 0.4 (could it be the reason?)

Any clue why its not detecting the duplication?

cyrilpicat commented 8 years ago

Hello,

thanks for your report.

There are some minimum values for a duplicate to be identified as such in SonarQube, I think your code simply doesn't reach it.

See http://docs.sonarqube.org/display/HOME/Duplications for more explanations and parametrization.

zfattuhi commented 8 years ago

You are absolutely right Cyril! Got it working now :)

Many thanks for the help