Old ESLint smell from 2 years ago showing up in a new PR as a smell

Error seen in the screen shot:

As you can see, the issue is 2 years old as reported by Sonar. However, when my co-worker did a pull request and we ran the sonar difference, the old smell is being reported on the new PR despite the line in question not being changed.

I feel like we have been seeing this happen for at least a month now, but we did not see it in the past, so it seems like something has changed recently that is treating old smells in touched files to be reported in new branches that have not changed those lines of code.

So I opened our main branch (named “dev”) and I opened the file in question. I see that the line of code does not have the smell. I re-ran our eslint command locally that we run on our build machines and I do see that smell in the JSON report file it produced.

The eslint report file is 17mb, I’m not sure if the size could be an issue? I’m not sure what else to look at to find out the potential problem. We run the same eslint command in both sonar scanner executions.

Any thoughts on why our main build is showing some eslint smells, but missing a majority of them while our branch builds are seeing all the smells reported by eslint?

Branch command:

pnpm run lint --format=json --output-file ./test-results/eslint.report.json

export client_source_dir=${nw_client_dir}/client-source

cs_file=${client_source_dir}/test-results/eslint.report.json
export SONAR_SCANNER_OPTS="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"
pnpm exec sonar-scanner \
  -Dproject.settings=${nw_client_dir}/sonar-project.properties \
  -Dsonar.pullrequest.branch=${GITHUB_PR_SOURCE_BRANCH} \
  -Dsonar.pullrequest.key=${GITHUB_PR_NUMBER} \
  -Dsonar.pullrequest.base=${GITHUB_PR_TARGET_BRANCH} \
  -Dsonar.pullrequest.provider=nextworld-tools \
  -Dsonar.pullrequest.github.repository=nw-client \
  -Dsonar.typescript.internal.typescriptLocation=${nw_client_dir}/node_modules/typescript/lib \
  -Dsonar.javascript.lcov.reportPaths=${client_source_dir}/test-results/coverage/lcov.info \
  -Dsonar.eslint.reportPaths=${cs_file}

Main branch job:

pnpm run lint --quiet --format=json --output-file ./test-results/eslint.report.json

export client_source_dir=${nw_client_dir}/client-source

cs_file=${client_source_dir}/test-results/eslint.report.json

pnpm exec sonar-scanner \
  -Dproject.settings=${nw_client_dir}/sonar-project.properties \
  -Dsonar.pullrequest.name=${branchName} \
  -Dsonar.pullrequest.target=${branchName} \
  -Dsonar.typescript.internal.typescriptLocation=${nw_client_dir}/node_modules/typescript/lib \
  -Dsonar.javascript.lcov.reportPaths=${client_source_dir}/test-results/coverage/lcov.info \
  -Dsonar.eslint.reportPaths=${cs_file}

May not be related at all, but we have also had a couple of smells in Typescript code saying imports were unused, but they are definitely used. Only seen as far as I know in the last couple of days

Hi,

Could you provide an analysis log from the main branch and one from a PR where an old issue showed up as new?

Also, just to be sure, you do re-analyze main on a regular basis, right?

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