Skip to content

Commit

Permalink
chore: update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Sep 20, 2024
1 parent feff022 commit 2be022a
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
- uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86
with:
version: v1.60.1
version: v1.61.0
17 changes: 8 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
run:
go: '1.22'

linters:
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
Expand Down Expand Up @@ -78,6 +77,7 @@ linters:
- tenv
- testableexamples
- testifylint
- testpackage
- thelper
- tparallel
- typecheck
Expand All @@ -89,26 +89,22 @@ linters:
- whitespace
- zerologlint
disable:
- canonicalheader
- copyloopvar
- cyclop
- depguard
- err113
- exhaustruct
- funlen
- gochecknoglobals
- gocognit
- gocyclo
- godox
- gomnd
- gosec
- lll
- maintidx
- mnd
- mnd
- nestif
- nlreturn
- stylecheck
- testpackage
- varnamelen
- wrapcheck
- wsl
Expand All @@ -131,6 +127,9 @@ issues:
- dupl
- scopelint
path: "_test\\.go"
- linters:
- err113
text: do not define dynamic errors, use wrapped static errors instead
- linters:
- forbidigo
path: "main\\.go"
1 change: 0 additions & 1 deletion generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ func TestGenerator(t *testing.T) {
),
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 4 additions & 3 deletions internal/tests/aixm/aixm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aixm
package aixm_test

import (
"archive/zip"
Expand All @@ -10,6 +10,7 @@ import (
"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/aixm"
)

func TestAIXM(t *testing.T) {
Expand Down Expand Up @@ -71,12 +72,12 @@ func TestAIXM(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, string(expectedSource), string(actualSource))

decodeZipFile := func(zipFile *zip.File) *AIXMBasicMessage {
decodeZipFile := func(zipFile *zip.File) *aixm.AIXMBasicMessage {
readCloser, err := zipFile.Open()
assert.NoError(t, err)
defer readCloser.Close()

var aixmBasicMessage AIXMBasicMessage
var aixmBasicMessage aixm.AIXMBasicMessage
assert.NoError(t, xml.NewDecoder(readCloser).Decode(&aixmBasicMessage))
return &aixmBasicMessage
}
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/gml/gml_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gml
package gml_test

import (
"archive/zip"
Expand Down
5 changes: 3 additions & 2 deletions internal/tests/gpx/gpx_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gpx
package gpx_test

import (
"bytes"
Expand All @@ -11,6 +11,7 @@ import (
"golang.org/x/net/html/charset"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/gpx"
)

func TestGPX(t *testing.T) {
Expand Down Expand Up @@ -58,7 +59,7 @@ func TestGPX(t *testing.T) {
decoder := xml.NewDecoder(bytes.NewReader(data))
decoder.CharsetReader = charset.NewReaderLabel

var gpx GPX
var gpx gpx.GPX
assert.NoError(t, decoder.Decode(&gpx))

switch filename {
Expand Down
5 changes: 3 additions & 2 deletions internal/tests/interlis/interlis_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interlis
package interlis_test

import (
"encoding/xml"
Expand All @@ -8,6 +8,7 @@ import (
"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/interlis"
)

func TestInterlis(t *testing.T) {
Expand Down Expand Up @@ -44,7 +45,7 @@ func TestInterlis(t *testing.T) {

data, err := os.ReadFile("testdata/metadata_gm03.xml")
assert.NoError(t, err)
var transfer Transfer
var transfer interlis.Transfer
assert.NoError(t, xml.Unmarshal(data, &transfer))

assert.Equal(t, "geocat.ch", transfer.HeaderSection.Sender)
Expand Down
5 changes: 3 additions & 2 deletions internal/tests/jmdict/jmdict_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jmdict
package jmdict_test

import (
"compress/gzip"
Expand All @@ -11,6 +11,7 @@ import (
"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/jmdict"
)

func TestJMDict(t *testing.T) {
Expand Down Expand Up @@ -325,7 +326,7 @@ func TestJMDict(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, string(expectedSource), string(actualSource))

var jmDict JMDict
var jmDict jmdict.JMDict
func() {
file, err := os.Open("testdata/JMdict.gz")
if errors.Is(err, fs.ErrNotExist) {
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/osm/osm_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package osm
package osm_test

import (
"compress/bzip2"
Expand Down
5 changes: 3 additions & 2 deletions internal/tests/play/play_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package play
package play_test

import (
"bytes"
Expand All @@ -9,6 +9,7 @@ import (
"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/play"
)

func TestPlay(t *testing.T) {
Expand Down Expand Up @@ -53,7 +54,7 @@ func TestPlay(t *testing.T) {

data, err := os.ReadFile("testdata/all_well.xml")
assert.NoError(t, err)
var allsWellThatEndsWell Play
var allsWellThatEndsWell play.Play
assert.NoError(t, xml.Unmarshal(data, &allsWellThatEndsWell))

assert.Equal(t, 5, len(allsWellThatEndsWell.Act))
Expand Down
2 changes: 1 addition & 1 deletion internal/tests/svg/svg_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package svg
package svg_test

import (
"archive/tar"
Expand Down
9 changes: 5 additions & 4 deletions internal/tests/xsd/xsd_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xsd
package xsd_test

import (
"bytes"
Expand All @@ -10,6 +10,7 @@ import (
"golang.org/x/net/html/charset"

"github.com/twpayne/go-xmlstruct"
"github.com/twpayne/go-xmlstruct/internal/tests/xsd"
)

func TestXSD(t *testing.T) {
Expand Down Expand Up @@ -49,12 +50,12 @@ func TestXSD(t *testing.T) {
decoder := xml.NewDecoder(bytes.NewReader(data))
decoder.CharsetReader = charset.NewReaderLabel

var schema Schema
var schema xsd.Schema
assert.NoError(t, decoder.Decode(&schema))

switch filename {
case "testdata/kml22gx.xsd":
assert.Equal(t, []Import{
assert.Equal(t, []xsd.Import{
{
Namespace: "http://www.opengis.net/kml/2.2",
SchemaLocation: "http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd",
Expand All @@ -63,7 +64,7 @@ func TestXSD(t *testing.T) {
case "testdata/ogckml22.xsd":
assert.Equal(t, "ogckml22.xsd 2008-01-23", *schema.Annotation.AppInfo)
case "testdata/xacml-core-v3-schema-wd-17.xsd":
assert.Equal(t, []Import{
assert.Equal(t, []xsd.Import{
{
Namespace: "http://www.w3.org/XML/1998/namespace",
SchemaLocation: "http://www.w3.org/2001/xml.xsd",
Expand Down
10 changes: 5 additions & 5 deletions xmlstruct_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package xmlstruct
package xmlstruct_test

import (
"encoding/xml"
"testing"

"github.com/alecthomas/assert/v2"

"github.com/twpayne/go-xmlstruct"
)

func TestDefaultExportNameFunc(t *testing.T) {
Expand Down Expand Up @@ -55,14 +57,13 @@ func TestDefaultExportNameFunc(t *testing.T) {
expected: "_",
},
} {
tc := tc
t.Run(tc.localName, func(t *testing.T) {
t.Parallel()

xmlName := xml.Name{
Local: tc.localName,
}
assert.Equal(t, tc.expected, DefaultExportNameFunc(xmlName))
assert.Equal(t, tc.expected, xmlstruct.DefaultExportNameFunc(xmlName))
})
}
}
Expand Down Expand Up @@ -123,14 +124,13 @@ func TestDefaultUnexportNameFunc(t *testing.T) {
expected: "_",
},
} {
tc := tc
t.Run(tc.localName, func(t *testing.T) {
t.Parallel()

xmlName := xml.Name{
Local: tc.localName,
}
assert.Equal(t, tc.expected, DefaultUnexportNameFunc(xmlName))
assert.Equal(t, tc.expected, xmlstruct.DefaultUnexportNameFunc(xmlName))
})
}
}

0 comments on commit 2be022a

Please sign in to comment.