-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
importas linter is non-deterministic #5218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, This is because the number of reports is limited by default. The reports are changed in a "random" order, so when you apply a filter to it, you have "non-deterministic" results. You can put this into your configuration to remove limitations: issues:
max-same-issues: 0
max-issues-per-linter: 0 https://golangci-lint.run/usage/configuration/#issues-configuration You can also sort the reports: output:
show-stats: true
sort-results: true
sort-order:
- file
- linter https://golangci-lint.run/usage/configuration/#output-configuration |
@ldez Thank you for your response, but I'm sorry, that's not my issue. I was not talking about the order of the reported issues. I was talking about the issues being inconsistent/incorrect. If you look at my configuration, you'll notice that there are two rules. Both will match the same import: When clearing the cache, the results change from one run to another for the same file, too. I've run I've spent two hours looking at this, with a colleague, and we both agree that this is a bug (or misconfiguration). |
ok give me a few minutes |
You can find a full example here: https://github.com/temporalio/temporal/actions/runs/12287413365/job/34289395042?pr=6968#step:4:3163 ![]() |
Inside golangci-lint we are using slices for aliases, so there is no random order, but inside importas the aliases are in a map. golangci/golangci-lint-action#1110 (comment) The problem has been fixed inside importas but there is no release. |
The latest and the only release of importas is really old (2022) so I will bypass our dependency policies to use a pseudo version. I asked for a new release of importas: julz/importas#27 |
Ah, thank you! That would explain why my local
Sorry to confirm, do you mean golangci-lint's dependency policies; or ours? It seems the current version of |
Our dependency policies 😄 😄 sorry it's funny, yes I made a typo, I'm talking about golangci-lint dependency policies. |
What do you mean? |
I tried golangci-lint with the updated version of But you have to change your configuration: from: importas:
alias:
- pkg: go.temporal.io/api/(\w+)/v1
alias: enumspb1
- pkg: go.temporal.io/api/enums/v1
alias: enumspb2 to importas:
alias:
- pkg: go.temporal.io/api/enums/v1
alias: enumspb2
- pkg: go.temporal.io/api/(\w+)/v1
alias: enumspb1 The order is now very important. If I use your current configuration: $ ./golangci-lint run | rg 'enumspb2' | wc -l
0 If I use my suggestion: $ ./golangci-lint run | rg 'enumspb2' | wc -l
392 Note: I disabled all the limitations. |
@ldez thank you, I appreciated your work! I'll ask about our policy there. |
Welcome
typecheck
section of the FAQ.Description of the problem
Running the
importas
linter does not seem to be deterministic.I've run
importas
separately, with the same config, and it produces the expected results, consistently.With
golangci-lint
it doesn't.For example, in the output I pasted, you'll find both
ie the first rule,
enumspb1
.As well as
ie the second rule,
enumspb2
.But they match the same import!
Version of golangci-lint
Configuration
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
temporalio/temporal#6968
Validation
Supporter
The text was updated successfully, but these errors were encountered: