You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thriftgo generated code can't pass staticcheck, so we must write an extra config file staticcheck.conf to ignore some checks, but staticcheck will ignore all golang code files under the same directory tree which the config file placed
Reproduction
assume we have a thrift file named 'foo.thrift' and below is the content
go mod init code.byted.org/demo
thriftgo -g go -o ./ foo.thrift
go mod tidy
go mod edit -replace github.com/apache/thrift=github.com/apache/[email protected]
go mod tidy
staticcheck ./...
and will get the output
foo/foo.go:113:67: error strings should not be capitalized (ST1005)
Recommandation
add //lint:ignore directive to generator/golang/templates/struct.go::StructLikeRead
RequiredFieldNotSetError:
//lint:ignore ST1005 {some reasons}returnthrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_ModelSync[fieldId]))
use lowercase word instead
returnthrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_ModelSync[fieldId]))
That's awkward. Files generated by thriftgo all contains a header comment // Code generated by thriftgo (x.y.z). DO NOT EDIT. and staticcheck should ignore them as most linters do. Can you check if this is an issue of staticcheck ?
This is a known issue of staticcheck, but the author recommends 'generator' to fix the problems, and I also find a code review comment about error string: https://github.com/golang/go/wiki/CodeReviewComments#error-strings, so does this is a bad smell of thriftgo or there have some reasons to use capitalized in error string?
OK, we will fix the error string issue in the next version.
But after all, staticcheck does not follow the common way for ignoring generated files but asks all potential generators to meet its requirement. I think this is irrational.
And, DO NOT EDIT is recommended by the go officials. See golang/go#41196.
Description
thriftgo generated code can't pass
staticcheck
, so we must write an extra config filestaticcheck.conf
to ignore some checks, butstaticcheck
will ignore all golang code files under the same directory tree which the config file placedReproduction
assume we have a thrift file named 'foo.thrift' and below is the content
execute shell commands below
and will get the output
Recommandation
//lint:ignore
directive to generator/golang/templates/struct.go::StructLikeReadReference
The text was updated successfully, but these errors were encountered: