Phony targets in compile_commands.json confusing sonarlint

Please provide

  • Operating system: Win10
  • SonarLint plugin version: v3.22.0
  • Programming language you’re coding in: C
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): SonarQube Enterprise Edition
      Version 9.9 (build 65466)

And a thorough description of the problem / question:

We have an compile_commands.json with some phony targets that we need for our setup ( The Ninja build system ) this confuses SonarLint to not do any analysis.
If we remove the phony targets then its working ok but we would like to not do that as it makes things needlessly complicated, needing a special compile_commands.json just for SonarLint. Problem seems to be with empty command lines like this “command”: “”, in compile_commands.json

Hey there.

Can you upload a sample compile_commands.json file showing off these phony targets?

Here is a snippet of the problematic ones

{
    "directory": "C:\\src\\product1",
    "command": "",
    "file": "C:/src/product1/build/binaries/firmware",
    "output": "firmware"
  },
  {
    "directory": "C:\\src\\product1",
    "command": "",
    "file": "C:/src/product1/build/binaries/firmware",
    "output": "fw"
  },
  {
    "directory": "C:\\src\\product1",
    "command": "",
    "file": "C:/src/product1/build/BOOT.BIN",
    "output": "bootloader"
  },

Hi @FrejSuomi ,

thank you for your report, I created a ticket to ignore those entries: CPP-4779.

While waiting for the fix you should modify the JSON to drop those entries or by providing a non-empty command, you could find and replace in the file "command": "", with something like "command": "true", .

2 Likes

Thanks for the quick response and ticket.

1 Like