Code duplications are not printing in sonarqube, why? need advise

  1. This is for iOS swift project, i have achieved code coverage and code smell details through slather, lizard and swiftlint.
    my question is, we have code duplication but why sonarqube is not displaying the data in duplication block? its shows 0% . i have attached screenprint for reference. please address this.

log:
CPD Executor Calculating CPD for 0 filese[0m
[12:54:34]: ▸ e[35mINFO: CPD Executor CPD calculation finished (done) | time=0mse[0m

  1. also for code smell while using swiftlint ,

swiftlint(path: “.”, output_file: “sonar-reports/swiftlint.txt”, ignore_exit_status: true),

we are seeing results published in sonarqube
but if we give below output as .json, no datas are displaying.

swiftlint(path: “.”, output_file: “sonar-reports/swiftlint.json”, reporter: “sonarqube”, ignore_exit_status: true)

(i referred from swiftlint and sonarqube documentation and created this command)


image

Hi,

Off-hand this looks like maybe there’s a blanket duplications exclusion in place.

If you check Project Settings → Background Tasks → [row dots menu] → Show Scanner Context for sonar.cpd.exclusions that should either confirm or rule out the theory.

If there is one then it’s time to figure out where it’s being set and remove it.

 
HTH,
Ann

Hey Ann, that sonar.cpd.exclusions property is not even set in sonar-project.properties file.

whether if we give or dont set, will sonarqube checks and prints data for duplication block?

how this works for swift projects?

i even set the property dummy to see whether it runs cpd checks, but it didnt.

eg: sonar.cpd.exclusions=DerivedData

Unfortunately it didnt print any data, also intentionally added duplicate lines in code, but still no % spotted.

Hi,

Can you provide your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hey Ann,

i have attached analysis log here. i have made some changes which contain org details, but other details are same.

please help on this Ann…

we have android and iOS platform… android kotlin works perfectly with all these stat including duplication, code smell etc…
only for iOS swift projects, we are facing so much problems.

sonar-properties.txt (1.2 KB)
sonarlog.txt (11.2 KB)

Hi,

[02:15:53]: INFO: Analyzing on SonarQube server 8.9.6

I can’t help you.

Your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

8.9.6 → 9.9.4 → 10.4 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

If your error persists after upgrade, please come back to us.

 
Ann

Hi Ann, updated to 9.9 LTS, still same problem

sonarlognew.txt (10.2 KB)

Hi,

From this log, it looks like you’re analyzing Swift code in SonarQube Community Edition using a 3rd-party plugin?

[11:21:37]: ▸ INFO: Sensor SwiftLint [backelitesonarswiftplugin]
[11:21:37]: ▸ INFO: Processing SwiftLint report sonar-reports/swiftlint.txt
[11:21:37]: ▸ INFO: Load project repositories
[11:21:37]: ▸ INFO: Load project repositories (done) | time=8ms
[11:21:37]: ▸ INFO: Sensor SwiftLint [backelitesonarswiftplugin] (done) | time=174ms
[11:21:37]: ▸ INFO: Sensor Tailor [backelitesonarswiftplugin]
[11:21:37]: ▸ INFO: Sensor Tailor [backelitesonarswiftplugin] (done) | time=1ms
[11:21:37]: ▸ INFO: Sensor Swift Squid [backelitesonarswiftplugin]
[11:21:40]: ▸ WARN: Metric 'lines' is an internal metric computed by SonarQube/SonarCloud. Provided value is ignored.
[11:21:43]: ▸ INFO: Sensor Swift Squid [backelitesonarswiftplugin] (done) | time=5405ms

If so, you’ll need to talk to its maintainers about why analysis doesn’t see any files to calculate duplications on:

[11:23:55]: ▸ INFO: CPD Executor Calculating CPD for 0 files
[11:23:55]: ▸ INFO: CPD Executor CPD calculation finished (done) | time=0ms

 
HTH,
Ann

Hey Ann,

we have 2 projects… we ran one another seperately to see its stat for duplication, we got duplication stat for 1 project and didnt get dupl block stat for another project.
strange

Hi,

That doesn’t change my earlier answer.

 
Ann

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.