diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d5aeade..f8605c9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,12 +5,18 @@ on: jobs: lint: + name: ๐Ÿ“‹ Lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - name: โฌ‡๏ธ Git clone the repository + uses: actions/checkout@v3 + + - name: ๐Ÿ“ฆ Install Go + uses: actions/setup-go@v3 with: go-version: '1.21' - - uses: golangci/golangci-lint-action@v3 - with: - args: --timeout=5m + + - name: ๐Ÿงช Revive + run: | + go install github.com/mgechev/revive@latest + make lint diff --git a/Makefile b/Makefile index b4b4c43..d613623 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ build: # Run all lint checking with exit codes for CI. lint: - golint -set_exit_status `go list ./... | grep -v /vendor/` + revive -config revive.toml -set_exit_status ./cmd/... ./internal/... ./pkg/... # Run tests with coverage reporting. test: diff --git a/internal/mysql/provider/stdout/provider_test.go b/internal/mysql/provider/stdout/provider_test.go index d8b6e50..e7ca599 100644 --- a/internal/mysql/provider/stdout/provider_test.go +++ b/internal/mysql/provider/stdout/provider_test.go @@ -29,12 +29,12 @@ func TestMySQLGetSelectQueryFor(t *testing.T) { func TestMySQLGetSelectQueryForHandlingError(t *testing.T) { db, mock := mock.GetDB(t) dumper := NewClient(db, log.New(os.Stdout, "", 0)) - error := errors.New("broken") - mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(error) + e := errors.New("broken") + mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(e) query, err := dumper.GetSelectQueryForTable("table", provider.DumpParams{ SelectMap: map[string]map[string]string{"table": {"c2": "NOW()"}}, WhereMap: map[string]string{"table": "c1 > 0"}, }) - assert.Equal(t, error, err) + assert.Equal(t, e, err) assert.Equal(t, "", query) } diff --git a/internal/mysql/provider/utils/utils_test.go b/internal/mysql/provider/utils/utils_test.go index 7a0bc8d..f2e85b2 100644 --- a/internal/mysql/provider/utils/utils_test.go +++ b/internal/mysql/provider/utils/utils_test.go @@ -24,11 +24,11 @@ func TestMySQLGetColumnsForSelect(t *testing.T) { func TestMySQLGetColumnsForSelectHandlingErrorWhenQuerying(t *testing.T) { db, mock := mock.GetDB(t) - error := errors.New("broken") - mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(error) + e := errors.New("broken") + mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(e) columns, err := QueryColumnsForTable(db, "table", provider.DumpParams{ SelectMap: map[string]map[string]string{"table": {"col2": "NOW()"}}, }) - assert.Equal(t, err, error) + assert.Equal(t, err, e) assert.Empty(t, columns) } diff --git a/internal/mysql/write_test.go b/internal/mysql/write_test.go index c5f048b..62c014d 100644 --- a/internal/mysql/write_test.go +++ b/internal/mysql/write_test.go @@ -82,7 +82,7 @@ func TestMySQLDumpTableDataHandlingErrorFromSelectAllDataFor(t *testing.T) { db, mock := mock.GetDB(t) buffer := bytes.NewBuffer(make([]byte, 0)) dumper := NewClient(db, log.New(os.Stdout, "", 0), "stdout", "", "") - error := errors.New("fail") - mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(error) - assert.Equal(t, error, dumper.WriteTableData(buffer, "table", provider.DumpParams{})) + e := errors.New("fail") + mock.ExpectQuery("SELECT \\* FROM `table` LIMIT 1").WillReturnError(e) + assert.Equal(t, e, dumper.WriteTableData(buffer, "table", provider.DumpParams{})) } diff --git a/revive.toml b/revive.toml new file mode 100644 index 0000000..dbb727b --- /dev/null +++ b/revive.toml @@ -0,0 +1,32 @@ +ignoreGeneratedHeader = false +severity = "warning" +confidence = 0.8 +errorCode = 0 +warningCode = 0 + +[rule.blank-imports] +[rule.context-as-argument] +[rule.context-keys-type] +[rule.dot-imports] +[rule.error-return] +[rule.error-strings] +[rule.error-naming] +[rule.exported] +[rule.increment-decrement] +[rule.var-naming] +[rule.var-declaration] +[rule.range] +[rule.receiver-naming] +[rule.time-naming] +[rule.unexported-return] +[rule.indent-error-flow] +[rule.errorf] +[rule.empty-block] +[rule.superfluous-else] +[rule.unreachable-code] +[rule.redefines-builtin-id] + +# These should be uncommented and resolve in +# future pull requests. +# [rule.package-comments] +# [rule.unused-parameter]