Add golangci-lint config
This commit is contained in:
parent
58a2d0919f
commit
f7a5d8858f
3 changed files with 87 additions and 8 deletions
77
.golangci.yml
Normal file
77
.golangci.yml
Normal file
|
@ -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
|
|
@ -3,3 +3,5 @@ FROM golang:1.13
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
rsync \
|
rsync \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& 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
|
|
@ -32,12 +32,12 @@ func Test_testSubmission_correct(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
for _, dir := range testDirs {
|
for _, dir := range testDirs {
|
||||||
dir, err := filepath.Abs(dir)
|
absDir, err := filepath.Abs(dir)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
problem := path.Base(dir)
|
problem := path.Base(absDir)
|
||||||
t.Run(problem, func(t *testing.T) {
|
t.Run(problem, func(t *testing.T) {
|
||||||
studentRepo := path.Join(dir, "student")
|
studentRepo := path.Join(absDir, "student")
|
||||||
privateRepo := path.Join(dir, "private")
|
privateRepo := path.Join(absDir, "private")
|
||||||
|
|
||||||
require.NoError(t, testSubmission(studentRepo, privateRepo, problem))
|
require.NoError(t, testSubmission(studentRepo, privateRepo, problem))
|
||||||
})
|
})
|
||||||
|
@ -49,13 +49,13 @@ func Test_testSubmission_incorrect(t *testing.T) {
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
for _, dir := range testDirs {
|
for _, dir := range testDirs {
|
||||||
dir, err := filepath.Abs(dir)
|
absDir, err := filepath.Abs(dir)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
problem := path.Base(dir)
|
problem := path.Base(absDir)
|
||||||
t.Run(problem, func(t *testing.T) {
|
t.Run(problem, func(t *testing.T) {
|
||||||
studentRepo := path.Join(dir, "student")
|
studentRepo := path.Join(absDir, "student")
|
||||||
privateRepo := path.Join(dir, "private")
|
privateRepo := path.Join(absDir, "private")
|
||||||
|
|
||||||
err := testSubmission(studentRepo, privateRepo, problem)
|
err := testSubmission(studentRepo, privateRepo, problem)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
|
|
Loading…
Reference in a new issue