Skip to content

Commit

Permalink
chore: linter config tidy up, fixup some new linter complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Mar 28, 2024
1 parent ed01781 commit 6ed05e3
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
unit-test:
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 12
max-parallel: 14
matrix:
os:
- ubuntu-latest
Expand All @@ -21,6 +21,7 @@ jobs:
- "1.19"
- "1.20"
- "1.21"
- "1.22"
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -33,7 +34,7 @@ jobs:
- name: lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.57
args: --timeout 5m
- name: install gotestsum
run: go install gotest.tools/[email protected]
Expand All @@ -47,7 +48,7 @@ jobs:
os:
- ubuntu-latest
go-version:
- "1.21"
- "1.22"
runtime:
- "docker"
needs:
Expand Down
7 changes: 4 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ issues:
max-same-issues: 0
# https://github.com/golangci/golangci-lint/issues/2439#issuecomment-1002912465
exclude-use-default: false
exclude-dirs:
- private
- .private
exclude-rules:
- path: _test\.go
linters:
Expand All @@ -115,11 +118,9 @@ issues:

run:
go: '1.21'
skip-dirs:
- private

output:
uniq-by-line: false

service:
golangci-lint-version: 1.54.x
golangci-lint-version: 1.57.x
1 change: 0 additions & 1 deletion driver/generic/sendcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (d *Driver) SendCommands(
op,
opts...,
)

if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions driver/generic/sendwithcallbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestSendWithCallbacks(t *testing.T) {
initialInput: "",
callbacks: []*generic.Callback{
{
Callback: func(d *generic.Driver, s string) error {
Callback: func(d *generic.Driver, _ string) error {
_, err := d.Channel.SendInput("configure terminal")

return err
Expand All @@ -82,7 +82,7 @@ func TestSendWithCallbacks(t *testing.T) {
ResetOutput: true,
},
{
Callback: func(d *generic.Driver, s string) error {
Callback: func(d *generic.Driver, _ string) error {
return d.Channel.WriteAndReturn([]byte("show version"), false)
},
ContainsRe: regexp.MustCompile(`(?im)^c3560cx\(config\)#`),
Expand Down
1 change: 1 addition & 0 deletions driver/netconf/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (d *Driver) read() {
b = []byte(ss[1])
} else if d.Channel.PromptPattern.Match(b) {
var messageID int

var subID int

messageID = getID(patterns.messageID.FindSubmatch(b))
Expand Down
8 changes: 4 additions & 4 deletions driver/options/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ func TestWithOnOpen(t *testing.T) {
cases := map[string]*optionsGenericDriverOnXTestCase{
"set-on-open": {
description: "simple set option test",
f: func(d *generic.Driver) error { return nil },
f: func(*generic.Driver) error { return nil },
o: &generic.Driver{},
isignored: false,
},
"ignored": {
description: "skipped due to ignored type",
f: func(d *generic.Driver) error { return nil },
f: func(*generic.Driver) error { return nil },
o: &network.Driver{},
isignored: true,
},
Expand Down Expand Up @@ -221,13 +221,13 @@ func TestWithOnClose(t *testing.T) {
cases := map[string]*optionsGenericDriverOnXTestCase{
"set-on-close": {
description: "simple set option test",
f: func(d *generic.Driver) error { return nil },
f: func(*generic.Driver) error { return nil },
o: &generic.Driver{},
isignored: false,
},
"ignored": {
description: "skipped due to ignored type",
f: func(d *generic.Driver) error { return nil },
f: func(*generic.Driver) error { return nil },
o: &network.Driver{},
isignored: true,
},
Expand Down
8 changes: 4 additions & 4 deletions driver/options/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func TestWithNetworkOnOpen(t *testing.T) {
cases := map[string]*optionsNetworkDriverOnXTestCase{
"set-on-open": {
description: "simple set option test",
f: func(d *network.Driver) error { return nil },
f: func(*network.Driver) error { return nil },
o: &network.Driver{},
isignored: false,
},
"ignored": {
description: "skipped due to ignored type",
f: func(d *network.Driver) error { return nil },
f: func(*network.Driver) error { return nil },
o: &generic.Driver{},
isignored: true,
},
Expand Down Expand Up @@ -98,13 +98,13 @@ func TestWithNetworkOnClose(t *testing.T) {
cases := map[string]*optionsNetworkDriverOnXTestCase{
"set-on-close": {
description: "simple set option test",
f: func(d *network.Driver) error { return nil },
f: func(*network.Driver) error { return nil },
o: &network.Driver{},
isignored: false,
},
"ignored": {
description: "skipped due to ignored type",
f: func(d *network.Driver) error { return nil },
f: func(*network.Driver) error { return nil },
o: &generic.Driver{},
isignored: true,
},
Expand Down
2 changes: 1 addition & 1 deletion response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (r *Response) Record(b []byte) {

s := util.StringContainsAnySubStrs(r.Result, r.FailedWhenContains)

if len(s) > 0 {
if s != "" {
r.Failed = &OperationError{
Input: r.Input,
Output: r.Result,
Expand Down
2 changes: 1 addition & 1 deletion transport/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (t *Standard) openBase(a *Args) error {
if a.Password != "" {
authMethods = append(authMethods, ssh.Password(a.Password),
ssh.KeyboardInteractive(
func(user, instruction string, questions []string, echos []bool) ([]string, error) {
func(_, _ string, questions []string, _ []bool) ([]string, error) {
answers := make([]string, len(questions))
for i := range answers {
answers[i] = a.Password
Expand Down
1 change: 0 additions & 1 deletion transport/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func (t *System) openNetconf(a *Args) error {
var err error

t.fd, err = pty.Start(c)

if err != nil {
a.l.Criticalf("encountered error spawning pty, error: %s", err)

Expand Down

0 comments on commit 6ed05e3

Please sign in to comment.