MSP-3533 Update lint
This commit is contained in:
1 parent
4480d932e1
commit
843c6d36c2
14 files changed
+63
-40
No files matched your search
+46
-35
@@ -1,40 +1,48 @@
|
||||
run:
|
||||
timeout: 2m
|
||||
|
||||
allow-parallel-runners: true
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: controller #достаточное кол-во контекса на уровне контроллеров
|
||||
linters:
|
||||
- wrapcheck
|
||||
- path: transaction #транзакции прозрачны
|
||||
linters:
|
||||
- wrapcheck
|
||||
- path: middleware #отсутствует необходимость оборачивать ошибки
|
||||
linters:
|
||||
- wrapcheck
|
||||
- path: proxy
|
||||
linters:
|
||||
- gochecknoglobals
|
||||
- mnd
|
||||
- path: httperrors #отсутствует необходимость оборачивать ошибки
|
||||
linters:
|
||||
- wrapcheck
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- asciicheck
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- dogsled
|
||||
- errcheck
|
||||
- funlen
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gofmt
|
||||
- gomnd
|
||||
- goprintffuncname
|
||||
- gosimple
|
||||
- govet
|
||||
- nakedret
|
||||
- nestif
|
||||
- prealloc
|
||||
- rowserrcheck
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
- varcheck
|
||||
- gosec
|
||||
- misspell
|
||||
- whitespace
|
||||
- exhaustive #смотрит на соответствие между элементами enum и swich кейсами
|
||||
- exportloopref #for _,p := []int{1, 2, 3} { s.Bar(&p) /* If s stores the pointer, it will be bug.*/ }
|
||||
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed.
|
||||
enable-all: true
|
||||
disable:
|
||||
- goimports #у нас собственные правила форматирования импортов
|
||||
- wsl #расставление пробелов очень индивидуально
|
||||
- exhaustivestruct #не имеет смысла
|
||||
- varnamelen #очень индивидуально (db)
|
||||
- exhaustruct #не имеет смысла
|
||||
- golint #устарел
|
||||
- contextcheck #не имеет смысла
|
||||
- gci #у нас собственные правила форматирования импортов
|
||||
- gofumpt #у нас собственные правила форматирования импортов
|
||||
- nolintlint #Goland все равно форматирует с отступом
|
||||
- nlreturn #не всегда имеет смысл
|
||||
- godot #не актуально для свагера
|
||||
- ifshort #приняли решение, что мы так не пишем if err := ...; err != nil {}
|
||||
- godox #не позволяет оставлять todo
|
||||
- maligned #аллокацией памяти для структур конфликтует с удобством их чтения
|
||||
- nosnakecase #не позволяет заводить пакеты используя snake_case
|
||||
- depguard #не всегда имеет смысл
|
||||
- dupword #не имеет смысла
|
||||
- tagalign #не всегда имеет смысл
|
||||
- musttag #у нас собственные правило: не используем теги, если работаем с пакетом isp-kit/json и с внутренними структурами(между нашими сервисами), при этом теги обязательный для всех внених для нас структур
|
||||
- perfsprint #мнимая производительность в угоду читаемости
|
||||
- testpackage
|
||||
linters-settings:
|
||||
funlen:
|
||||
lines: 80
|
||||
@@ -53,3 +61,6 @@ linters-settings:
|
||||
- "-ST1020"
|
||||
- "-ST1021"
|
||||
- "-ST1022"
|
||||
testifylint:
|
||||
disable:
|
||||
- compares
|
||||
@@ -164,6 +164,7 @@ func (a *Assembly) Closers() []app.Closer {
|
||||
return closers
|
||||
}
|
||||
|
||||
// nolint:ireturn
|
||||
func (a *Assembly) redisClient(config conf.Redis) redis.UniversalClient {
|
||||
if config.Sentinel != nil {
|
||||
return redis.NewFailoverClient(&redis.FailoverOptions{
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location, redisCli
|
||||
)
|
||||
}
|
||||
entrypoint := middleware.Entrypoint(
|
||||
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:gomnd
|
||||
config.Http.MaxRequestBodySizeInMb*1024*1024, //nolint:mnd,gomnd
|
||||
handler,
|
||||
l.logger,
|
||||
middleware.EntryPointConfig{
|
||||
|
||||
Vendored
+3
@@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetBasic(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
@@ -23,6 +24,7 @@ func TestGetBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetExpired(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
@@ -36,6 +38,7 @@ func TestGetExpired(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNilValue(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
cache := cache.New()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint:gochecknoinits,lll
|
||||
package conf
|
||||
|
||||
import (
|
||||
|
||||
@@ -26,7 +26,7 @@ func (e HttpError) Error() string {
|
||||
}
|
||||
|
||||
func (e HttpError) WriteError(w http.ResponseWriter) error {
|
||||
w.Header().Set("content-type", "application/json")
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(e.statusCode)
|
||||
data := map[string]interface{}{
|
||||
"errorCode": http.StatusText(e.statusCode),
|
||||
|
||||
@@ -16,6 +16,7 @@ func (f HandlerFunc) Handle(ctx *request.Context) error {
|
||||
|
||||
type Middleware func(next Handler) Handler
|
||||
|
||||
// nolint:ireturn
|
||||
func Chain(root Handler, middlewares ...Middleware) Handler {
|
||||
for i := len(middlewares) - 1; i >= 0; i-- {
|
||||
root = middlewares[i](root)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint:gochecknoinits
|
||||
package proxy
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint:dupl
|
||||
package repository
|
||||
|
||||
import (
|
||||
|
||||
@@ -27,7 +27,7 @@ func (r DailyLimit) Increment(ctx context.Context, applicationId int, today time
|
||||
}
|
||||
|
||||
if value == 1 {
|
||||
err := r.cli.ExpireNX(ctx, key, 24*time.Hour).Err() //nolint:gomnd
|
||||
err := r.cli.ExpireNX(ctx, key, 24*time.Hour).Err() //nolint:mnd,gomnd
|
||||
if err != nil {
|
||||
return 0, errors.WithMessage(err, "expire nx")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint:dupl
|
||||
package repository
|
||||
|
||||
import (
|
||||
|
||||
@@ -30,7 +30,7 @@ func (r RedisAuthCache) Get(ctx context.Context, token string) (*domain.AuthData
|
||||
p.Get(ctx, token)
|
||||
return nil
|
||||
})
|
||||
if err != nil && err != redis.Nil {
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return nil, errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func (r RedisAuthzCache) Get(ctx context.Context, applicationId int, endpoint st
|
||||
p.Get(ctx, r.key(applicationId, endpoint))
|
||||
return nil
|
||||
})
|
||||
if err != nil && err != redis.Nil {
|
||||
if err != nil && !errors.Is(err, redis.Nil) {
|
||||
return false, errors.WithMessage(err, "pipelined")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// nolint:canonicalheader
|
||||
package tests
|
||||
|
||||
import (
|
||||
@@ -262,6 +263,7 @@ func (s *HappyPathTestSuite) TestAdminAuthorization() {
|
||||
require.EqualValues(http.StatusForbidden, errResp.StatusCode)
|
||||
}
|
||||
|
||||
// nolint:ireturn
|
||||
func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, redis.UniversalClient, *client.Client, *client.Client) {
|
||||
require := test.Assert()
|
||||
redisCli := NewRedis(test)
|
||||
@@ -324,6 +326,7 @@ func (s *HappyPathTestSuite) commonDependencies(test *test.Test) (conf.Remote, r
|
||||
}
|
||||
|
||||
func TestHappyPathTestSuite(t *testing.T) {
|
||||
t.Parallel()
|
||||
suite.Run(t, new(HappyPathTestSuite))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user