golangci-lint icon indicating copy to clipboard operation
golangci-lint copied to clipboard

Use path exclude rules on absolute paths instead of relative paths

Open xtonyjiang opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. Using path exclude rules is difficult because the issue path depends on which directory I run golangci-lint from.

Describe the solution you'd like I'd like path exclude rules to be evaluated on the absolute path of the issue, not the relative path that is output.

Describe alternatives you've considered Can't think of a great alternative here.

Additional context Example: If I have an exclude rule on a file a/b/c.go, this rule will not apply if I run golangci-lint from directory a/b/.

xtonyjiang avatar Jun 06 '20 00:06 xtonyjiang

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

boring-cyborg[bot] avatar Jun 06 '20 00:06 boring-cyborg[bot]

Note that this feature would be especially important for editor integrations like VSCode's vscode-go.

Users have no option to control the cwd from which golangci-lint will be executed there (lint of save), it's always going to be the path were the file lives.

Typically, the only configuration that happens there is something like:

"go.lintTool": "golangci-lint",
"go.lintFlags": [
  "--fast",
  "--timeout",
  "5m"
],

majodev avatar Sep 21 '20 15:09 majodev

Are there any efforts related to this? It seems like a common enough issue. I can take a crack at it if it's a feature that would be accepted by the golangci team

gganley avatar Feb 08 '21 15:02 gganley

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 30 '22 06:03 stale[bot]

This is really painful to enable a monorepo global ruleset. we can't run golangci-lint from the root of the monorepo, so you have to pushd into the module directory, but that means you can't have path based exclude rules in the root config file.

given

/monorepo
    /module1
    /module2
/.golangci.yml

I can't have any path based rules in golangci.yml, because they have to be relative to where the golangci-lint command is being run, which has to be from module1 or module2 folder.

serbrech avatar Dec 11 '22 22:12 serbrech