Skip to content

Commit dedffd0

Browse files
Setup linter and add basic rules (#403)
Add linter rules for imports
1 parent 34025a2 commit dedffd0

File tree

87 files changed

+510
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+510
-406
lines changed

.golangci.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
3+
run:
4+
issues-exit-code: 3
5+
timeout: 30m
6+
skip-dirs:
7+
- vendor
8+
9+
linters:
10+
fast: false
11+
enable-all: false
12+
disable-all: false
13+
presets:
14+
- performance
15+
- format
16+
- complexity
17+
- bugs
18+
- unused
19+
disable:
20+
- staticcheck
21+
- errcheck
22+
- govet
23+
- gosec
24+
- ineffassign
25+
- noctx
26+
- contextcheck
27+
- unparam
28+
- scopelint
29+
- exhaustive
30+
- cyclop
31+
- errorlint
32+
- errchkjson
33+
- nestif
34+
- prealloc
35+
- maligned
36+
- funlen
37+
- typecheck
38+
- deadcode
39+
- unused
40+
- maintidx
41+
- varcheck
42+
- gocognit
43+
- gofumpt
44+
- gocyclo
45+
46+
linters-settings:
47+
gci:
48+
sections:
49+
- standard
50+
- default
51+
- prefix(github.com/arangodb)
52+
- prefix(github.com/arangodb/go-driver)

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ env:
4242

4343
script:
4444
- |
45-
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ ! -z "$ALWAYS" ]; then
45+
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ ! -z "$ALWAYS" ]; then
46+
make linter
4647
make $TEST_SUITE TEST_RESOURCES="$HOME/resources/" VERBOSE=1;
4748
fi

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [master](https://github.com/arangodb/go-driver/tree/master) (N/A)
44
- Fix `lastValue` field type
5+
- Setup Go-lang linter with minimal configuration
56
- Use Go 1.17.6
67

78
## [1.3.2](https://github.com/arangodb/go-driver/tree/v1.3.2) (2022-05-16)

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ else
136136
DOCKER_V2_RUN_CMD := $(GOV2IMAGE) go test $(GOBUILDTAGSOPT) $(TESTOPTIONS) $(TESTVERBOSEOPTIONS) ./tests
137137
endif
138138

139-
.PHONY: all build clean run-tests
139+
.PHONY: all build clean linter run-tests
140140

141141
all: build
142142

@@ -492,6 +492,8 @@ run-benchmarks-single-vpack-no-auth:
492492

493493
.PHONY: tools
494494
tools:
495+
@echo ">> Fetching golangci-lint linter"
496+
@GOBIN=$(TMPDIR)/bin go install github.com/golangci/golangci-lint/cmd/[email protected]
495497
@echo ">> Fetching goimports"
496498
@go get -mod 'readonly' golang.org/x/tools/cmd/goimports
497499
@echo ">> Fetching license check"
@@ -519,10 +521,7 @@ fmt-verify: license-verify
519521

520522
.PHONY: linter
521523
linter: fmt
522-
@golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all \
523-
$(foreach MODE,$(GOLANGCI_ENABLED),--enable $(MODE) ) \
524-
--exclude-use-default=false \
525-
$(SOURCES_PACKAGES)
524+
$(TMPDIR)/bin/golangci-lint run ./...
526525

527526
# V2
528527

agency/operation_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ package agency_test
2525
import (
2626
"testing"
2727

28-
"github.com/arangodb/go-driver/agency"
2928
"github.com/stretchr/testify/require"
29+
30+
"github.com/arangodb/go-driver/agency"
3031
)
3132

3233
func TestCreateSubKey(t *testing.T) {

encode-go_1_8.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23+
//go:build go1.8
2324
// +build go1.8
2425

2526
package driver

encode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23+
//go:build !go1.8
2324
// +build !go1.8
2425

2526
package driver

example_client_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23+
//go:build !auth
2324
// +build !auth
2425

2526
package driver_test

example_context_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23+
//go:build !auth
2324
// +build !auth
2425

2526
package driver_test

example_create_document_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// Author Ewout Prangsma
2121
//
2222

23+
//go:build !auth
2324
// +build !auth
2425

2526
// This example demonstrates how to create a single document.

0 commit comments

Comments
 (0)