diff --git a/.golangci.yml b/.golangci.yml index a06e95e8f..0fe2eb496 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -37,6 +37,17 @@ linters: - wrapcheck - stylecheck - thelper + - nonamedreturns + - revive + - dupword + - exhaustruct + - varnamelen + - forcetypeassert + - ireturn + - maintidx + - govet + - nosnakecase + - testableexamples linters-settings: govet: diff --git a/bin/.go@1.17.pkg b/bin/.go-1.19.2.pkg similarity index 100% rename from bin/.go@1.17.pkg rename to bin/.go-1.19.2.pkg diff --git a/bin/.golangci-lint-1.37.0.pkg b/bin/.golangci-lint-1.50.0.pkg similarity index 100% rename from bin/.golangci-lint-1.37.0.pkg rename to bin/.golangci-lint-1.50.0.pkg diff --git a/bin/go b/bin/go index 9797b799e..50baf1754 120000 --- a/bin/go +++ b/bin/go @@ -1 +1 @@ -.go@1.17.pkg \ No newline at end of file +.go-1.19.2.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt index 9797b799e..50baf1754 120000 --- a/bin/gofmt +++ b/bin/gofmt @@ -1 +1 @@ -.go@1.17.pkg \ No newline at end of file +.go-1.19.2.pkg \ No newline at end of file diff --git a/bin/golangci-lint b/bin/golangci-lint index cf27348e6..b32e1a3b1 120000 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1 +1 @@ -.golangci-lint-1.37.0.pkg \ No newline at end of file +.golangci-lint-1.50.0.pkg \ No newline at end of file diff --git a/cmd/chroma/go.mod b/cmd/chroma/go.mod index 1cb1e7e10..29ecb0475 100644 --- a/cmd/chroma/go.mod +++ b/cmd/chroma/go.mod @@ -1,6 +1,6 @@ module github.com/alecthomas/chroma/v2/cmd/chroma -go 1.17 +go 1.19 replace github.com/alecthomas/chroma/v2 => ../../ diff --git a/cmd/chroma/go.sum b/cmd/chroma/go.sum index 19cd2e604..eeade3bdb 100644 --- a/cmd/chroma/go.sum +++ b/cmd/chroma/go.sum @@ -1,12 +1,13 @@ +github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw= github.com/alecthomas/kong v0.2.17 h1:URDISCI96MIgcIlQyoCAlhOmrSw6pZScBNkctg8r0W0= github.com/alecthomas/kong v0.2.17/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ= -github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY= -github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= +github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= diff --git a/cmd/chromad/go.mod b/cmd/chromad/go.mod index d31551fb3..830455775 100644 --- a/cmd/chromad/go.mod +++ b/cmd/chromad/go.mod @@ -1,6 +1,6 @@ module github.com/alecthomas/chroma/v2/cmd/chromad -go 1.17 +go 1.19 require ( github.com/alecthomas/chroma/v2 v2.0.0-00010101000000-000000000000 diff --git a/cmd/chromad/go.sum b/cmd/chromad/go.sum index f64caf2b4..2f9e7c5e3 100644 --- a/cmd/chromad/go.sum +++ b/cmd/chromad/go.sum @@ -1,11 +1,10 @@ +github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw= github.com/alecthomas/kong v0.2.1-0.20190721020729-f7d3d9bfb5ed/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI= github.com/alecthomas/kong v0.2.4 h1:Y0ZBCHAvHhTHw7FFJ2FzCAAG4pkbTgA45nc7BpMhDNk= github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/kong-hcl v0.2.0 h1:l1+pkGJm2BtRJF9dCq9hw6KZWEanteY4Ar9suW3Qm0g= github.com/alecthomas/kong-hcl v0.2.0/go.mod h1:S5D46RHGG8Ubdxk8TuXBT9wndShsA8/JYSxxiI9y01Y= -github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY= -github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= @@ -20,16 +19,12 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/coalesce_test.go b/coalesce_test.go index bc26e038f..d003ffa51 100644 --- a/coalesce_test.go +++ b/coalesce_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/stretchr/testify/assert" + assert "github.com/alecthomas/assert/v2" ) func TestCoalesce(t *testing.T) { diff --git a/colour_test.go b/colour_test.go index 87f32a642..45e215cd5 100644 --- a/colour_test.go +++ b/colour_test.go @@ -4,7 +4,7 @@ import ( "math" "testing" - "github.com/stretchr/testify/assert" + assert "github.com/alecthomas/assert/v2" ) func TestColourRGB(t *testing.T) { @@ -62,12 +62,10 @@ func hue(c Colour) float64 { } func TestColourClampBrightness(t *testing.T) { - const delta = 0.01 // used for brightness and hue comparisons - // Start with a colour with a brightness close to 0.5. initial := NewColour(0, 128, 255) br := initial.Brightness() - assert.InDelta(t, 0.5, br, delta) + assertInDelta(t, 0.5, br) // Passing a range that includes the colour's brightness should be a no-op. assert.Equal(t, initial.String(), initial.ClampBrightness(br-0.01, br+0.01).String()) @@ -79,10 +77,15 @@ func TestColourClampBrightness(t *testing.T) { // Clamping to a brighter or darker range should produce the requested // brightness while preserving the colour's hue. brighter := initial.ClampBrightness(0.75, 1) - assert.InDelta(t, 0.75, brighter.Brightness(), delta) - assert.InDelta(t, hue(initial), hue(brighter), delta) + assertInDelta(t, 0.75, brighter.Brightness()) + assertInDelta(t, hue(initial), hue(brighter)) darker := initial.ClampBrightness(0, 0.25) - assert.InDelta(t, 0.25, darker.Brightness(), delta) - assert.InDelta(t, hue(initial), hue(darker), delta) + assertInDelta(t, 0.25, darker.Brightness()) + assertInDelta(t, hue(initial), hue(darker)) +} + +func assertInDelta(t *testing.T, expected, actual float64) { + const delta = 0.01 // used for brightness and hue comparisons + assert.True(t, actual > (expected-delta) && actual < (expected+delta)) } diff --git a/delegate_test.go b/delegate_test.go index f37d18740..083896afa 100644 --- a/delegate_test.go +++ b/delegate_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/stretchr/testify/assert" + assert "github.com/alecthomas/assert/v2" ) func makeDelegationTestLexers(t *testing.T) (lang Lexer, root Lexer) { diff --git a/formatters/html/html_test.go b/formatters/html/html_test.go index d86eb7791..2670a9073 100644 --- a/formatters/html/html_test.go +++ b/formatters/html/html_test.go @@ -4,10 +4,11 @@ import ( "bytes" "fmt" "io/ioutil" + "regexp" "strings" "testing" - "github.com/stretchr/testify/assert" + assert "github.com/alecthomas/assert/v2" "github.com/alecthomas/chroma/v2" "github.com/alecthomas/chroma/v2/lexers" @@ -117,7 +118,7 @@ func TestTabWidthStyle(t *testing.T) { err = f.Format(&buf, styles.Fallback, it) assert.NoError(t, err) - assert.Regexp(t, `
echo FOO
\n