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

linting? #160

Open
uhthomas opened this issue May 9, 2024 · 3 comments · May be fixed by #165
Open

linting? #160

uhthomas opened this issue May 9, 2024 · 3 comments · May be fixed by #165

Comments

@uhthomas
Copy link
Collaborator

uhthomas commented May 9, 2024

Describe the bug

I noticed some bugs whilst working on the project, such as:

image

It would be good to have golangci-lint run to catch these automatically.

To Reproduce

N/A

Expected behavior

Fewer bugs.

Screenshots

See above.

Additional context

N/A

@uhthomas
Copy link
Collaborator Author

uhthomas commented May 9, 2024

image

@uhthomas
Copy link
Collaborator Author

uhthomas commented May 9, 2024

I'll stop adding more comments and just run static check.

image

@uhthomas
Copy link
Collaborator Author

uhthomas commented May 9, 2024

❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
internal/it/suite_test.go:32:5: var cfg is unused (U1000)
internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
exit status 1

uhthomas added a commit that referenced this issue May 9, 2024
Use [staticcheck](https://staticcheck.dev/) to find and fix correctness
issues.

	❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
	internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
	internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
	internal/it/suite_test.go:32:5: var cfg is unused (U1000)
	internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
	internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
	pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
	pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
	pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
	pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
	pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
	pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
	pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
	pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
	exit status 1

Refs: #160
uhthomas added a commit that referenced this issue May 9, 2024
Use [staticcheck](https://staticcheck.dev/) to find and fix correctness
issues.

	❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
	internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
	internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
	internal/it/suite_test.go:32:5: var cfg is unused (U1000)
	internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
	internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
	pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
	pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
	pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
	pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
	pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
	pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
	pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
	pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
	exit status 1

Refs: #160
uhthomas added a commit that referenced this issue May 9, 2024
Use [staticcheck](https://staticcheck.dev/) to find and fix correctness
issues.

	❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
	internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
	internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
	internal/it/suite_test.go:32:5: var cfg is unused (U1000)
	internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
	internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
	pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
	pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
	pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
	pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
	pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
	pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
	pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
	pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
	exit status 1

Refs: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
@uhthomas uhthomas linked a pull request May 9, 2024 that will close this issue
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
Use [staticcheck](https://staticcheck.dev/) to find and fix correctness
issues.

	❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
	internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
	internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
	internal/it/suite_test.go:32:5: var cfg is unused (U1000)
	internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
	internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
	pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
	pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
	pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
	pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
	pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
	pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
	pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
	pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
	exit status 1

Refs: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
jodevsa pushed a commit that referenced this issue May 9, 2024
Use [staticcheck](https://staticcheck.dev/) to find and fix correctness
issues.

	❯ go run honnef.co/go/tools/cmd/staticcheck@latest ./...
	internal/iptables/iptables.go:61:3: should replace loop with rules = append(rules, EgressNetworkPolicyToIpTableRules(policy, peerChain)...) (S1011)
	internal/iptables/iptables.go:80:22: unnecessary use of fmt.Sprintf (S1039)
	internal/it/suite_test.go:32:5: var cfg is unused (U1000)
	internal/it/suite_test.go:34:5: var testEnv is unused (U1000)
	internal/it/suite_test.go:172:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:185:2: this value of b is never used (SA4006)
	internal/it/suite_test.go:222:2: this value of err is never used (SA4006)
	pkg/api/v1alpha1/wireguard_types.go:26:2: only the first constant in this group has an explicit type (SA9004)
	pkg/controllers/suite_test.go:41:5: var cfg is unused (U1000)
	pkg/controllers/wireguard_controller.go:151:13: error strings should not be capitalized (ST1005)
	pkg/controllers/wireguard_controller.go:407:3: this value of port is never used (SA4006)
	pkg/controllers/wireguard_controller.go:407:10: Sprint doesn't have side effects and its return value is ignored (SA4017)
	pkg/wireguard/wireguard.go:63:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:104:2: this value of link is never used (SA4006)
	pkg/wireguard/wireguard.go:155:2: this value of err is never used (SA4006)
	pkg/wireguard/wireguard.go:293:6: should omit comparison to bool constant, can be simplified to peer.Spec.Disabled (S1002)
	pkg/wireguard/wireguard.go:343:2: this value of err is never used (SA4006)
	exit status 1

Refs: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
uhthomas added a commit that referenced this issue May 9, 2024
golangci-lint runs many analysers, including staticcheck, which prevent
correctness issues and catch bugs.

https://golangci-lint.run/

Fixes: #160
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 a pull request may close this issue.

1 participant