Code linting using SonarLint VSCode extension

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Code linting using SonarLint VSCode extension

Postby zazas321 » Tue Jul 25, 2023 8:13 am

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 6136 times

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Code linting using SonarLint VSCode extension

Postby ESP_igrr » 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?

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: Code linting using SonarLint VSCode extension

Postby zazas321 » Wed Jul 26, 2023 4:26 am

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

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Code linting using SonarLint VSCode extension

Postby ESP_igrr » 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.

zazas321
Posts: 231
Joined: Mon Feb 01, 2021 9:41 am

Re: Code linting using SonarLint VSCode extension

Postby zazas321 » Wed Jul 26, 2023 8:25 am

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?

Who is online

Users browsing this forum: No registered users and 52 guests