SonarCloud is detecting code smells and bugs

SonarCloud is detecting code smells and bugs from 3 to 4 years old code for a new PR.

Current changes include 30 additions and 11 deletions in the pull request but the reliability rating is C based on 2 bugs identified from 4 years ago. Also 2 code smells are identified from 4 years ago.

Unable to resolve.

Hi @MANOJPATRA1991, welcome to our community!

Is this project a public one, in order to tell us the URL of it?
Can you copy and paste the logs from the scanner output here?
Did you changed anything regarding the quality gate/profile configuration for this project?
Additionally, could you please tell us the new code configuration for your project and organization?

Hi @Alexandre_Holzhey ,

I can’t share URL as this project is a private one for the organisation I am working for.

The quality gate/profile configuration has been changed a few times in last couple of months to deploy features for the app and avoid sonar build fails due to this issue.

But here’s the code configuration:

sonar.projectKey=${PROJECT_KEY}
sonar.organization=${ORG}
sonar.projectName=${PROJECT_NAME}
sonar.sources=src
sonar.tests=src
sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarcloud.io
sonar.login=${SONAR_TOKEN}
sonar.exclusions=**/*.spec.ts
sonar.test.inclusions=**/*.spec.ts
sonar.inclusions=**/*.ts
sonar.typescript.lcov.reportPaths=${PROJECT_PATH}/coverage/lcov.info

Thanks for your reply @MANOJPATRA1991. Unfortunately, the provided information did not help that much. This is happening only in a single PR or all PRs? About the quality profile, can you tell me if any rule is related to the code smells and bugs that were raised? If yes, please tell us the rules/conditions and when they were changed last time. Since your project is not public we really need more information to try understand your issue, so the scanner logs and the new code configuration are required for further investigations.

Hi @Alexandre_Holzhey, can you guide me on how to download the scanner logs? I am not sure where the menu for this is located at.

Thanks,
Manoj

Sure!

Just got to your project view (something like https://sonarcloud.io/dashboard?id=alexandre-holzhey-sonarsource_laravel), then in the Administration menu click on Background Tasks:

image

You will get a list of recent analysis with respective IDs:

Just pick an ID form a related scan (that is reporting the CS and bugs as you told us).

Hi Alexandre, sorry for the delay in response, Had 2 busy weeks. Please find the details here, let me know if this helps:


Import statements being detected.

Whitespaces and constructor arguments detected here from code written in 2017.

Spec files are showing up in the list of files on sonar.

It happens for most PRs. Quality profile is set to default Sonar way.

Number of days (All code that has changed in the last x days is considered new code) is set to 30 days.

Hi @MANOJPATRA1991 and thanks for the screenshots. Unfortunately they are showing what you told us already. To proper verify the related issue we need that analysis ID i asked before… could you please provide it?

Hi @Alexandre_Holzhey,

My organisation has asked to share any task related info as private message only. Is it fine if I share the analysis IDs with you via email or any other source? I tried sharing privately here but your profile seems to be not accessible for me from the community.

Thanks,
Manoj

@Alexandre_HolzheyI have already shared the IDs with you as you asked, wondering if you have found anything :roll_eyes:

Hi @MANOJPATRA1991. Unfortunately i was not able to find the logs for the analysis id you sent to me. That could happen since we keep the logs for 2 weeks. Do you still get those code smells and bugs in recent scans? If yes, can you send me the analysis id (and the date!) of one of them, please? You can reply to the private message as you did before.

Thanks and sorry about the delayed response!