-
-
Notifications
You must be signed in to change notification settings - Fork 256
Addition of golang ci lint to pipeline #166
Replies: 1 comment · 2 replies
-
I suppose i would have to see the output of it running against gofakeit first before i would add it in totally. Not sure what value a linter would be for golang considering how well golang is setup currently |
Beta Was this translation helpful? Give feedback.
All reactions
-
I ran it with the below config (removed the annoying linters) and this was the result Resultcmd/gofakeitserver/main.go:227:6: `notfound` is unused (deadcode)
func notfound(w http.ResponseWriter) {
^
cmd/gofakeitserver/main.go:35:21: Error return value of `http.ListenAndServe` is not checked (errcheck)
http.ListenAndServe(":"+port, mux)
^
cmd/gofakeitserver/main.go:47:9: Error return value of `w.Write` is not checked (errcheck)
w.Write(gofakeit.ImagePng(32, 32))
^
cmd/gofakeitserver/main.go:183:12: Error return value of `enc.Encode` is not checked (errcheck)
enc.Encode(v)
^
cmd/gofakeitserver/main.go:218:9: Error return value of `w.Write` is not checked (errcheck)
w.Write(resp)
^
cmd/gofakeitserver/main.go:224:9: Error return value of `w.Write` is not checked (errcheck)
w.Write([]byte(msg))
^
cmd/gofakeitserver/main_test.go:46:6: S1023: redundant break statement (gosimple)
break
^
cmd/gofakeitserver/main_test.go:49:6: S1023: redundant break statement (gosimple)
break
^
cmd/gofakeitserver/main_test.go:56:6: S1023: redundant break statement (gosimple)
break
^
cmd/gofakeit/gofakeit.go:90:2: S1038: should use fmt.Printf instead of fmt.Println(fmt.Sprintf(...)) (but don't forget the newline) (gosimple)
fmt.Println(fmt.Sprintf("%v", value))
^
address_test.go:587:19: Error return value is not checked (errcheck)
LatitudeInRange(-90, 90)
^
address_test.go:595:21: Error return value of `f.LatitudeInRange` is not checked (errcheck)
f.LatitudeInRange(-90, 90)
^
address_test.go:603:21: Error return value of `f.LatitudeInRange` is not checked (errcheck)
f.LatitudeInRange(-90, 90)
^
address_test.go:647:20: Error return value is not checked (errcheck)
LongitudeInRange(-180, 180)
^
address_test.go:655:22: Error return value of `f.LongitudeInRange` is not checked (errcheck)
f.LongitudeInRange(-180, 180)
^
address_test.go:663:22: Error return value of `f.LongitudeInRange` is not checked (errcheck)
f.LongitudeInRange(-180, 180)
^
faker.go:30:12: Error return value of `crand.Read` is not checked (errcheck)
crand.Read(c.buf)
^
faker.go:50:14: Error return value of `binary.Read` is not checked (errcheck)
binary.Read(crand.Reader, binary.BigEndian, &seed)
^
generate_test.go:184:8: Error return value is not checked (errcheck)
Struct(&rg)
^
helpers.go:27:14: Error return value of `binary.Read` is not checked (errcheck)
binary.Read(crand.Reader, binary.BigEndian, &seed)
^
image.go:54:13: Error return value of `jpeg.Encode` is not checked (errcheck)
jpeg.Encode(buf, image(r, width, height), nil)
^
image.go:66:12: Error return value of `png.Encode` is not checked (errcheck)
png.Encode(buf, image(r, width, height))
^
struct_test.go:113:10: Error return value of `f.Struct` is not checked (errcheck)
f.Struct(&foo)
^
struct_test.go:174:10: Error return value of `f.Struct` is not checked (errcheck)
f.Struct(&fm)
^
xml.go:89:17: Error return value of `e.EncodeToken` is not checked (errcheck)
e.EncodeToken(xml.StartElement{Name: xml.Name{Local: key}})
^
xml.go:96:17: Error return value of `e.EncodeToken` is not checked (errcheck)
e.EncodeToken(xml.EndElement{Name: xml.Name{Local: key}})
^
xml.go:110:18: Error return value of `json.Unmarshal` is not checked (errcheck)
json.Unmarshal(inrec, &inInterface) Configlinters-settings:
depguard:
list-type: whitelist
include-go-root: false
packages:
- github.com/brianvoe/gofakeit/v6
revive:
ignore-generated-header: true
severity: warning
rules:
- name: indent-error-flow
severity: warning
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- importShadow
- hugeParam
gocyclo:
min-complexity: 15
golint:
min-confidence: 0
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
govet:
check-shadowing: true
lll:
line-length: 200
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
linters:
enable-all: true
disable:
# The fluent-bit-go(a CGO library) uses heavy use of interface{} making things very verbose
- forcetypeassert
# very aggressive whitespace linter
- wsl
# This enforces that all fields in a struct are explicitly defined during instantiation
# This is bad for readability because there are structs(Eg All AWS Lib structs, http client struct) have a
# lot of fields with sensible defaults explicitly defining all fields increases noise over signals.
- exhaustivestruct
# We are using global vars for storing kafka topic config as we dont see any other options
- gochecknoglobals
# Enforces usage of package level error declarations which is not desirable
- goerr113
# This enforces a newline before return and branch statements. We feel this makes the code less readable
- nlreturn
# We have no concerns default package import order
- gci
# We are happy with our existing gofmt(go's default formatting). Hence excluding stricter code formatting
- gofumpt
# Added this because its checking the fmt of imported package and failing because of that
- goimports
# Within a test suite it need not be mandated that everything should run in parallel
- paralleltest
# Having todos is a bit common especially when using a non PR workflow(i.e. direct pushes to master)
- godox
disable-all: false
fast: false
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
run:
skip-dirs:
- test/testdata_etc
- internal/cache
- internal/renameio
- internal/robustio Command
|
Beta Was this translation helpful? Give feedback.
All reactions
-
Oh boy that linter file looks crazy to me. It hurts me to think of adding that to the repo. As far as the handling errors go. Most of those are meant to be not handled. In situations where the value going in cannot be ran wrong I dont deal with the error for it. Considering in most situations I dont return errors. This is because I most situation when you want to generate something its easier to put it in the place you want to seed and if i returned an error they would have to move the generate line further away from where it would be used. Anyway I dont mind tackling some of these linting things but for the most part if it just yells at me for certain preferences gofakeit likes to do then it just becomes white noise |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
What are your thoughts on adding
https://github.com/golangci/golangci-lint
To the build pipeline?
I have personally used it in all my projects and i highly recommend it
Beta Was this translation helpful? Give feedback.
All reactions