Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update go and golangci-lint #23

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.22.x]
go-version: [1.22.x, 1.23.x]
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand All @@ -32,5 +32,5 @@ jobs:
# conflicting guidance, run only on the most recent supported version.
# For the same reason, only check generated code on the most recent
# supported version.
if: matrix.go-version == '1.22.x'
if: matrix.go-version == '1.23.x'
run: make checkgenerate && make lint
19 changes: 5 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
run:
skip-dirs-use-default: false
linters-settings:
gocyclo:
min-complexity: 25
Expand All @@ -26,36 +24,29 @@ linters:
enable-all: true
disable:
- cyclop # covered by gocyclo
- deadcode # abandoned
- depguard
- exhaustive
- exhaustivestruct # replaced by exhaustruct
- execinquery # deprecated in golangci v1.58
- exhaustruct
- funlen # rely on code review to limit function length
- gochecknoglobals # globals are fine
- gocognit # dubious "cognitive overhead" quantification
- gofumpt # prefer standard gofmt
- goimports # rely on gci instead
- golint # deprecated by Go team
- gomnd # some unnamed constants are okay
- ifshort # deprecated by author
- interfacer # deprecated by author
- gomnd # deprecated in golangci v1.58 in favor of mnd
- mnd # some unnamed constants are okay
- ireturn # "accept interfaces, return structs" isn't ironclad
- lll # don't want hard limits for line length
- maintidx # covered by gocyclo
- maligned # readability trumps efficient struct packing
- nilnil
- nlreturn # generous whitespace violates house style
- nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065
- protogetter
- scopelint # deprecated by author
- structcheck # abandoned
- testpackage # internal tests are fine
- varcheck # abandoned
- wrapcheck # don't _always_ need to wrap errors
- wsl # generous whitespace violates house style
issues:
exclude-dirs-use-default: false
exclude:
# Don't ban use of fmt.Errorf to create new errors, but the remaining
# checks from err113 are useful.
- "err113: do not define dynamic errors.*"
- "do not define dynamic errors.*"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $(BIN)/license-header: $(BIN) Makefile
go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@latest

$(BIN)/golangci-lint: $(BIN) Makefile
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.0

$(BIN)/jv: $(BIN) Makefile
go install github.com/santhosh-tekuri/jsonschema/cmd/jv@latest
10 changes: 5 additions & 5 deletions internal/protoschema/jsonschema/jsonschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,15 @@ func (p *jsonSchemaGenerator) generateEnumValidation(field protoreflect.FieldDes

func (p *jsonSchemaGenerator) generateIntValidation(_ protoreflect.FieldDescriptor, entry map[string]interface{}, bitSize int) {
// Use floats to handle integer overflow.
min := -math.Pow(2, float64(bitSize-1))
max := math.Pow(2, float64(bitSize-1))
minSize := -math.Pow(2, float64(bitSize-1))
maxSize := math.Pow(2, float64(bitSize-1))
Comment on lines +234 to +235
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed predeclared linting in Go v1.23.

if bitSize <= 53 {
entry["type"] = jsInteger
entry["minimum"] = min
entry["exclusiveMaximum"] = max
entry["minimum"] = minSize
entry["exclusiveMaximum"] = maxSize
} else {
entry["anyOf"] = []map[string]interface{}{
{"type": jsInteger, "minimum": min, "maximum": max},
{"type": jsInteger, "minimum": minSize, "maximum": maxSize},
{"type": jsString, "pattern": "^[0-9]+$"},
}
}
Expand Down
Loading