-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🚀 Feature: Add and apply more stricter golangci-lint linting rules #2286
Conversation
This is quite a big diff, but should be rather quick to review. |
6b16025
to
9cd19e9
Compare
is it still a draft or already final I will then look at everything |
I still need to fix the linting issues in all subpackages. Hope to complete that until next week. |
9cd19e9
to
9e60d66
Compare
This is now ready for review, @ReneWerner87 |
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.
LGTM. We should resolve some TODOs in v3 later.
@ReneWerner87 I'll rebase this once approved. |
Any news here? 😊 I'd like to get this merged asap. Resolving the conflicts will become more and more difficult with time. |
Sorry will check it in a few hours |
@leonklingele can you resolve the conflicts one more time -> before i merge it We may have to readjust some of the rules again(later). some adjustments like the initialization of the return variable although covered by golang i wouldn't make it mandatory and leave the developers the freedom to do so but most of the stuff is great |
@ReneWerner87 that's the I'll rebase this now. |
6567880
to
3645af4
Compare
@ReneWerner87 any idea why the Windows tests are failing now? |
@leonklingele will gradually undo your changes locally and see if I can locate the point of failure |
have tried to fix the errors, but that is currently not possible because I have limited time in the pull request more has been implemented than is initially apparent
exactly the last point is the problem, because not all tests or the whole app is currently not yet built to run in parallel with multiple instances @leonklingele if i were you i would disable this parallelism in some places and consider this separately from the pull request into a new one as it takes more time and prevents the big swing of changes from landing in the master |
3c687ce
to
8e40214
Compare
8e40214
to
afb85ef
Compare
afb85ef
to
ffaa8ad
Compare
No, this was already done previously as part of #2299. None of the tests are made parallel with this change. I have rebased to latest master to resolve merge conflicts and also cleaned up some of the new commits (yours + mine). |
@ReneWerner87 @efectn @leonklingele I feel like this PR needs to be reverted, and applied by section. So far, I have found some slight issues:
From my point of view, the Monitor middleware tests are all passing just fine but the middleware does not work at all. What else could be broken that we haven't noticed yet? |
…rules (gofiber#2286)" This reverts commit 167a8b5
Thanks for the feedback @gaby! To address your comments:
I have checked the code and it is a bug of the new error handling: func updateStatistics(p *process.Process) {
- pidCpu, _ := p.CPUPercent()
- monitPidCpu.Store(pidCpu / 10)
+ pidCPU, err := p.CPUPercent()
+ if err != nil {
+ monitPIDCPU.Store(pidCPU / 10) //nolint:gomnd // TODO: Explain why we divide by 10 here
+ } The code should check for
Obviously, this should not have been done. The
@gaby are you referring to the changes which now validate the second (bool) return value of type-assertions? @@ -877,7 +882,11 @@ func AcquireClient() *Client {
if v == nil {
return &Client{}
}
- return v.(*Client)
+ c, ok := v.(*Client)
+ if !ok {
+ panic(fmt.Errorf("failed to type-assert to *Client"))
+ }
+ return c
} This was panic-ing before (implicitly), so it's not a breaking change.
See above. This was panic-ing before, although now done explicitly instead of implicitly.
Those errors are now returned in a wrapped form with some additional context. Indeed it is a breaking change for people who do not use errors correctly (e.g. by comparing errors against a string). @@ -1379,7 +1381,7 @@ func Test_Test_DumpError(t *testing.T) {
resp, err := app.Test(httptest.NewRequest(MethodGet, "/", errorReader(0)))
utils.AssertEqual(t, true, resp == nil)
- utils.AssertEqual(t, "errorReader", err.Error())
+ utils.AssertEqual(t, "failed to dump request: errorReader", err.Error())
} Instead of comparing the error-string returned by
@gaby which variables are you referring to? No changes to exported fields, funcs, types, etc. should have been made. Renaming unexported data should be fine (and IMO also not be part of the documentation). Edit: The exported
Valid Go is not necessarily good Go. I quickly skimmed over all |
|
Description
In order to fix and avoid upcoming bugs, apply more stricter linting rules while still being easy to maintain.
Type of change
Please delete options that are not relevant.
Checklist: