Skip to content

Commit c02a219

Browse files
committed
Start using golangci-lint
- Fix issues found
1 parent f6baf14 commit c02a219

11 files changed

+107
-83
lines changed

.golangci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
linters:
2+
enable:
3+
- golint
4+
- interfacer
5+
- unconvert
6+
- dupl
7+
- goconst
8+
- gofmt
9+
- misspell
10+
- maligned
11+
- unparam
12+
- nakedret
13+
- prealloc
14+
- gosec
15+
linters-settings:
16+
misspell:
17+
locale: US
18+
issues:
19+
max-same: 0
20+
max-per-linter: 0
21+
exclude-use-default: false
22+
exclude:
23+
# gosec: Duplicated errcheck checks
24+
- G104
25+
- G201 # Re-enable once gosec considers quoted strings to be safe: https://github.com/securego/gosec/pull/240
26+
# Ignore unused variables/constants for now
27+
- is unused

.travis.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
language: go
22
sudo: false
33

4+
env:
5+
global:
6+
- GOLANGCI_LINT_VERSION=v1.10.2
7+
- DEP_VERSION=v0.5.0
8+
49
matrix:
510
allow_failures:
611
- go: master
@@ -11,12 +16,15 @@ matrix:
1116
- go: master
1217

1318
before_install:
14-
- if [ $GO_GET_COVER ]; then go get golang.org/x/tools/cmd/cover; fi
15-
- if [ "${NO_GOLINT}" != "true" ]; then go get github.com/golang/lint/golint; fi
19+
- curl -L -s https://github.com/golang/dep/releases/download/$DEP_VERSION/dep-linux-amd64 -o $GOPATH/bin/dep
20+
- chmod +x $GOPATH/bin/dep
21+
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin $GOLANGCI_LINT_VERSION
22+
23+
install:
24+
- dep ensure -vendor-only
1625

1726
before_script:
18-
- if [ "${NO_VET}" != "true" ]; then go vet ./...; fi
19-
- if [ "${NO_GOLINT}" != "true" ]; then golint ./...; fi
27+
- golangci-lint run
2028

2129
script:
2230
- ./codecov_test.sh

audit_logger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
// setupAuditLoggerTestData logs test data to the given AuditLogger
12-
func setupAuditLoggerTestData(userID passhash.UserID, al passhash.AuditLogger) int {
12+
func setupAuditLoggerTestData(userID passhash.UserID, al passhash.AuditLogger) int { // nolint: unparam
1313
numIters := 5
1414
for i := 0; i < numIters; i++ {
1515
al.Log(userID, passhash.AuthnSucceeded, passhash.EmptyIP)

benchmarks_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ func BenchmarkDefaultWorkFactorPbkdfSha256(b *testing.B) {
1515
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
1616
}
1717
userID := passhash.UserID(0)
18-
password := "insecurepassword"
1918
for i := 0; i < b.N; i++ {
20-
config.NewCredential(userID, password)
19+
config.NewCredential(userID, testPassword) // nolint: errcheck
2120
}
2221
}
2322

@@ -28,9 +27,8 @@ func BenchmarkDefaultWorkFactorPbkdfSha512(b *testing.B) {
2827
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
2928
}
3029
userID := passhash.UserID(0)
31-
password := "insecurepassword"
3230
for i := 0; i < b.N; i++ {
33-
config.NewCredential(userID, password)
31+
config.NewCredential(userID, testPassword) // nolint: errcheck
3432
}
3533
}
3634

@@ -41,9 +39,8 @@ func BenchmarkDefaultWorkFactorPbkdfSha3_256(b *testing.B) {
4139
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
4240
}
4341
userID := passhash.UserID(0)
44-
password := "insecurepassword"
4542
for i := 0; i < b.N; i++ {
46-
config.NewCredential(userID, password)
43+
config.NewCredential(userID, testPassword) // nolint: errcheck
4744
}
4845
}
4946

@@ -54,9 +51,8 @@ func BenchmarkDefaultWorkFactorPbkdfSha3_512(b *testing.B) {
5451
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
5552
}
5653
userID := passhash.UserID(0)
57-
password := "insecurepassword"
5854
for i := 0; i < b.N; i++ {
59-
config.NewCredential(userID, password)
55+
config.NewCredential(userID, testPassword) // nolint: errcheck
6056
}
6157
}
6258

@@ -67,9 +63,8 @@ func BenchmarkDefaultWorkFactorBcrypt(b *testing.B) {
6763
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
6864
}
6965
userID := passhash.UserID(0)
70-
password := "insecurepassword"
7166
for i := 0; i < b.N; i++ {
72-
config.NewCredential(userID, password)
67+
config.NewCredential(userID, testPassword) // nolint: errcheck
7368
}
7469
}
7570

@@ -80,8 +75,7 @@ func BenchmarkDefaultWorkFactorScrypt(b *testing.B) {
8075
Store: passhash.DummyCredentialStore{}, PasswordPolicies: []passhash.PasswordPolicy{},
8176
}
8277
userID := passhash.UserID(0)
83-
password := "insecurepassword"
8478
for i := 0; i < b.N; i++ {
85-
config.NewCredential(userID, password)
79+
config.NewCredential(userID, testPassword) // nolint: errcheck
8680
}
8781
}

config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestNewCredentialRandError(t *testing.T) {
9494
}()
9595
passhash.SetRandReader(readerError{})
9696
userID := passhash.UserID(0)
97-
password := "insecurepassword"
97+
password := testPassword
9898
if _, err := passhash.DefaultConfig.NewCredential(userID, password); err == nil {
9999
t.Error("No error hit when calling random numbers")
100100
}

consts_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package passhash_test
2+
3+
const testPassword = "insecurePassword"

credential.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net"
88
)
99

10-
// EmptyIP is the cannonical value for an empty IP. This value should not be modified
10+
// EmptyIP is the canonical value for an empty IP. This value should not be modified
1111
var EmptyIP = net.IP{}
1212

1313
// Credential is a password specification.

0 commit comments

Comments
 (0)