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

staticcheck #69

Merged
merged 1 commit into from
Jul 20, 2021
Merged

staticcheck #69

merged 1 commit into from
Jul 20, 2021

Conversation

coryschwartz
Copy link

This fixes small problems picked up by staticcheck.
The ones that remain are for the generated protobuf file, which I haven't regenerated.

For context: protocol/.github#41

◉ staticcheck ./...
pb/merkledag.pb.go:213:10: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:217:11: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:222:10: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:226:11: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:231:10: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:309:10: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:313:11: error strings should not be capitalized (ST1005)
pb/merkledag.pb.go:317:10: error strings should not be capitalized (ST1005)

@welcome
Copy link

welcome bot commented Apr 15, 2021

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link
Contributor

@mvdan mvdan left a comment

Choose a reason for hiding this comment

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

I think we don't want to re-generate that protobuf code on purpose, to prevent changing CIDs.

@marten-seemann
Copy link
Member

@mvdan This will fail on CI though. Any suggestion how to proceed here?

@mvdan
Copy link
Contributor

mvdan commented Apr 20, 2021

Right. I think we have two options:

  1. Manually fix the code to have no warnings, while being extra careful that we're not changing the behavior of the code in any way. The tests should cover most mistakes here, but I think we should also get 2+ thorough reviews.

  2. Mark the entire file as "nolint" with staticcheck, assuming that's possible.

Option 2 is probably the easiest, assuming that none of the warnings point at real bugs.

@marten-seemann
Copy link
Member

  1. Mark the entire file as "nolint" with staticcheck, assuming that's possible.

According to https://staticcheck.io/docs, we could create a config file. Not sure if that allows us to exclude files though.

@mvdan
Copy link
Contributor

mvdan commented Apr 20, 2021

There are comment directives to disable a check for the entire file: https://staticcheck.io/docs#file-based-linter-directives

@marten-seemann
Copy link
Member

marten-seemann commented Apr 20, 2021

Apparently it's not possible to disable a rule for a specific file (but it might be possible to do it for an entire directory, which would work here): dominikh/go-tools#429. Fun fact: @mvdan participated in that discussion 1.5 years ago.
I have to admit I failed to figure out how to write such a rule in TOML though.

@mvdan
Copy link
Contributor

mvdan commented Apr 20, 2021

What about that //lint:file-ignore I linked to in my last comment?

@marten-seemann
Copy link
Member

-: Near line 0 (last key parsed ''): bare keys cannot contain '/' (compile)

Doesn't seem to be valid TOML.

@mvdan
Copy link
Contributor

mvdan commented Apr 20, 2021

That goes in the Go source file, not a TOML config.

@marten-seemann
Copy link
Member

That might work, but I'd like to avoid editing generated files. We have a lot of protobuf files across our code base.

@mvdan
Copy link
Contributor

mvdan commented Apr 21, 2021

I would hope that this kind of thing is only necessary for go-merkledag's ancient gogo-protobuf generated code though. Most other repos should be using a recent protoc-gen-go version, which I hope does not generate any vet or staticcheck warnings.

@Stebalien
Copy link
Member

That might work, but I'd like to avoid editing generated files. We have a lot of protobuf files across our code base.

We've already intentionally edited this file to ensure that we'll fail a test if we try to regenerate it. Essentially, I don't consider it to be an "autogenerated" file at this point. I'll file a new PR to remove that comment....

@Stebalien Stebalien merged commit 1c3bc18 into ipfs:master Jul 20, 2021
rvagg added a commit that referenced this pull request Jul 20, 2021
This file has evolved beyond its codegen status and has been manually
edited a few times already. It's unlikely to change and is slowly being
deprecated in favour of https://github.com/ipld/go-codec-dagpb

Ref: #69
@rvagg rvagg mentioned this pull request Jul 20, 2021
@rvagg
Copy link
Member

rvagg commented Jul 20, 2021

#71

@aschmahmann aschmahmann mentioned this pull request Aug 23, 2021
62 tasks
Jorropo pushed a commit to ipfs/boxo that referenced this pull request Mar 15, 2023
Jorropo pushed a commit to ipfs/boxo that referenced this pull request Mar 15, 2023
This file has evolved beyond its codegen status and has been manually
edited a few times already. It's unlikely to change and is slowly being
deprecated in favour of https://github.com/ipld/go-codec-dagpb

Ref: ipfs/go-merkledag#69


This commit was moved from ipfs/go-merkledag@40f5034
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.

5 participants