Skip to content

Commit f501889

Browse files
authored
Make golangci-lint happy (#115)
1 parent 94499fb commit f501889

9 files changed

Lines changed: 140 additions & 32 deletions

File tree

.golangci.yml

Lines changed: 107 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,123 @@
11
version: "2"
22

33
linters:
4-
default: all
5-
disable:
4+
enable:
5+
# Default
6+
- errcheck
7+
- govet
8+
- ineffassign
9+
- staticcheck
10+
- unused
11+
# Custom
12+
- asasalint
13+
- asciicheck
14+
- bidichk
15+
- bodyclose
16+
- containedctx
17+
- contextcheck
18+
- copyloopvar
19+
- cyclop
20+
- depguard
21+
- dogsled
22+
- dupl
23+
- dupword
24+
- durationcheck
25+
- embeddedstructfieldcheck
26+
- errchkjson
27+
- errname
28+
- errorlint
29+
- exhaustive
30+
- exptostd
31+
- fatcontext
32+
- forcetypeassert
33+
- gocheckcompilerdirectives
34+
- gochecknoglobals
35+
- gochecknoinits
36+
- gocritic
37+
- godoclint
38+
- godot
39+
- gosec
40+
- misspell
41+
- nolintlint
42+
- nonamedreturns
643
- revive
7-
- testpackage
8-
- varnamelen
9-
- wsl
44+
- sloglint
45+
- unparam
46+
- usestdlibvars
47+
48+
settings:
49+
govet:
50+
enable-all: true
51+
disable:
52+
- fieldalignment
53+
54+
staticcheck:
55+
checks:
56+
- all
57+
58+
# Custom
59+
depguard:
60+
rules:
61+
all:
62+
list-mode: strict
63+
files:
64+
- $all
65+
- "!$test"
66+
allow:
67+
- $gostd
68+
- github.com/typisttech/comver
69+
test:
70+
files:
71+
- $test
72+
deny:
73+
- pkg: github.com/stretchr/testify
74+
desc: Use standard library or 'github.com/google/go-cmp/cmp'
75+
76+
exhaustive:
77+
default-signifies-exhaustive: true
78+
79+
gocritic:
80+
enabled-checks:
81+
- emptyStringTest
82+
- preferStringWriter
83+
84+
godoclint:
85+
enable:
86+
- max-len
87+
- no-unused-link
88+
- require-stdlib-doclink
89+
90+
godot:
91+
scope: toplevel
92+
capital: true
93+
94+
nolintlint:
95+
require-specific: true
96+
97+
revive:
98+
rules:
99+
- name: exported
100+
disabled: true
101+
10102
exclusions:
103+
generated: disable
104+
warn-unused: true
11105
rules:
12106
- path: _test\.go
13107
linters:
14-
- depguard
15108
- dupl
16-
- funlen
17-
- lll
18-
- maintidx
109+
110+
- path: doc.go
111+
linters:
112+
- godoclint
19113

20114
formatters:
21115
enable:
22116
- gci
23117
- gofmt
24118
- gofumpt
25119
- goimports
26-
- swaggo
120+
121+
settings:
122+
gofumpt:
123+
extra-rules: true

and.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const (
88
errImpossibleInterval stringError = "impossible interval"
99
)
1010

11-
// And returns a [CeilingFloorConstrainter] instance representing the logical AND of
12-
// the given [Endless] instances; or return an error if the given [Endless] instances
13-
// could never be satisfied at the same time.
11+
// And returns a [CeilingFloorConstrainter] instance representing the logical
12+
// AND of the given [Endless] instances; or return an error if the given
13+
// [Endless] instances could never be satisfied at the same time.
1414
func And(es ...Endless) (CeilingFloorConstrainter, error) { //nolint:cyclop,ireturn
1515
var nilC CeilingFloorConstrainter
1616

compact.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"slices"
55
)
66

7-
// Compact returns a new [Constrainter] that is logically equivalent to the input [Or].
7+
// Compact returns a new [Constrainter] that is logically equivalent to the
8+
// input [Or].
9+
//
810
// The returned [Constrainter] may or may be not be an [Or] instance.
911
// When it is, Compact tries to return the shortest [Or] possible.
1012
func Compact(o Or) Constrainter { //nolint:cyclop,ireturn

endless.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package comver
22

3-
// Endless represents a constraint that is either floor bounded, ceiling bounded,
4-
// or [match all].
5-
// The zero value for Endless is a [match all] constraint which satisfied by any [Version].
3+
// Endless represents a constraint that is either floor bounded, ceiling
4+
// bounded, or [match all].
5+
// The zero value for Endless is a [match all] constraint which satisfied by any
6+
// [Version].
67
//
78
// [match all]: https://github.com/composer/semver/blob/main/src/Constraint/MatchAllConstraint.php
89
type Endless struct {
@@ -103,9 +104,13 @@ func (b Endless) matchAll() bool {
103104
//
104105
// The comparison is done by comparing the version first, then the operator.
105106
// - Versions are compared according to their semantic precedence
106-
// - Operators are compared in the following order (lowest to highest): >=, >, <, <=
107-
// - Match all [Endless] is considered to be higher than ceiling bounded [Endless] while
108-
// lower than floor bounded [Endless]
107+
// - Operators are compared in the following order (lowest to highest):
108+
// - >=
109+
// - >
110+
// - <
111+
// - <=
112+
// - Match all [Endless] is considered to be higher than ceiling bounded
113+
// [Endless] while lower than floor bounded [Endless]
109114
//
110115
// The result is 0 when b == d, -1 when b < d, or +1 when b > d.
111116
func (b Endless) compare(d Endless) int {

internal/wordfencetest/gen.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ const fileTemplateRaw = `// Code generated by {{ .GeneratedBy }}; DO NOT EDIT.
1313
{{- range .Sources }}
1414
// - {{ . }}
1515
{{- end }}
16+
1617
package main
1718
18-
var {{ .VariableName }} = []string{
19+
var {{ .VariableName }} = []string{ //nolint:gochecknoglobals
1920
{{- range .Versions }}
2021
{{ printf "%q" . }},
2122
{{- end }}

internal/wordfencetest/wordfence_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interval.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package comver
22

3-
// interval represents a constraint that is both floor bounded and ceiling bounded.
4-
// It must be initialized via [And].
3+
// interval represents a constraint that is both floor bounded and ceiling
4+
// bounded. It must be initialized via [And].
55
type interval struct {
66
upper Endless
77
lower Endless

or.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package comver
33
import "strings"
44

55
//nolint:godox
6-
// TODO: Make Or to be []Constrainter so that we can nest Or
6+
// TODO: Make Or to be []Constrainter so that we can nest Or.
77

8-
// Or represents a logical OR operation between multiple [CeilingFloorConstrainter] instances.
9-
// The zero value for Or is a [match none] constraint which could never be satisfied.
8+
// Or represents a logical OR operation between multiple
9+
// [CeilingFloorConstrainter] instances. The zero value for Or is a [match none]
10+
// constraint which could never be satisfied.
1011
//
1112
// [match none]: https://github.com/composer/semver/blob/main/src/Constraint/MatchNoneConstraint.php
1213
type Or []CeilingFloorConstrainter

version.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ type Version struct {
3838
// Parse parses a given version string, attempts to coerce a version string into
3939
// a [Version] object or return an error if unable to parse the version string.
4040
//
41-
// If there is a leading v or a version listed without all parts (e.g. v1.2.p5+foo) it
42-
// attempt to coerce it into a valid composer version (e.g. 1.2.0.0-patch5). In both cases
43-
// a [Version] object is returned that can be sorted, compared, and used in constraints.
41+
// If there is a leading v or a version listed without all parts
42+
// (e.g. v1.2.p5+foo) it attempt to coerce it into a valid composer version
43+
// (e.g. 1.2.0.0-patch5). In both cases a [Version] object is returned that can
44+
// be sorted, compared, and used in constraints.
4445
//
45-
// Due to implementation complexity, it only supports a subset of [composer versioning].
46-
// Refer to the [version_test.go] for examples.
46+
// Due to implementation complexity, it only supports a subset of
47+
// [composer versioning]. Refer to the [version_test.go] for examples.
4748
//
4849
// [composer versioning]: https://github.com/composer/semver/
4950
// [version_test.go]: https://github.com/typisttech/comver/blob/main/version_test.go

0 commit comments

Comments
 (0)