Skip to content

Commit

Permalink
feat: fix linter deprecation warnings (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
rriski authored Sep 2, 2024
1 parent 7f40900 commit 153ad33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ linters:
- gocyclo
- gofmt
- goimports
- gomnd
- mnd
- gosec
- gosimple
- govet
Expand All @@ -27,6 +27,7 @@ linters:
- nakedret
- nestif
- nilerr
- nolintlint
- prealloc
- revive
- staticcheck
Expand All @@ -42,7 +43,9 @@ linters-settings:
min-len: 2
min-occurrences: 2
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
lll:
line-length: 120
tab-width: 4
Expand Down
11 changes: 5 additions & 6 deletions generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
queryParamArraySize = 2
)

// nolint:funlen,gocognit,gocyclo // It's a generator, it's supposed to be long, and we won't expand it.
//nolint:funlen,gocognit,gocyclo // It's a generator, it's supposed to be long, and we won't expand it.
func exec() error {
cfg := new(envConfig)

Expand Down Expand Up @@ -422,15 +422,14 @@ func exec() error {
for _, k := range sortedKeys(scope) {
v := scope[k]
err = writeStruct(file, v)

if err != nil {
return err
}
}

dirPath := filepath.Join(cfg.HandlerDir, fileName)

err = os.MkdirAll(dirPath, os.ModePerm)
err = os.MkdirAll(dirPath, dirMode)
if err != nil {
return err
}
Expand Down Expand Up @@ -463,9 +462,8 @@ func exec() error {
// reMakesSense sometimes there are invalid enums, for instance just a comma ","
var reMakesSense = regexp.MustCompile(`\w`)

// nolint:funlen // It's a generator, it's supposed to be long, and we won't expand it.
//nolint:funlen // It's a generator, it's supposed to be long, and we won't expand it.
func writeStruct(f *jen.File, s *Schema) error {
// nolint:nestif // It's a generator, it's supposed to be long, and we won't expand it.
if s.isEnum() {
kind := getScalarType(s)
o := f.Type().Id(s.CamelName)
Expand Down Expand Up @@ -563,7 +561,8 @@ func toSingle(src string) string {

const (
yamlTabSize = 2
writeMode = os.FileMode(0644)
writeMode = os.FileMode(0o644)
dirMode = os.FileMode(0o750)
)

// readConfig reads and formats the config
Expand Down
2 changes: 1 addition & 1 deletion generator/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ type Schema struct {
in, out bool // Request or Response DTO
}

// nolint:funlen,gocognit,gocyclo // It is easy to maintain and read, we don't need to split it
//nolint:funlen,gocognit,gocyclo // It is easy to maintain and read, we don't need to split it
func (s *Schema) init(doc *Doc, scope map[string]*Schema, name string) {
if s.Ref != "" {
other, err := doc.getSchema(s.Ref)
Expand Down

0 comments on commit 153ad33

Please sign in to comment.