From f7a5d8858fdbf4f2c4487cdb5e0d7965fee1f81d Mon Sep 17 00:00:00 2001 From: Fedor Korotkiy Date: Fri, 14 Feb 2020 15:39:06 +0300 Subject: [PATCH] Add golangci-lint config --- .golangci.yml | 77 +++++++++++++++++++ build.docker | 2 + .../testtool/commands/test_submission_test.go | 16 ++-- 3 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..4b4d4be --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,77 @@ +# options for analysis running +run: + # default concurrency is a available CPU number + concurrency: 8 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + deadline: 5m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" + format: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + +# all available settings of specific linters +linters-settings: + govet: + # report about shadowed variables + check-shadowing: true + golint: + # minimal confidence for issues, default is 0.8 + min-confidence: 0.8 + gofmt: + # simplify code: gofmt with `-s` option, true by default + simplify: true + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: gitlab.com + +linters: + disable-all: true + enable: + - errcheck + - gofmt + - golint + - gosimple + - govet + - ineffassign + - scopelint + - staticcheck + - typecheck + - unconvert + + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # But independently from this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. To list all + # excluded by default patterns execute `golangci-lint run --help` + exclude: + - Using the variable on range scope .* in function literal + + # Independently from option `exclude` we use default exclude patterns, + # it can be disabled by this option. To list all + # excluded by default patterns execute `golangci-lint run --help`. + # Default value for this option is true. + exclude-use-default: true + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 diff --git a/build.docker b/build.docker index b735438..f65dd6d 100644 --- a/build.docker +++ b/build.docker @@ -3,3 +3,5 @@ FROM golang:1.13 RUN apt-get update && apt-get install -y \ rsync \ && rm -rf /var/lib/apt/lists/* + +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6 \ No newline at end of file diff --git a/tools/testtool/commands/test_submission_test.go b/tools/testtool/commands/test_submission_test.go index 845efae..6031b74 100644 --- a/tools/testtool/commands/test_submission_test.go +++ b/tools/testtool/commands/test_submission_test.go @@ -32,12 +32,12 @@ func Test_testSubmission_correct(t *testing.T) { require.Nil(t, err) for _, dir := range testDirs { - dir, err := filepath.Abs(dir) + absDir, err := filepath.Abs(dir) require.Nil(t, err) - problem := path.Base(dir) + problem := path.Base(absDir) t.Run(problem, func(t *testing.T) { - studentRepo := path.Join(dir, "student") - privateRepo := path.Join(dir, "private") + studentRepo := path.Join(absDir, "student") + privateRepo := path.Join(absDir, "private") require.NoError(t, testSubmission(studentRepo, privateRepo, problem)) }) @@ -49,13 +49,13 @@ func Test_testSubmission_incorrect(t *testing.T) { require.Nil(t, err) for _, dir := range testDirs { - dir, err := filepath.Abs(dir) + absDir, err := filepath.Abs(dir) require.Nil(t, err) - problem := path.Base(dir) + problem := path.Base(absDir) t.Run(problem, func(t *testing.T) { - studentRepo := path.Join(dir, "student") - privateRepo := path.Join(dir, "private") + studentRepo := path.Join(absDir, "student") + privateRepo := path.Join(absDir, "private") err := testSubmission(studentRepo, privateRepo, problem) require.Error(t, err)