Skip to content

Commit

Permalink
Fixed linter issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oherych authored Mar 3, 2023
1 parent 536a048 commit f2288c1
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 45 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.17.x, 1.18.x, 1.19.x, 1.20.x ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17
go-version: ${{ matrix.go-version }}

- name: Test
run: go test -v ./...
Expand All @@ -24,27 +27,15 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: '1.20'

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.29

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
version: v1.51.2
skip-cache: true
58 changes: 58 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
run:
timeout: 5m
modules-download-mode: readonly


output:
format: line-number

# Print lines of code with issue.
# Default: true
print-issued-lines: false


# Make issues output unique by line.
# Default: true
uniq-by-line: false



linters:
enable-all: true
disable:
- wrapcheck
- varnamelen
- thelper
- testpackage
- paralleltest
- gochecknoglobals
- forcetypeassert
- wsl
- dupl
- nonamedreturns
- nakedret
- lll
- godot
- gomnd
- godox # temporary
- errorlint
- typecheck
- forbidigo

# deprecated
- interfacer
- varcheck
- nosnakecase
- deadcode
- scopelint
- structcheck
- golint
- ifshort
- exhaustivestruct
- maligned

issues:
exclude-rules:
- path: _test\.go
linters:
- funlen
8 changes: 4 additions & 4 deletions adjust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

func TestClient_SetAdjust(t *testing.T) {
var testAction = AdjustActionIncrease
var testProp = AdjustPropBright
testAction := AdjustActionIncrease
testProp := AdjustPropBright

tests := map[string]struct {
tr transportFn
Expand Down Expand Up @@ -38,8 +38,8 @@ func TestClient_SetAdjust(t *testing.T) {
}

func TestClient_SetBackgroundAdjust(t *testing.T) {
var testAction = AdjustActionIncrease
var testProp = AdjustPropBright
testAction := AdjustActionIncrease
testProp := AdjustPropBright

tests := map[string]struct {
tr transportFn
Expand Down
3 changes: 2 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package yeelight

import (
"context"
"github.com/stretchr/testify/assert"
"reflect"
"testing"

"github.com/stretchr/testify/assert"
)

func TestNew(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions cron_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestClient_AddCron(t *testing.T) {
})
}
}

func TestClient_GetCron(t *testing.T) {
tests := map[string]struct {
on bool
Expand Down
2 changes: 1 addition & 1 deletion discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func readReadDiscoveryPayload(in string) (DiscoveryResultItem, error) {
const crlf = "\r\n"

if strings.HasSuffix(in, crlf) {
in = in + crlf
in += crlf
}

resp, err := http.ReadResponse(bufio.NewReader(strings.NewReader(in)), nil)
Expand Down
1 change: 0 additions & 1 deletion errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ import (

func TestUnknownError_Error(t *testing.T) {
assert.Equal(t, "im_test_error", UnknownError("im_test_error").Error())

}
1 change: 1 addition & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/oherych/yeelight"
)

//nolint:gocritic
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
Expand Down
12 changes: 6 additions & 6 deletions flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
)

func TestClient_StartColorFlow(t *testing.T) {
var testCount = 12
var testAction = FlowActionTurnOff
var testExpressions = []FlowExpression{
testCount := 12
testAction := FlowActionTurnOff
testExpressions := []FlowExpression{
{
Duration: time.Minute,
Mode: FlowModeColor,
Expand Down Expand Up @@ -59,9 +59,9 @@ func TestClient_StartColorFlow(t *testing.T) {
}

func TestClient_StartBackgroundColorFlow(t *testing.T) {
var testCount = 12
var testAction = FlowActionTurnOff
var testExpressions = []FlowExpression{
testCount := 12
testAction := FlowActionTurnOff
testExpressions := []FlowExpression{
{
Duration: time.Minute,
Mode: FlowModeColor,
Expand Down
7 changes: 0 additions & 7 deletions listen.go

This file was deleted.

2 changes: 1 addition & 1 deletion raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func defaultTransport(ctx context.Context, host string, raw string) ([]byte, err

res, err := bufio.NewReader(conn).ReadBytes('\n')
if err != nil {
return nil, fmt.Errorf("cannot read command result %s", err)
return nil, fmt.Errorf("cannot read command result %w", err)
}

return res, nil
Expand Down

0 comments on commit f2288c1

Please sign in to comment.