pantajoe / vscode-elixir-credo

VSCode support for Elixir Linter 'Credo'.

Home Page:https://marketplace.visualstudio.com/items?itemName=pantajoe.vscode-elixir-credo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for project subdirectories

Pavinati opened this issue · comments

Right now this extension only works if I open the elixir directory as the root directory of the vscode workspace.
It will be helpful to have a configuration setting that allows me to define in which subdirectory the elixir root folder is.
The problem arises when I have to work both at the frontend and backend at the same time.

So, you have a multi-folder workspace? That's weird then, because for me it works, and I added support for this a while ago.
What does your setup look like and what error messages or warnings do you get?

@Pavinati Any updates on this?

I actually stopped to use this extension and now i just launch mix credo from the terminal.
My setup was the following:

  • A root folder with project files like the CHANGELOG.md, license and similar files
  • 2 sub directories, one for the backend (elixir) one for the frontend (Typescript)
  • Everything elixir related is in the backed dir, for example the mix file would be in backend/mix.exs
  • I work on the project by opening the root dir from VS Code (Ctrl + K, Crtl + O by default)

On this setup i was able to get all the warning by running the following commands on the terminal

cd backend
mix credo

But no warnings and no error messages where shown in the VS Code project

Thanks for the info!

I see. I initially thought you'd have two workspace folders instead of only one with two subdirectories.
I belive the issue would also occur in monorepos.
So it would be sufficient to go recursively up to the project root (depending on the openend document) and see if there is any mix.exs that would identify that directory as a mix project.

Will be working on that immediately and let you know as soon as it's fixed if you're interested.

Thank you very much!

@Pavinati I deployed a version 0.8.1 to the VS Code extension store where this bug should be fixed.

Let me know if it works!

So i did update the plugin, but it still doesn't work. The only difference is that now it displays a warning
Screenshot_20220729_162901

I didn't expect the credo config to be required so i generated one anyway with the command

mix credo gen.config

but the warning remains

Huh, that's weird. Could you enable the debug mode of the extension?

Either by using the UI or by adding "elixir.credo.enableDebug": true to your settings json.

And then can you have a look at the VS Code Output Panel of the extension and send me a screenshot after opening an elixir file?

Then, I can properly debug and fix the issue.

Enabling the Debug flag doesn't show anything in the Output Panel (nor in other Panels)
Screenshot_20220729_180337
Screenshot_20220729_180530

You have to select the output channel to view on the right hand side of the panel (where the dropdown Tasks) is displayed. There you need to select Credo (Elixir Linter)

You're right, i actually never changed it. here you go

> .credo.exs file does not exist. Ignoring...

> Retreiving credo information: Executing credo command `/home/pavij/.asdf/shims/mix credo info --format json --verbose` for /home/pavij/seco/clea/backend/lib/clea/apps.ex in directory /home/pavij/seco/clea/backend

> Credo (Elixir Linter) initiated successfully.

> Setting linter issues for document /home/pavij/seco/clea/backend/lib/clea/apps.ex.

i tried to manually launch said command from the terminal and it appears working as intended

pavij@pavij-desktop-pc:~/seco/clea/backend$ /home/pavij/.asdf/shims/mix credo info --format json --verbose /home/pavij/seco/clea/backend/lib/clea/apps.ex
{
  "config": {
    "checks": [
      {
        "name": "Elixir.Credo.Check.Consistency.ExceptionNames",
        "params": {}
      },
...

Thanks for the output! I believe I did not strip the project folder when comparing whether a file should be linted. I assume that everything would work if the configuration option Lint Everything is enabled.

Okay, I published a new version 0.8.2 which (hoppefully 😅) fixes everything.
Can you please confirm?

Ok, installed the 0.8.2 version, now i can see a new command launched

> Retreiving credo information: Executing credo command `/home/pavij/.asdf/shims/mix credo info --format json --verbose` for /home/pavij/seco/clea/backend/lib/clea/apps.ex in directory /home/pavij/seco/clea/backend

> Executing credo command `/home/pavij/.asdf/shims/mix credo --format json --read-from-stdin --config-file .credo.exs` for /home/pavij/seco/clea/backend/lib/clea/apps.ex in directory /home/pavij/seco/clea/backend

> Setting linter issues for document /home/pavij/seco/clea/backend/lib/clea/apps.ex.

That second command never ends thoguh. I guess it's due to the --read-from-stdin flag.
It works with the following command:

/home/pavij/.asdf/shims/mix credo --format json --config-file .credo.exs /home/pavij/seco/clea/backend/lib/clea/apps.ex

or by piping the file into the stdin with bash

cat /home/pavij/seco/clea/backend/lib/clea/apps.ex | /home/pavij/.asdf/shims/mix credo --format json --read-from-stdin --config-file .credo.exs

EDIT: the visual studio editor doesn't display any warning though

Are you sure the second command never ends? Because the third line of your output is only shown if the second terminates.

Could you send me your setting for the credo extension (either JSON or Settings UI screenshot would be helpful)?

Could you maybe also test for VS Code by adding three consecutive blank lines in your apps.ex or somewhere and then save the file?

I tried the setup you described locally, and for me everything works fine:

image

And in my settings i only have the debug mode enabled, nothing else.

Edit: The warnings are shown inline for me because I use the extension ErrorLens