Skip to content

Commit

Permalink
lint: Add more linters
Browse files Browse the repository at this point in the history
  • Loading branch information
guerinoni committed Dec 3, 2024
1 parent a32bab9 commit 9412088
Show file tree
Hide file tree
Showing 26 changed files with 209 additions and 156 deletions.
76 changes: 66 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,93 @@
linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
# - containedctx
- contextcheck
- copyloopvar
- decorder
- dogsled
# - dupl
- dupword
- durationcheck
- errcheck
# - errchkjson
- errname
# - errorlint
- fatcontext
- forbidigo
# - forcetypeassert
- gci
- ginkgolinter
- gocheckcompilerdirectives
# - gochecknoinits
- gochecksumtype
# - gocognit
- goconst
- gocritic
- gocyclo
- godot
# - godot
# - godox
- gofmt
# - goheader
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
# - gosec
- gosimple
- govet
- ineffassign
- gosmopolitan
- grouper
- iface
- importas
# - inamedparam
- interfacebloat
# - intrange
- loggercheck
# - maintidx
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- staticcheck
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- stylecheck
- typecheck
- tagalign
- tenv
- testableexamples
- thelper
- tparallel
- unconvert
- unused
- unparam
- usestdlibvars
- wastedassign
- whitespace
- zerologlint

linters-settings:
gofmt:
Expand Down
2 changes: 1 addition & 1 deletion analysisrequest/analysisrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ type Results interface {
}

type Builder interface {
FromJSON([]byte) (AnalysisRequest, error)
FromJSON(data []byte) (AnalysisRequest, error)
}
4 changes: 1 addition & 3 deletions analysisrequest/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (

var _ BasicAnalysisRequest = (*base)(nil)

var (
errBaseSnowflakeEmpty = errors.New("missing snowflake ID")
)
var errBaseSnowflakeEmpty = errors.New("missing snowflake ID")

// base is a struct containing the fields common to all the analysis requests.
//
Expand Down
9 changes: 3 additions & 6 deletions analysisrequest/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
"github.com/listendev/pkg/pypi"
)

var (
errBuilderInvalidAnalysisRequest = errors.New("invalid analysis request")
)
var errBuilderInvalidAnalysisRequest = errors.New("invalid analysis request")

type builder struct {
ctx context.Context
Expand All @@ -28,7 +26,7 @@ type builder struct {
func NewBuilder(ctx context.Context) (*builder, error) {
t := tracer.FromContext(ctx)
if t == nil {
return nil, fmt.Errorf("couldn't retrieve the tracer from context")
return nil, errors.New("couldn't retrieve the tracer from context")
}

return &builder{
Expand Down Expand Up @@ -196,8 +194,7 @@ func (b *builder) FromJSON(body []byte) (AnalysisRequest, error) {
return nil, errBuilderInvalidAnalysisRequest
}

type noOpBuilder struct {
}
type noOpBuilder struct{}

//nolint:revive // we are doing this on purpose (for now)
func NewNoOpBuilder() *noOpBuilder {
Expand Down
120 changes: 59 additions & 61 deletions analysisrequest/gen/reals.go
Original file line number Diff line number Diff line change
@@ -1,63 +1,61 @@
package gen

var (
realPackageTriples = []string{
"react 18.0.0 b468736d1f4a5891f38585ba8e8fb29f91c3cb96",
"@vue/devtools 6.5.0 32b09b0e3ca7b757802f9a0b9ded8c2035ce7874",
"alpinejs-component 1.1.2 31339edcd3eb3f9c9bb5cedb775cd33a141efaed",
"@alpinejs/ui 3.10.5-beta.8 a4b0edc67b3c8bcd6deafdb417579e5bbdfbedc4",
"alpinejs-notify 1.0.2 6e7475154cf3b171602d161aa45bd77cf33070bf",
"alpinejs-ray 1.1.1 8c65b5cf52f157f280bb0b84b1ddc0c2d4936693",
"@alpinejs/trap 3.2.3 a4900ecf3ebc797345380bc506fb8f4203c9e267",
"chalk 4.0.0 6e98081ed2d17faab615eb52ac66ec1fe6209e72",
"postcss-clean 1.2.1 0b1636c2a961fc1862856616484689be7eaff417",
"debug 4.2.0 7f150f93920e94c58f5574c2fd01a3110effe7f1",
"kube 1.2.4 301f0f72e3bf18d7ace131e78acc16fc69c09da2",
"vue 0.8.2 c1d30517b5160982a48ea22022b6974bd1bbde6a",
"@babel/highlight 7.9.0 4e9b45ccb82b79607271b2979ad82c7b68163079",
"support-color 7.1.0 6e6e25a258e16a0148cdc92f0950e60c9c24617c",
"ansi-color 0.2.1 3e75c037475217544ed763a8db5709fa9ae5bf9a",
"con 0.1.3 8424faee53b2b5abf9089d7095319c685f0a6455",
"replicate 0.9.3 34e3900e95af012c9fc103aadabc72b474ad6a2c",
"table 3.3.0 e5fb6522f862363757a8210c34a35d0c22d969ea",
"@beisen-cmps/italent-task-common-component 1.0.2 79e4d83b21034bb46ba7fd2f0270d1c3eb99f0d8",
"@pozible/mongoose-yas 0.6.0 41a18b24c61ffe7e3a69e7921632c84473a80067",
"@tweetscore/ui 0.0.50 964172ee69cf232331ab6a8a01234509f7f6b8cf",
"lipicker 0.0.6 2c34bf508f4d809ba3d78ea885bf1c050a98ff2a",
"@geoblink/design-system 5.0.1 62747b77034886d1ec51fd298bccd7456f4675a7",
"@darkblock.io/shared-components 0.2.0-beta.110 c4df29e595ecaac8c246a563e29ccaa986e0d041",
"immutable-core-model-form 0.9.35 20d83724ee14ac009637e1deddc481d7b4f69a70",
"@wecity/weda-sdk 2.1.1 c0c8ae4f027e988ccb55666db047e7c182948f97",
"exframe-security 2.0.7 582394abbfd96c509181eb2eb7ee28f2444adadf",
"@instructure/quiz-grading 17.7.7-rc.2 436833a45e4eb4bd93d9b3bcf0a5c5b6d38d3461",
"@gitpod/gitpod-protocol 0.1.5-corneliusludmann-server-move-all-3144.70 8f23fb674071731f130ed8f8d0656e4545029686",
"@covr/components 0.3.4 169dda925a92ac12a5478622d0d2c82cdbfca509",
"@storybook/html 6.3.0-alpha.25 f8e118d411407514ce27b2523f67d9ca24467a1a",
"jsbattle 2.0.2 a77638a5e65f511df114c4d52b88ff0769f19211",
"rx-form 2.0.17 b42ff385c03d46169e0f4afc956107f0da63dadc",
"@trxn/terraform-service-pwa 2.1.2 fc81b344e1850b1c5684c2abf4e54d55876d5276",
"@ctx-core/auth0-management 9.2.120 5e4baa421489b693fc597ac497ea96d1cca0bb01",
"mfl-models 1.0.74 57af0cd8e870e3e1539ee20c678d3cd344c473c5",
"a06-upload-sdk 1.0.0 e55701d90d77621da4d42428d42f47dc41ea8f34",
"@ionic-native/baidu-push 5.4.0 3e59e9dc492e7457f2add6aefbf6725054a1c515",
"@tidec/notify-library 1.2.0 c6ba84c117be03275b6bc98f1d8cafa69a915bc9",
"@scrapp_society/scrapp-auth 0.1.4 8f2d797cfae1e76204d4de031a62bef552e1308f",
"speechy 1.1.0 cc4e61cd02560ae7145ce2fdb0dbc3581a897258",
"@smartb/did-domain 0.1.0-1611677955484 7f9ca83dd4da407572be700f1e1293aca1214de8",
"@pangolindex/components 3.0.6-rc.9 ec37a333a7ec9fd03bebf3e38db4e7d105896f34",
"@ocap/schema 1.13.23 24bb3c5750726271533db3c780612666a3265fb8",
"@scaffoldly/serverless-util 4.0.38 7ecd86310c9c14a4fc3276e7b1039ac24088d43b",
"@cocos/bullet 1.0.1 2adb3995ce5798f69028b7820a894d2df151fc25",
"redux-devtools-extension 2.13.6 1e59bb9c4e6c05862ac7417c607d0201ca0854c1",
"ember-power-timepicker 1.0.7 077c68b5228a580b6cf206f68b11c18dc91c3ba7",
"date-utils 1.2.3 e614f9c4c612a9badb534032e26995fa7d100d06",
"esoftplay 0.0.83-e a9bf7d3eb087e93d57e2b0407aa45f1ce25cae9b",
"@layer0/nuxt 3.0.4-next-1618568966-d957fd94.0 afd548c0c35e75068e66950fd1a1a31e04e5f9af",
"@fruits-chain/react-native-lidong-template 0.70.8 b6beb90a54c90164b51102960c07fb34b79c4a1c",
"@kickstartds/core 1.0.1-canary.164.1017.0 3c61d7496f93e36baeddd64ba3244b6bde2adc5c",
"molecule-javascript 0.1.2 021be5bcbf8d05a77b240ed10bf43c2ec5ad5b65",
"tracking-worker 1.6.101 3f8870a8959cb2a7097eca359f23201c9c36ea1f",
"@mailchimp/mailchimp_marketing 3.0.36 4d169709d1e135aaa5eebb2bf2b31897ac0cce1c",
"@fluid-topics/ft-reader-topic-context 0.3.51 c76e14149da265351f704212982530dfdfd79405",
}
)
var realPackageTriples = []string{
"react 18.0.0 b468736d1f4a5891f38585ba8e8fb29f91c3cb96",
"@vue/devtools 6.5.0 32b09b0e3ca7b757802f9a0b9ded8c2035ce7874",
"alpinejs-component 1.1.2 31339edcd3eb3f9c9bb5cedb775cd33a141efaed",
"@alpinejs/ui 3.10.5-beta.8 a4b0edc67b3c8bcd6deafdb417579e5bbdfbedc4",
"alpinejs-notify 1.0.2 6e7475154cf3b171602d161aa45bd77cf33070bf",
"alpinejs-ray 1.1.1 8c65b5cf52f157f280bb0b84b1ddc0c2d4936693",
"@alpinejs/trap 3.2.3 a4900ecf3ebc797345380bc506fb8f4203c9e267",
"chalk 4.0.0 6e98081ed2d17faab615eb52ac66ec1fe6209e72",
"postcss-clean 1.2.1 0b1636c2a961fc1862856616484689be7eaff417",
"debug 4.2.0 7f150f93920e94c58f5574c2fd01a3110effe7f1",
"kube 1.2.4 301f0f72e3bf18d7ace131e78acc16fc69c09da2",
"vue 0.8.2 c1d30517b5160982a48ea22022b6974bd1bbde6a",
"@babel/highlight 7.9.0 4e9b45ccb82b79607271b2979ad82c7b68163079",
"support-color 7.1.0 6e6e25a258e16a0148cdc92f0950e60c9c24617c",
"ansi-color 0.2.1 3e75c037475217544ed763a8db5709fa9ae5bf9a",
"con 0.1.3 8424faee53b2b5abf9089d7095319c685f0a6455",
"replicate 0.9.3 34e3900e95af012c9fc103aadabc72b474ad6a2c",
"table 3.3.0 e5fb6522f862363757a8210c34a35d0c22d969ea",
"@beisen-cmps/italent-task-common-component 1.0.2 79e4d83b21034bb46ba7fd2f0270d1c3eb99f0d8",
"@pozible/mongoose-yas 0.6.0 41a18b24c61ffe7e3a69e7921632c84473a80067",
"@tweetscore/ui 0.0.50 964172ee69cf232331ab6a8a01234509f7f6b8cf",
"lipicker 0.0.6 2c34bf508f4d809ba3d78ea885bf1c050a98ff2a",
"@geoblink/design-system 5.0.1 62747b77034886d1ec51fd298bccd7456f4675a7",
"@darkblock.io/shared-components 0.2.0-beta.110 c4df29e595ecaac8c246a563e29ccaa986e0d041",
"immutable-core-model-form 0.9.35 20d83724ee14ac009637e1deddc481d7b4f69a70",
"@wecity/weda-sdk 2.1.1 c0c8ae4f027e988ccb55666db047e7c182948f97",
"exframe-security 2.0.7 582394abbfd96c509181eb2eb7ee28f2444adadf",
"@instructure/quiz-grading 17.7.7-rc.2 436833a45e4eb4bd93d9b3bcf0a5c5b6d38d3461",
"@gitpod/gitpod-protocol 0.1.5-corneliusludmann-server-move-all-3144.70 8f23fb674071731f130ed8f8d0656e4545029686",
"@covr/components 0.3.4 169dda925a92ac12a5478622d0d2c82cdbfca509",
"@storybook/html 6.3.0-alpha.25 f8e118d411407514ce27b2523f67d9ca24467a1a",
"jsbattle 2.0.2 a77638a5e65f511df114c4d52b88ff0769f19211",
"rx-form 2.0.17 b42ff385c03d46169e0f4afc956107f0da63dadc",
"@trxn/terraform-service-pwa 2.1.2 fc81b344e1850b1c5684c2abf4e54d55876d5276",
"@ctx-core/auth0-management 9.2.120 5e4baa421489b693fc597ac497ea96d1cca0bb01",
"mfl-models 1.0.74 57af0cd8e870e3e1539ee20c678d3cd344c473c5",
"a06-upload-sdk 1.0.0 e55701d90d77621da4d42428d42f47dc41ea8f34",
"@ionic-native/baidu-push 5.4.0 3e59e9dc492e7457f2add6aefbf6725054a1c515",
"@tidec/notify-library 1.2.0 c6ba84c117be03275b6bc98f1d8cafa69a915bc9",
"@scrapp_society/scrapp-auth 0.1.4 8f2d797cfae1e76204d4de031a62bef552e1308f",
"speechy 1.1.0 cc4e61cd02560ae7145ce2fdb0dbc3581a897258",
"@smartb/did-domain 0.1.0-1611677955484 7f9ca83dd4da407572be700f1e1293aca1214de8",
"@pangolindex/components 3.0.6-rc.9 ec37a333a7ec9fd03bebf3e38db4e7d105896f34",
"@ocap/schema 1.13.23 24bb3c5750726271533db3c780612666a3265fb8",
"@scaffoldly/serverless-util 4.0.38 7ecd86310c9c14a4fc3276e7b1039ac24088d43b",
"@cocos/bullet 1.0.1 2adb3995ce5798f69028b7820a894d2df151fc25",
"redux-devtools-extension 2.13.6 1e59bb9c4e6c05862ac7417c607d0201ca0854c1",
"ember-power-timepicker 1.0.7 077c68b5228a580b6cf206f68b11c18dc91c3ba7",
"date-utils 1.2.3 e614f9c4c612a9badb534032e26995fa7d100d06",
"esoftplay 0.0.83-e a9bf7d3eb087e93d57e2b0407aa45f1ce25cae9b",
"@layer0/nuxt 3.0.4-next-1618568966-d957fd94.0 afd548c0c35e75068e66950fd1a1a31e04e5f9af",
"@fruits-chain/react-native-lidong-template 0.70.8 b6beb90a54c90164b51102960c07fb34b79c4a1c",
"@kickstartds/core 1.0.1-canary.164.1017.0 3c61d7496f93e36baeddd64ba3244b6bde2adc5c",
"molecule-javascript 0.1.2 021be5bcbf8d05a77b240ed10bf43c2ec5ad5b65",
"tracking-worker 1.6.101 3f8870a8959cb2a7097eca359f23201c9c36ea1f",
"@mailchimp/mailchimp_marketing 3.0.36 4d169709d1e135aaa5eebb2bf2b31897ac0cce1c",
"@fluid-topics/ft-reader-topic-context 0.3.51 c76e14149da265351f704212982530dfdfd79405",
}
10 changes: 6 additions & 4 deletions analysisrequest/nop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
amqp "github.com/rabbitmq/amqp091-go"
)

var _ AnalysisRequest = (*NOP)(nil)
var _ Publisher = (*NOP)(nil)
var _ Deliverer = (*NOP)(nil)
var _ Results = (*NOP)(nil)
var (
_ AnalysisRequest = (*NOP)(nil)
_ Publisher = (*NOP)(nil)
_ Deliverer = (*NOP)(nil)
_ Results = (*NOP)(nil)
)

type NOP struct {
base
Expand Down
21 changes: 10 additions & 11 deletions analysisrequest/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,22 @@ import (
"context"
"encoding/json"
"errors"
"fmt"

"github.com/listendev/pkg/ecosystem"
"github.com/listendev/pkg/npm"
"github.com/listendev/pkg/observability/tracer"
amqp "github.com/rabbitmq/amqp091-go"
)

var _ AnalysisRequest = (*NPM)(nil)
var _ Publisher = (*NPM)(nil)
var _ Deliverer = (*NPM)(nil)
var _ Results = (*NPM)(nil)

var (
errNPMNameEmpty = errors.New("NPM package name is empty")
_ AnalysisRequest = (*NPM)(nil)
_ Publisher = (*NPM)(nil)
_ Deliverer = (*NPM)(nil)
_ Results = (*NPM)(nil)
)

var errNPMNameEmpty = errors.New("NPM package name is empty")

type NPMFillError struct {
Err error
}
Expand Down Expand Up @@ -51,7 +50,7 @@ type NPM struct {
func NewNPM(request Type, snowflake string, priority uint8, force bool, name, version, digest string) (AnalysisRequest, error) {
tc := request.Components()
if !tc.HasEcosystem() {
return nil, fmt.Errorf("couldn't instantiate an analysis request for NPM from a type without ecosystem at all")
return nil, errors.New("couldn't instantiate an analysis request for NPM from a type without ecosystem at all")
}
if tc.Ecosystem == ecosystem.Npm {
return &NPM{
Expand All @@ -69,7 +68,7 @@ func NewNPM(request Type, snowflake string, priority uint8, force bool, name, ve
}, nil
}

return nil, fmt.Errorf("couldn't instantiate an analysis request for NPM")
return nil, errors.New("couldn't instantiate an analysis request for NPM")
}

func (arn *NPM) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -174,10 +173,10 @@ func (arn NPM) ResultsPath() ResultUploadPath {
func (arn NPM) Switch(t Type) (AnalysisRequest, error) {
c := t.Components()
if !c.HasEcosystem() {
return nil, fmt.Errorf("couldn't switch the current NPM analysis request to an analysis request with a type without ecosystem")
return nil, errors.New("couldn't switch the current NPM analysis request to an analysis request with a type without ecosystem")
}
if c.Ecosystem != ecosystem.Npm {
return nil, fmt.Errorf("couldn't switch the current NPM analysis request to a non NPM one")
return nil, errors.New("couldn't switch the current NPM analysis request to a non NPM one")
}
arn.RequestType = t

Expand Down
Loading

0 comments on commit 9412088

Please sign in to comment.