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

Credo.Check.Refactor.ModuleDependencies breaks analysis

peloycosta opened this issue · comments

With Credo.Check.Refactor.ModuleDependencies enabled and a file that triggers this check, no issues show up on VSCode since the parsing fails on parser.tsx#L22 with trigger.replace is not a function.

This happens because the trigger for this check is an array, ie:

{
  category: "refactor",
  check: "Credo.Check.Refactor.ModuleDependencies",
  column: null,
  column_end: null,
  filename: "stdin",
  line_no: 1,
  message: "Module has too many dependencies: 13 (max is 10)",
  priority: 3,
  scope: "MyService.TooManyDeps",
  trigger: [
    "OK",
    "DateTime",
    "Atom",
    "Float",
    "Timex",
    "MyService.Dep1",
    "Enum",
    "Map",
    "MyService.Dep2",
    "MyService.Dep3",
    "MyService.Dep4",
    "MyService.Dep5",
    "List",
  ],
}

A quick fix would be to change the check on L19 to if (!trigger || typeof trigger !== 'string') return null; but maybe there's a better way to go about this.

Thanks for picking that up! Your solution is probably the best here because in such cases (at least for this check) it makes sense to highlight the entire module definition (in your example, line 1) instead of all module dependencies.