yoctoproject / vscode-bitbake

Bitbake language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake
Other
39 stars 9 forks source link

shellcheck fails to resolve some variables in bitbake recipes #221

Open jrmejiaa opened 2 months ago

jrmejiaa commented 2 months ago

Hi all,

First of all, thanks for the awesome extension, I use it all the time. This is something small, but I would like to know if there is possible to find a workaround.

Current Behavior

The vscode-shellcheck extension uses the well-known shellcheck to give suggestions about writing shell scripting. I have been using both apps in the last days and I found out that when both extensions are enabled, the shellcheck extension recognizes the bitbake recipes as shell scripting but only the part wrap into a tasks like do_install.

This produces a problem because a task in bitbake can use user variables outside of the scope of a task to perform operations, and because the rest of the bitbake recipe is not taking into account by shellcheck, it throws a warning saying that the variable is not initialize

If I do not enable vscode-bitbake this would not happen and therefore I would not get any warning from shellcheck.

Possible solution

The vscode-shellcheck extension has a setting to ignore certain patterns shellcheck.ignorePatterns but for some reason that I do not understand it is not working with the bitbake extensions. Therefore I think it is something to do with the settings in this extension.

Please let me know any of your thoughts, I decided to create an issue in this extensions because it happens only when I activate it. If you need more information I will post an update

Thanks.

idillon-sfl commented 2 months ago

Hello! Thank you for opening the issue.

Currently, you can scan the recipe for the file you're working on. It will find the occurrences of the variables in the recipe and make the warnings disappear.

You can trigger the scan simply by saving the file (if the option Parse On Save has not been deactivated), or by using the command BitBake: Scan Recipe.

I just got an idea to make the scan unnecessary for variables that are defined in the same file. I'll try to make it available soon.

jrmejiaa commented 2 months ago

Hi @idillon-sfl thank you for the fast answer!

Ohh ok, I normally have the Parse On Save deactivate because with big projects it takes several seconds and I want normally to test fast small changes. But kudos for the integration with shellcheck, I didn't knew that this was part of the extension. Thanks!

With the Parse On Save deactivate, I notice something. Even If I used the command BitBake: Scan Recipe or BitBake: Rescan Project the user variables defined in the file are not recognized. Only if the option Parse On Save is on, the variables are not longer have the warning.

As your message suggests, this should not be the behavior right?

Thanks for the awesome work 🤟🏼

idillon-sfl commented 2 months ago

I get the same problem. I'll investigate.