feat: exclude Swagger Codegen files (#4967)
This commit is contained in:
parent
0275389a64
commit
a6bd868cf0
@ -18,10 +18,19 @@ const (
|
|||||||
AutogeneratedModeDisable = "disable"
|
AutogeneratedModeDisable = "disable"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// The values must be in lowercase.
|
||||||
const (
|
const (
|
||||||
genCodeGenerated = "code generated"
|
genCodeGenerated = "code generated"
|
||||||
genDoNotEdit = "do not edit"
|
genDoNotEdit = "do not edit"
|
||||||
genAutoFile = "autogenerated file" // easyjson
|
|
||||||
|
// Related to easyjson.
|
||||||
|
genAutoFile = "autogenerated file"
|
||||||
|
|
||||||
|
//nolint:lll // Long URL
|
||||||
|
// Related to Swagger Codegen.
|
||||||
|
// https://github.com/swagger-api/swagger-codegen/blob/61cfeac3b9d855b4eb8bffa0d118bece117bcb7d/modules/swagger-codegen/src/main/resources/go/partial_header.mustache#L16
|
||||||
|
// https://github.com/swagger-api/swagger-codegen/issues/12358
|
||||||
|
genSwaggerCodegen = "* generated by: swagger codegen "
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ Processor = (*AutogeneratedExclude)(nil)
|
var _ Processor = (*AutogeneratedExclude)(nil)
|
||||||
@ -101,7 +110,7 @@ func (p *AutogeneratedExclude) shouldPassIssue(issue *result.Issue) (bool, error
|
|||||||
// The function uses a bit laxer rules than isGeneratedFileStrict to match more generated code.
|
// The function uses a bit laxer rules than isGeneratedFileStrict to match more generated code.
|
||||||
// See https://github.com/golangci/golangci-lint/issues/48 and https://github.com/golangci/golangci-lint/issues/72.
|
// See https://github.com/golangci/golangci-lint/issues/48 and https://github.com/golangci/golangci-lint/issues/72.
|
||||||
func (p *AutogeneratedExclude) isGeneratedFileLax(doc string) bool {
|
func (p *AutogeneratedExclude) isGeneratedFileLax(doc string) bool {
|
||||||
markers := []string{genCodeGenerated, genDoNotEdit, genAutoFile}
|
markers := []string{genCodeGenerated, genDoNotEdit, genAutoFile, genSwaggerCodegen}
|
||||||
|
|
||||||
doc = strings.ToLower(doc)
|
doc = strings.ToLower(doc)
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ func TestAutogeneratedExclude_isGeneratedFileLax_generated(t *testing.T) {
|
|||||||
* THIS FILE SHOULD NOT BE EDITED BY HAND
|
* THIS FILE SHOULD NOT BE EDITED BY HAND
|
||||||
*/`,
|
*/`,
|
||||||
`// AUTOGENERATED FILE: easyjson file.go`,
|
`// AUTOGENERATED FILE: easyjson file.go`,
|
||||||
|
` * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)`,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, comment := range comments {
|
for _, comment := range comments {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user