Skip to content
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

chore(lint): cleanup config and enable default linters for our code #764

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

qdm12
Copy link
Collaborator

@qdm12 qdm12 commented Jan 24, 2025

Why this should be merged

Enable default linters (errcheck, staticcheck, gosimple and staticcheck were missing) + errorlint for our code only:

  • ./plugin/*.go files
  • *libevm*.go files
  • _ext.go files
  • More suggestions are welcome

More linters can be added subsequently, but this PR fixes already quite a few errors already coming from enabling the default linters and errorlint in our code

How this works

  • Remove unused and unneeded configuration options
  • Existing geth code uses the same linters as before
  • No golangci-lint upgrade, wait for geth sync to upgrade the linter and get upstream lint error fixes
  • Our code is linted with more linters (default ones+errorlint)

How this was tested

  • Linter passing locally
  • CI passing

Need to be documented?

No

Need to update RELEASES.md?

No

@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch 2 times, most recently from f9798f5 to 3eddab0 Compare January 30, 2025 12:18
@qdm12 qdm12 changed the title Linting: lint more on new code only chore(lint): cleanup config and enable default linters for our code Jan 30, 2025
@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch from 3eddab0 to bff54b5 Compare January 30, 2025 12:32
@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch from bff54b5 to 8b2feae Compare February 13, 2025 11:14
@qdm12 qdm12 requested a review from alarso16 February 13, 2025 11:17
@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch from 44b1570 to 31da1de Compare February 13, 2025 12:05
_, err := rand.Read(blocksBytes[i])
assert.NoError(t, err)
}
blocksBytes := [][]byte{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these are the same values that were previously pseudo random generated, but I removed math/rand to make gosec happy; alternatively I can (did 1 in the last commit):

  1. Use smaller deterministic values set without a generator and change the tests expectations since the generated values would be different. My preferred because randomness has no place where it's actually not needed. This is done in the last commit.
  2. //nolint:gosec a bunch of places (I don't recommend)
  3. Disable gosec about weak generator for test files (eh it's ok, but not totally recommended either)

The same goes for a few other tests changed the same way as this one.

go vmSetup.serverVM.AppRequest(ctx, nodeID, requestID, time.Now().Add(1*time.Second), request)
go func() {
err := vmSetup.serverVM.AppRequest(ctx, nodeID, requestID, time.Now().Add(1*time.Second), request)
require.NoError(t, err)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note technically this should only be called in the test goroutine, but this would involve significant changes that are out of scope in this PR, so leaving this as is. It would still detect the failure, but may panic if the test goroutine finished and this goroutine fails after that.

Comment on lines +372 to +375
err := a.trieDB.Dereference(a.lastAcceptedRoot)
if err != nil {
return false, fmt.Errorf("dereferencing last accepted root: %w", err)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: i forgot to check the error here, showing the point of errcheck 😄 Risky business otherwise!

@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch 3 times, most recently from 1b632eb to 17cf418 Compare February 13, 2025 17:04
@qdm12 qdm12 marked this pull request as ready for review February 17, 2025 17:55
@qdm12 qdm12 requested review from ceyonur, darioush and a team as code owners February 17, 2025 17:55
@qdm12 qdm12 mentioned this pull request Feb 17, 2025
@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch from 17cf418 to 48a4806 Compare February 17, 2025 18:57
@qdm12 qdm12 marked this pull request as draft February 17, 2025 18:59
@qdm12 qdm12 force-pushed the qdm12/linter-new-only branch from 48a4806 to c80529b Compare February 17, 2025 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants