Skip to content

Commit

Permalink
Enable a bunch more linters
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstace committed Oct 10, 2023
1 parent 49ea768 commit 73888f7
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 112 deletions.
35 changes: 21 additions & 14 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ issues:
- thelper

linters-settings:
thelper:
# TODO: consider turning this check back on.
tb:
name: false
depguard:
rules:
main:
allow:
- $gostd
- github.com/peterstace/simplefeatures
- github.com/lib/pq
gosec:
excludes:
- G404 # Insecure random number source (rand)

linters:

Expand All @@ -35,39 +41,37 @@ linters:
- structcheck
- varcheck

- cyclop # Due to the nature of simplefeatures, cyclomatic complexity is going to be high.
- exhaustive # Switches on geometry type are often purposefully non-exhaustive.
- forbidigo # Overly prescriptive.
- funlen # Overly opinionated.
- gocyclo # Due to the nature of simplefeatures, cyclomatic complexity is going to be high.
- paralleltest # Most tests are CPU bound, so parallel tests don't make sense.

# Disabled because they're currently not passing cleanly.
- cyclop
- depguard
- dupl
- dupword
- errcheck
- errname
- errorlint
- exhaustive
- exhaustruct
- forbidigo
- forcetypeassert
- funlen
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- goerr113
- gomnd
- gosec
- lll
- maintidx
- nestif
- nilerr
- nlreturn
- nolintlint
- nonamedreturns
- paralleltest
- prealloc
- predeclared
- revive
Expand All @@ -76,20 +80,22 @@ linters:
- unconvert
- unparam
- varnamelen
- whitespace
- wrapcheck
- wsl

enable:

- gosec
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- depguard
- dogsled
- dupword
- durationcheck
- errchkjson
- execinquery
Expand Down Expand Up @@ -134,4 +140,5 @@ linters:
- unused
- usestdlibvars
- wastedassign
- whitespace
- zerologlint
6 changes: 3 additions & 3 deletions geom/alg_convex_hull.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

func convexHull(g Geometry) Geometry {
if g.IsEmpty() {
// Any empty geometry could be returned here to to give correct
// behaviour. However, to replicate PostGIS behaviour, we always return
// the original geometry.
// Any empty geometry could be returned here to give correct behaviour.
// However, to replicate PostGIS behaviour, we always return the
// original geometry.
return g.Force2D()
}

Expand Down
2 changes: 1 addition & 1 deletion geom/alg_exact_equals.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func newExactEqualsComparator(opts []ExactEqualsOption) exactEqualsComparator {
}

// ToleranceXY modifies the behaviour of the ExactEquals method by allowing two
// geometry control points be be considered equal if their XY coordinates are
// geometry control points be considered equal if their XY coordinates are
// within the given euclidean distance of each other.
func ToleranceXY(within float64) ExactEqualsOption {
return func(c exactEqualsComparator) exactEqualsComparator {
Expand Down
1 change: 1 addition & 0 deletions geom/alg_set_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ func TestBinaryOp(t *testing.T) {
relate: "FF1F0F1F2",
},
{
//nolint:dupword
/*
+--A&B--+---A---+
| | |
Expand Down
3 changes: 0 additions & 3 deletions geom/twkb_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ func (p *twkbParser) parseBBoxHeader(twkb []byte) (bbox []Point, err error) {
minPt := NewPoint(Coordinates{XY: XY{minX, minY}, Z: minZ, M: minM, Type: p.ctype})
maxPt := NewPoint(Coordinates{XY: XY{maxX, maxY}, Z: maxZ, M: maxM, Type: p.ctype})
bbox = []Point{minPt, maxPt}

} else if p.hasZ {
minX := p.scalings[0] * float64(p.bbox[0])
minY := p.scalings[1] * float64(p.bbox[2])
Expand All @@ -367,7 +366,6 @@ func (p *twkbParser) parseBBoxHeader(twkb []byte) (bbox []Point, err error) {
minPt := NewPoint(Coordinates{XY: XY{minX, minY}, Z: minZ, Type: p.ctype})
maxPt := NewPoint(Coordinates{XY: XY{maxX, maxY}, Z: maxZ, Type: p.ctype})
bbox = []Point{minPt, maxPt}

} else if p.hasM {
minX := p.scalings[0] * float64(p.bbox[0])
minY := p.scalings[1] * float64(p.bbox[2])
Expand All @@ -380,7 +378,6 @@ func (p *twkbParser) parseBBoxHeader(twkb []byte) (bbox []Point, err error) {
minPt := NewPoint(Coordinates{XY: XY{minX, minY}, M: minM, Type: p.ctype})
maxPt := NewPoint(Coordinates{XY: XY{maxX, maxY}, M: maxM, Type: p.ctype})
bbox = []Point{minPt, maxPt}

} else {
minX := p.scalings[0] * float64(p.bbox[0])
minY := p.scalings[1] * float64(p.bbox[2])
Expand Down
2 changes: 1 addition & 1 deletion geom/twkb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func TestWriteTWKBSQLFile(t *testing.T) {
sql += "\n\n"
}

err := os.WriteFile("../twkb_sql.txt", []byte(sql), 0o644)
err := os.WriteFile("../twkb_sql.txt", []byte(sql), 0o600)
expectNoErr(t, err)
}

Expand Down
2 changes: 1 addition & 1 deletion geom/type_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// cases where the width or height (or both) are zero, or the envelope is
// empty. Its bounds are validated so as to not be NaN or +/- Infinity.
//
// An envelope can be thought of as as being similar to a regular geometry, but
// An envelope can be thought of as being similar to a regular geometry, but
// can only represent an empty geometry, a single point, a horizontal or
// vertical line, or an axis aligned rectangle with some area.
//
Expand Down
Loading

0 comments on commit 73888f7

Please sign in to comment.