mirror of
https://github.com/hairyhenderson/go-onerng.git
synced 2025-05-18 11:15:40 -05:00
fix(lint): Upgrade to golangci-lint v2, Go 1.24, and fixing lint errors
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
This commit is contained in:
parent
8b7020bdf1
commit
a28550c008
@ -1,24 +1,7 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
enable-all: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 10
|
||||
dupl:
|
||||
threshold: 100
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 4
|
||||
ignore-tests: true
|
||||
nolintlint:
|
||||
allow-unused: false # report any unused nolint directives
|
||||
require-explanation: false # don't require an explanation for nolint directives
|
||||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
||||
version: "2"
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
default: none
|
||||
enable:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
@ -26,25 +9,15 @@ linters:
|
||||
- dupl
|
||||
- errcheck
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
# - funlen
|
||||
# - gci
|
||||
# - gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
# - godox
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goheader
|
||||
- goimports
|
||||
# - gomnd
|
||||
- gomodguard
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
@ -58,10 +31,50 @@ linters:
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- whitespace
|
||||
# - wsl
|
||||
|
||||
settings:
|
||||
dupl:
|
||||
threshold: 100
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 4
|
||||
gocyclo:
|
||||
min-complexity: 10
|
||||
govet:
|
||||
enable-all: true
|
||||
nolintlint:
|
||||
allow-unused: false # report any unused nolint directives
|
||||
require-explanation: false # don't require an explanation for nolint directives
|
||||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
|
||||
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
- linters:
|
||||
- goconst
|
||||
path: (.+)_test\.go
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
formatters:
|
||||
enable:
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
2
Makefile
2
Makefile
@ -48,7 +48,7 @@ test:
|
||||
endif
|
||||
|
||||
lint:
|
||||
@golangci-lint run --max-same-issues=0 --sort-results
|
||||
@golangci-lint run --max-same-issues=0
|
||||
|
||||
.PHONY: clean test build lint
|
||||
.DELETE_ON_ERROR:
|
||||
|
@ -184,8 +184,6 @@ func readCmd(cmd *cobra.Command, _ []string) error {
|
||||
|
||||
// humanizeBytes produces a human readable representation of an IEC size.
|
||||
// Taken from github.com/dustin/go-humanize
|
||||
//
|
||||
//nolint:gomnd
|
||||
func humanizeBytes(s float64) string {
|
||||
base := 1024.0
|
||||
sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}
|
||||
|
@ -21,7 +21,7 @@ func commands() *cobra.Command {
|
||||
This tool can be used to verify that the OneRNG device operates
|
||||
correctly, and that the firmware has not been tampered with.`,
|
||||
Version: version.Version,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
|
||||
cmd.SilenceErrors = true
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/hairyhenderson/go-onerng
|
||||
|
||||
go 1.21.5
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/spf13/cobra v1.8.0
|
||||
|
@ -442,6 +442,7 @@ func (o *OneRNG) AESWhitener(ctx context.Context, out io.Writer) (io.WriteCloser
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//nolint:staticcheck // not ready to change the algorithm yet
|
||||
stream := cipher.NewCFBEncrypter(block, iv)
|
||||
s := &cipher.StreamWriter{S: stream, W: out}
|
||||
|
||||
|
@ -43,8 +43,6 @@ func read(r io.Reader, p []byte) error {
|
||||
}
|
||||
|
||||
// readHeader reads the header and returns the length and the version
|
||||
//
|
||||
//nolint:gomnd
|
||||
func readHeader(r io.Reader) (length, version int, err error) {
|
||||
// read the length
|
||||
l := make([]byte, 3)
|
||||
@ -138,7 +136,6 @@ func verifyImage(signed, sig []byte, pubkey string) (signer *openpgp.Entity, err
|
||||
return signer, nil
|
||||
}
|
||||
|
||||
//nolint:gomnd
|
||||
func parseImage(image io.Reader, version, length int) (signed, sig []byte, err error) {
|
||||
c := make([]byte, length)
|
||||
n, err := io.ReadAtLeast(image, c, length)
|
||||
|
Loading…
x
Reference in New Issue
Block a user