Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Enable golangci-lint and fix reported errors#1661

Merged
janos merged 1 commit intogo-modulesfrom
go-modules-lint
Aug 14, 2019
Merged

Enable golangci-lint and fix reported errors#1661
janos merged 1 commit intogo-modulesfrom
go-modules-lint

Conversation

@janos
Copy link
Copy Markdown
Member

@janos janos commented Aug 9, 2019

This PR fulfills go-modules PR by enabling linters that are used on master but in updated version report errors on the codebase. While go-modules PR does not make changes to the swarm application, only tooling, this one does and for easier review it is split into a separate changeset.

In go-modules PR, a deprecated gometalinter.v2 is replaced by golangci-lint as the older one does not play well with modules.

Goangci-lint configuration is added mainly for goconst linter to be more permissive on min-occurrences, as some of the changes required with default configuration are not required by my opinion. Even some strings are repeated multiple times, it does not mean that their semantics is the same justifying additional constant. This is debatable and open for discussion.

Running the complete set of goglanci-lint linters produce a very high number of errors and I am suggesting to address some of them in the future and standardize linting.

for i, n := range snap.Nodes {
gotServices := n.Node.Config.Services
for i := 0; i < len(snap.Nodes); i++ {
gotServices := snap.Nodes[i].Node.Config.Services
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Previous iteration is coping the mutex, new one does not.

# minimal length of string constant, 3 by default
min-len: 3
# minimal occurrences count to trigger, 3 by default
min-occurrences: 5
Copy link
Copy Markdown
Contributor

@nolash nolash Aug 9, 2019

Choose a reason for hiding this comment

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

What exactly do these two choices mean?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comments are taken from the original documentation. The first one is the minimal length of the string that can be considered for a constant and the second one is the minimal number of that string occurrences in the package to be reported as constant definition required.

@skylenet skylenet added this to the 0.4.4 milestone Aug 12, 2019
@janos
Copy link
Copy Markdown
Member Author

janos commented Aug 13, 2019

Thank you for reviews, I will merge this PR as soon as #1532 receives more approvals an is ready to be merged.

@janos janos merged commit 139518b into go-modules Aug 14, 2019
@janos janos deleted the go-modules-lint branch August 14, 2019 08:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants