-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
typecheck: display compilation errors as report instead of error #1861
Conversation
c33f4dd
to
9e10dcc
Compare
018445b
to
a52604b
Compare
567a7f8
to
7b3ed82
Compare
7b3ed82
to
4285e92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job, thanks for fixing this! Also thanks for nicely splitting this up across several commits so I could easy follow them and not mix restructuring of the code with your changes to fix this. This will be much appreciated!
🌟 🌟 🌟
This comment has been minimized.
This comment has been minimized.
@thebeline could you open a new issue? |
This comment has been minimized.
This comment has been minimized.
@ldez - I would love to, but I am not exactly sure what I am reporting on, how to phrase it, etc. |
@thebeline I will open a new issue BUT please provide a way to reproduce it. |
This PR will improve the report when the analyzed code contains compilation errors.
It's a bit complex to explain but I will try to explain it.
typecheck
is like the front-end of a Go compiler: parses and type-checks Go code, this "linter" can manage compilation errors, that's its role.typecheck
is not a real linter it's just a way to parse some errors produced by thetypes.Checker
.The code in
pkg/golinters/typecheck.go
is just a kind of placeholder.golangci-lint/pkg/golinters/typecheck.go
Lines 14 to 16 in 8db518c
The real code is here:
golangci-lint/pkg/golinters/goanalysis/linter.go
Lines 180 to 216 in 8db518c
The core of the fix is to always handle errors as issues if the errors are
IllTypedError
.And to be able to detect this kind of error, I dropped the
FailedPrerequisitesError
because it grouped errors as string instead of error.This applies to all linters 🎉
I improved the number of issues reported by
typecheck
by removing the duplicate elements with a "stack crusher", so now the hardcoded limit can be removed safely.I have split the
pkg/golinters/goanalysis/runner.go
file into multiple files because it's a pain to debug a 1500 lines file with recursive calls, multiple structures, and multiple embedded and anonymous functions.Fixes #1820
Fixes #1826
Fixes #1168
Fixes #1043
Fixes #1002
Fixes #886
I think this also partially fixes #1792 (#1792 (comment))
Before my PR
With my PR