Skip to content

Commit c16961a

Browse files
author
TP Honey
committed
(maint) fixing naming and add more go best practice
1 parent c29b3f1 commit c16961a

File tree

5 files changed

+160
-4
lines changed

5 files changed

+160
-4
lines changed

.drone.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
---
22
kind: pipeline
3-
type: docker
3+
type: vm
44
name: default
55

6-
platform:
7-
os: linux
8-
arch: amd64
6+
pool:
7+
use: ubuntu
98

109
steps:
1110
- name: vet
@@ -15,6 +14,8 @@ steps:
1514
volumes:
1615
- name: gopath
1716
path: /go
17+
depends_on:
18+
- clone
1819

1920
- name: test
2021
image: golang:1.15
@@ -23,6 +24,30 @@ steps:
2324
volumes:
2425
- name: gopath
2526
path: /go
27+
depends_on:
28+
- vet
29+
30+
- name: check go.mod is up to date
31+
image: golang:1.15
32+
commands:
33+
- cp go.mod go.mod.bak
34+
- go mod tidy
35+
- diff go.mod go.mod.bak || (echo "go.mod is not up to date" && exit 1)
36+
volumes:
37+
- name: gopath
38+
path: /go
39+
depends_on:
40+
- vet
41+
42+
- name: golangci-lint
43+
image: golangci/golangci-lint
44+
commands:
45+
- golangci-lint run --timeout 500s --new-from-rev=HEAD~
46+
volumes:
47+
- name: gopath
48+
path: /go
49+
depends_on:
50+
- clone
2651

2752
volumes:
2853
- name: gopath

.golangci.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
linters-settings:
2+
dupl:
3+
threshold: 100
4+
funlen:
5+
lines: 400
6+
statements: 100
7+
gci:
8+
local-prefixes: github.com/golangci/golangci-lint
9+
goconst:
10+
min-len: 3
11+
min-occurrences: 3
12+
gocritic:
13+
enabled-tags:
14+
- diagnostic
15+
- experimental
16+
- opinionated
17+
- performance
18+
- style
19+
disabled-checks:
20+
- dupImport # https://github.com/go-critic/go-critic/issues/845
21+
- ifElseChain
22+
- octalLiteral
23+
- whyNoLint
24+
- wrapperFunc
25+
gocyclo:
26+
min-complexity: 25
27+
goimports:
28+
local-prefixes: github.com/golangci/golangci-lint
29+
gomnd:
30+
settings:
31+
mnd:
32+
# don't include the "operation" and "assign"
33+
checks: argument,case,condition,return
34+
govet:
35+
check-shadowing: true
36+
settings:
37+
printf:
38+
funcs:
39+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
40+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
41+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
42+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
43+
lll:
44+
line-length: 200
45+
maligned:
46+
suggest-new: true
47+
misspell:
48+
locale: US
49+
nolintlint:
50+
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
51+
allow-unused: false # report any unused nolint directives
52+
require-explanation: false # don't require an explanation for nolint directives
53+
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
54+
nakedret:
55+
max-func-lines: 100
56+
57+
linters:
58+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
59+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
60+
disable-all: true
61+
enable:
62+
- bodyclose
63+
- deadcode
64+
- depguard
65+
- dogsled
66+
- errcheck
67+
- exportloopref
68+
- exhaustive
69+
- funlen
70+
- gochecknoinits
71+
- goconst
72+
- gocritic
73+
- gocyclo
74+
- gofmt
75+
- goimports
76+
- gomnd
77+
- goprintffuncname
78+
- gosec
79+
- gosimple
80+
- govet
81+
- ineffassign
82+
- lll
83+
- misspell
84+
- nakedret
85+
- noctx
86+
- nolintlint
87+
- revive
88+
- rowserrcheck
89+
- staticcheck
90+
- structcheck
91+
- stylecheck
92+
- typecheck
93+
- unconvert
94+
- unparam
95+
- unused
96+
- varcheck
97+
- whitespace
98+
99+
# don't enable:
100+
# - asciicheck
101+
# - dupl
102+
# - scopelint
103+
# - gochecknoglobals
104+
# - gocognit
105+
# - godot
106+
# - godox
107+
# - goerr113
108+
# - interfacer
109+
# - maligned
110+
# - nestif
111+
# - prealloc
112+
# - testpackage
113+
# - revive
114+
# - wsl
115+
116+
issues:
117+
# Excluding configuration per-path, per-linter, per-text and per-source
118+
exclude-rules:
119+
- path: _test\.go
120+
linters:
121+
- gomnd
122+
123+
# https://github.com/go-critic/go-critic/issues/926
124+
- linters:
125+
- gocritic
126+
text: "unnecessaryDefer:"
127+
128+
run:
129+
skip-files:
130+
- _gen\.go

scm/driver/azure/git.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (s *gitService) ListChanges(ctx context.Context, repo, ref string, _ scm.Li
9191
}
9292

9393
func (s *gitService) CompareChanges(ctx context.Context, repo, source, target string, _ scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
94+
9495
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-6.0
9596
if s.client.project == "" {
9697
return nil, nil, ProjectRequiredError()
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)