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

feat: use golangci-lint for code static analysis #797

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dreamacro
Copy link
Contributor

@Dreamacro Dreamacro commented Jan 19, 2025

As described in #775, boxo requires a better static code analysis tool since the currently used ipdxco/unified-github-workflows has limitation capabilities.

Therefore, I am attempting to use golangci-lint here (while retaining the original ipdxco/unified-github-workflows). I have disabled all golangci-lint default configurations and enabled some checks that I find particularly valuable.

After performing the lint fixes, boxo generally has the following issues:

  1. Some files have imported package names divided into groups without any discernible pattern (if there is one, please let me know), and gci can fix this.
    for example:
    import (
    "bytes"
    "io"
    "strings"
    "testing"
    mdag "github.com/ipfs/boxo/ipld/merkledag"
    "github.com/ipfs/boxo/ipld/unixfs"
    context "context"
    testu "github.com/ipfs/boxo/ipld/unixfs/test"
    )
  2. many unnecessary type conversions can be detected and fixed using unconvert.
  3. Other minor issues, such as unnecessary blank lines, octal notation, statements that will never be executed, etc.

There might be some other valuable plugins, such as unused, and I would like to hear your opinions on them.

@Dreamacro Dreamacro requested review from lidel and a team as code owners January 19, 2025 11:57
Copy link

codecov bot commented Jan 19, 2025

Codecov Report

Attention: Patch coverage is 74.19355% with 8 lines in your changes missing coverage. Please review.

Project coverage is 60.54%. Comparing base (8ca0ca2) to head (528dbb8).

Files with missing lines Patch % Lines
gateway/serve_http_content.go 25.00% 1 Missing and 2 partials ⚠️
files/util.go 66.66% 1 Missing ⚠️
filestore/fsrefstore.go 0.00% 1 Missing ⚠️
gateway/backend_car_files.go 0.00% 1 Missing ⚠️
ipld/unixfs/unixfs.go 0.00% 1 Missing ⚠️
routing/http/types/json/responses.go 50.00% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #797      +/-   ##
==========================================
+ Coverage   60.51%   60.54%   +0.02%     
==========================================
  Files         245      245              
  Lines       31132    31131       -1     
==========================================
+ Hits        18840    18847       +7     
+ Misses      10615    10611       -4     
+ Partials     1677     1673       -4     
Files with missing lines Coverage Δ
bitswap/bitswap.go 69.13% <ø> (ø)
bitswap/client/internal/getter/getter.go 81.81% <ø> (ø)
bitswap/client/internal/peermanager/peermanager.go 91.85% <ø> (ø)
...wap/client/internal/peermanager/peerwantmanager.go 88.50% <ø> (-0.04%) ⬇️
...tswap/client/internal/session/sessionwantsender.go 97.65% <ø> (+0.70%) ⬆️
...l/sessioninterestmanager/sessioninterestmanager.go 100.00% <ø> (ø)
...p/client/internal/sessionmanager/sessionmanager.go 100.00% <ø> (ø)
.../internal/sessionpeermanager/sessionpeermanager.go 100.00% <ø> (ø)
bitswap/client/wantlist/wantlist.go 90.62% <ø> (ø)
bitswap/message/message.go 83.87% <100.00%> (ø)
... and 62 more

... and 5 files with indirect coverage changes

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.

1 participant