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 mix credo diff

bradleygolden opened this issue · comments

I'm currently using mix credo diff which was introduced in 1.6.0. Sadly this plugin doesn't work with that command (and all other elixir linters at the time of this writing). Here's an example of the new output:

{
  "diff": {
    "fixed": [],
    "new": [
      {
        "category": "refactor",
        "check": "Credo.Check.Refactor.VariableRebinding",
        "column": 5,
        "column_end": 12,
        "filename": "...",
        "line_no": 78,
        "message": "Variable \"changes\" was declared more than once.",
        "priority": 4,
        "scope": "...",
        "trigger": "changes"
      }
    ],
    "old": []
  }
}

Hi! Sorry for answering this late. I've had much on my plate lately and I overlooked the notification for this issue within all dependabot alerts 😄

Seems like a nice addition to Credo overall. So what would be your suggestion on how to display the new functionality?

A command or a setting to toggle the behavior to default or to the new diff behavior? And it would make sense to only show the new issues of the diff output command right?

I'm currently not sure what yields the best user experience, open to suggestions!

Hey no worries! Ideally I wouldn't have to do anything if that's possible. Right now I'm using an alias to make mix credo diff ... the default when running credo. Here's an example:

  defp aliases do
    [
      credo: ["credo diff --from-git-merge-base origin/dev"],
      ...
    ]
  end

The problem though is that I've had to comment this out because it causes the vscode extension to fail because the new output format is different than what's expected.

And yes, ideally the extension would only show new issues from the diff output command and not all issues.

Okay, thanks for the hint! Hm, I suppose I would add a config option to specify a git-merge-base that – when present – automatically activates the diff mode of credo. Will be starting working on it this week and tell you when you can try it out.

Published in version 0.8.0. 🚀

You can now specify in the settings whether to enable the diff mode or not with "elixir.credo.diffMode.enabled": true | false
and a custom merge base with "elixir.credo.diffMode.mergeBase": "feat-01" (default merge base is "main").

Let me know what you think!