SonarLint VSCode does not scan files in one project

Please provide

  • Operating system: Mac OS
  • SonarLint plugin version: v4.9.1
  • Programming language you’re coding in: go
  • Is connected mode used: yes and no, with same result
    • Connected to SonarCloud or SonarQube (and which version): SonarQube 9.9.4

And a thorough description of the problem / question:
Works with one project, not another. Opening any file that should be scanned (go, yaml) shows an empty list of inputFiles and logically then an Error that there are no files to analyze. How would one project be excluded?

log output:

[Debug - 18:16:31.103] Fetching global configuration
[Debug - 18:16:31.108] Fetching configuration for folder 'file:///<redacted-base-dir>'
[Debug - 18:16:31.110] Global settings updated: WorkspaceSettings[analysisExcludes=,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store,**/Thumbs.db,connections={<default>=ServerConnectionSettings[connectionId=<default>,disableNotifications=false,organizationKey=<null>,serverUrl=<redacted-server-url>]},disableTelemetry=false,excludedRules=[],focusOnNewCode=false,includedRules=[],pathToNodeExecutable=,ruleParameters={},showAnalyzerLogs=true,showVerboseLogs=true]
[Debug - 18:16:52.591] Computing file exclusion for uri 'file:///<redacted-base-dir>/main.go'
[Info - 18:16:52.602] Triggering analysis with configuration: [
baseDir: <redacted-base-dir>
extraProperties: {sonar.cs.file.suffixes=.cs, sonar.cfamily.compile-commands=, sonar.cs.internal.loadProjectsTimeout=60, sonar.cs.internal.useNet6=true, sonar.cs.internal.loadProjectOnDemand=false}
activeRules: [<omitted long list including go rules>]
inputFiles: []
]
[Error - 18:16:52.602] No file to analyze

Hello :wave: welcome to the community! And thanks for your question.

Could you please enable verbose logging for SonarLint and share a more detailed log output?

Additionally, would you be willing to share the .gitignore file(s) (if any) for the excluded project? I’m suspecting that this known issue may be at play here.

Thank you for the hint. Indeed there is a .gitignore entry to ignore the binary when it is compiled locally, which happens to match the name of the directory containing the checked-out code.
For example: base-dir is /Users/user/src/myprogram and compiling locally results in file /Users/user/src/myprogram/myprogram. The .gitignore file has the line myprogram to exclude the locally compiled binary, which is misunderstood by sonarlint to exclude all files within the myprogram directory.

As a workaround: changing the .gitignore line to /myprogram allows me to ignore the file with git while having sonarlint functioning as expected.

Thanks for your timely response!

1 Like

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