Page 1 of 1

Code linting using SonarLint VSCode extension

Posted: Tue Jul 25, 2023 8:13 am
by zazas321
Hello. To make projects look more clean we use SolarLint extension that helps us prevent silly mistakes.

One of the issues I notice is that I am getting frequent warnings such as:

Code: Select all


	 "call to undeclared function 'gpio_set_level'; ISO C99 and later do not support implicit function declarations",
Even though I have include:

Code: Select all

 #include "driver/gpio.h"
 


Can someone help me understand what could be the issue and why it is not working properly?
linting_issue.png
linting_issue.png (47.74 KiB) Viewed 6180 times

Re: Code linting using SonarLint VSCode extension

Posted: Tue Jul 25, 2023 11:18 am
by ESP_igrr
Just to check, have you specified sonarlint.pathToCompileCommands setting? If you run the linter from the CLI, do you get the same error reported?

Re: Code linting using SonarLint VSCode extension

Posted: Wed Jul 26, 2023 4:26 am
by zazas321
ESP_igrr wrote:
Tue Jul 25, 2023 11:18 am
Just to check, have you specified sonarlint.pathToCompileCommands setting? If you run the linter from the CLI, do you get the same error reported?
After downloading SonarLint extension, I havent configured anything, I was under impression it should work right out of the box.


Regarding the CLI, after a quick google search I havent found a way to run it from the CLI.


It is very strange because for example it does not complain about esp_deep_sleep_start() function so it seems to detect something. But I cannot wrap my head around why it wouldnt detect gpio functions

Re: Code linting using SonarLint VSCode extension

Posted: Wed Jul 26, 2023 6:22 am
by ESP_igrr
In that case, please try configuring that option. Otherwise sonarLint can't find the paths where to search for the header files.
compile_commands.json file should be generated in build/ directory of your project.

Re: Code linting using SonarLint VSCode extension

Posted: Wed Jul 26, 2023 8:25 am
by zazas321
ESP_igrr wrote:
Wed Jul 26, 2023 6:22 am
In that case, please try configuring that option. Otherwise sonarLint can't find the paths where to search for the header files.
compile_commands.json file should be generated in build/ directory of your project.


You were right. That was totally the issue.

I have went into SolarLint settings and noticed that it is refering to wrong compile_commands.json file:

Code: Select all

${workspaceFolder}\build\bootloader\compile_commands.json
instead, I have replaced it with

Code: Select all

${workspaceFolder}\build\compile_commands.json


And now it is working properly. Thanks for helping me out. Just out of curiosity though - what are the differences between build/bootloader/compile_commands.json and build/compile_commands.json?