Skip to content

Commit

Permalink
update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Jan 3, 2024
1 parent 81c7065 commit 57aa064
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: golangci/golangci-lint-action@v3
with:
version: v1.55.0
version: v1.55.2

go-mod-tidy:
runs-on: ubuntu-20.04
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- dupl
- errorlint
- exportloopref
- gochecknoinits
- gocritic
Expand All @@ -13,6 +16,7 @@ linters:
- prealloc
- revive
- unconvert
- tparallel
- wastedassign
- whitespace

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BASE_IMAGE = golang:1.21-alpine3.18
LINT_IMAGE = golangci/golangci-lint:v1.55.0
LINT_IMAGE = golangci/golangci-lint:v1.55.2

.PHONY: $(shell ls)

Expand Down
4 changes: 3 additions & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gomavlib
import (
"context"
"crypto/rand"
"errors"
"io"

"github.com/bluenviron/gomavlib/v2/pkg/frame"
Expand Down Expand Up @@ -141,7 +142,8 @@ func (ch *Channel) runReader(readerDone chan struct{}) {
for {
fr, err := ch.frw.Read()
if err != nil {
if _, ok := err.(*frame.ReadError); ok {
var eerr frame.ReadError
if errors.As(err, &eerr) {
ch.n.pushEvent(&EventParseError{err, ch})
continue
}
Expand Down
5 changes: 3 additions & 2 deletions channel_provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gomavlib

import (
"errors"
"fmt"
)

Expand Down Expand Up @@ -35,15 +36,15 @@ func (cp *channelProvider) run() {
for {
label, rwc, err := cp.eca.provide()
if err != nil {
if err != errTerminated {
if !errors.Is(err, errTerminated) {
panic("errTerminated is the only error allowed here")
}
break
}

ch, err := newChannel(cp.n, cp.eca, label, rwc)
if err != nil {
panic(fmt.Errorf("newChannel unexpected error: %s", err))
panic(fmt.Errorf("newChannel unexpected error: %w", err))

Check warning on line 47 in channel_provider.go

View check run for this annotation

Codecov / codecov/patch

channel_provider.go#L47

Added line #L47 was not covered by tests
}

cp.n.newChannel(ch)
Expand Down
6 changes: 3 additions & 3 deletions pkg/conversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func processDefinition(

def, err := definitionDecode(content)
if err != nil {
return nil, fmt.Errorf("unable to decode: %s", err)
return nil, fmt.Errorf("unable to decode: %w", err)

Check warning on line 322 in pkg/conversion/conversion.go

View check run for this annotation

Codecov / codecov/patch

pkg/conversion/conversion.go#L322

Added line #L322 was not covered by tests
}

addrPath, _ := filepath.Split(defAddr)
Expand Down Expand Up @@ -393,14 +393,14 @@ func getDefinition(isRemote bool, defAddr string) ([]byte, error) {
if isRemote {
byt, err := download(defAddr)
if err != nil {
return nil, fmt.Errorf("unable to download: %s", err)
return nil, fmt.Errorf("unable to download: %w", err)

Check warning on line 396 in pkg/conversion/conversion.go

View check run for this annotation

Codecov / codecov/patch

pkg/conversion/conversion.go#L396

Added line #L396 was not covered by tests
}
return byt, nil
}

byt, err := os.ReadFile(defAddr)
if err != nil {
return nil, fmt.Errorf("unable to open: %s", err)
return nil, fmt.Errorf("unable to open: %w", err)

Check warning on line 403 in pkg/conversion/conversion.go

View check run for this annotation

Codecov / codecov/patch

pkg/conversion/conversion.go#L403

Added line #L403 was not covered by tests
}
return byt, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/dialect/readwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewReadWriter(d *Dialect) (*ReadWriter, error) {

de, err := message.NewReadWriter(m)
if err != nil {
return nil, fmt.Errorf("message %T: %s", m, err)
return nil, fmt.Errorf("message %T: %w", m, err)
}

rw.messageRWs[m.GetID()] = de
Expand Down
6 changes: 3 additions & 3 deletions pkg/frame/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ type ReadError struct {
str string
}

func (e *ReadError) Error() string {
func (e ReadError) Error() string {
return e.str
}

func newError(format string, args ...interface{}) *ReadError {
return &ReadError{
func newError(format string, args ...interface{}) ReadError {
return ReadError{
str: fmt.Sprintf(format, args...),
}
}
Expand Down

0 comments on commit 57aa064

Please sign in to comment.