In the last week or so we’ve started to see sonar firing issues on unchanged lines of code in our github PRs. This happens only on files that were touched. I tried changing the project’s definition of new code from the default since-last-version to 7 days, which did not affect this behavior.
(This is a private repo so I can’t share the details.)
Sonar is triggered by a github action:
name: Sonarcloud (with coverage reporting)
on:
workflow_call:
inputs:
COVERAGE_FILENAME:
description: The name of the coverage file to download. Defaults to "code-coverage-report".
type: string
required: false
default: "code-coverage-report"
WORKING_DIRECTORY:
description: Path to the directory/project the analysis should be conducted on.
type: string
required: false
default: "."
jobs:
sonarcloud:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Download code coverage results
uses: actions/download-artifact@v4
with:
name: ${{inputs.COVERAGE_FILENAME}}
path: bin
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v6
with:
projectBaseDir: ${{ inputs.WORKING_DIRECTORY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
properties file (redacted):
sonar.projectKey=REDACTED
sonar.organization=REDACTED
sonar.projectName=REDACTED
sonar.language=go
sonar.sources=.
sonar.exclusions=**/cmd/**/main.go, **/testutils/**, **/integration_tests/**, **/synthetic.go, **/mock/*.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.tests.reportPaths=/home/runner/work/REDACTED/bin/coverage.out
sonar.go.coverage.reportPaths=/home/runner/work/REDACTED/bin/coverage.out
sonar.sourceEncoding=UTF-8
thanks!
