Skip to content

Commit 0703ec5

Browse files
committed
style: add exportloopref, gocritic, godot & goimports linters + fixes
Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
1 parent e401212 commit 0703ec5

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

.travis.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,19 @@ script:
3232
- go test -race $GO_TEST_OPTS ./...
3333
- >
3434
if [ "$USE_LINTER" = 1 ]; then
35-
golangci-lint run -E gofmt -E golint -E maligned -E misspell -E prealloc -E unconvert -E whitespace ./...;
35+
golangci-lint run --max-issues-per-linter 0 \
36+
--max-same-issues 0 \
37+
-E exportloopref \
38+
-E gocritic \
39+
-E godot \
40+
-E goimports \
41+
-E golint \
42+
-E maligned \
43+
-E misspell \
44+
-E prealloc \
45+
-E unconvert \
46+
-E whitespace \
47+
./...;
3648
fi
3749
3850
notifications:

transport.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,11 @@ func (m *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
162162
m.callCountInfo[respKey]++
163163
}
164164
m.totalCallCount++
165-
} else {
165+
} else if m.noResponder != nil {
166166
// we didn't find a responder, so fire the 'no responder' responder
167-
if m.noResponder != nil {
168-
m.callCountInfo[internal.NoResponder]++
169-
m.totalCallCount++
170-
responder = m.noResponder
171-
}
167+
m.callCountInfo[internal.NoResponder]++
168+
m.totalCallCount++
169+
responder = m.noResponder
172170
}
173171
m.mu.Unlock()
174172

@@ -178,7 +176,7 @@ func (m *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
178176
return runCancelable(responder, internal.SetSubmatches(req, submatches))
179177
}
180178

181-
// NumResponders
179+
// NumResponders returns the number of responders currently in use.
182180
func (m *MockTransport) NumResponders() int {
183181
m.mu.RLock()
184182
defer m.mu.RUnlock()
@@ -547,7 +545,7 @@ var DefaultTransport = NewMockTransport()
547545
var InitialTransport = http.DefaultTransport
548546

549547
// oldClients is used to handle custom http clients (i.e clients other
550-
// than http.DefaultClient)
548+
// than http.DefaultClient).
551549
var oldClients = map[*http.Client]http.RoundTripper{}
552550

553551
// Activate starts the mock environment. This should be called before

util_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ func writeFile(t *testing.T, file string, content []byte) {
6060
}
6161
}
6262

63-
// All this stuff to compensate the absence of (*testing.T).Helper() in go<1.9
63+
// fakeHelper allows to compensate the absence of
64+
// (*testing.T).Helper() in go<1.9.
6465
type fakeHelper struct{}
6566

6667
func (f fakeHelper) Helper() {}

0 commit comments

Comments
 (0)