ci: enable errorlint, forcetypeassert, goconst, gocritic linters#347
Merged
bfabio merged 1 commit intoitalia:mainfrom Mar 26, 2026
Merged
ci: enable errorlint, forcetypeassert, goconst, gocritic linters#347bfabio merged 1 commit intoitalia:mainfrom
bfabio merged 1 commit intoitalia:mainfrom
Conversation
bfabio
requested changes
Mar 26, 2026
parser.go
Outdated
| publiccodeValidator "github.com/italia/publiccode-parser-go/v5/validators" | ||
| ) | ||
|
|
||
| const schemeFile = "file" |
Member
There was a problem hiding this comment.
This one doesn't provide any actual value, it's just noise
d93b9e0 to
b47d27b
Compare
Contributor
Author
|
Done, removed goconst and the constant. |
errorlint: replace type assertions/switches on error with errors.As in parser.go and publiccode-parser/; fix %v → %w in validations.go. forcetypeassert: use ok-form for PublicCodeV0/V1 casts in fields.go; call fe.Error() directly in validators/validator.go since FieldError already embeds error. gocritic: rewrite if-else chain to switch in validators/validator.go; rewrite single-case switch to if in publiccode-parser/.
b47d27b to
7db78db
Compare
Contributor
Author
|
Rebased on main (phase 2 was merged). Also added //nolint:err113 on the two new dynamic-type error messages in fields.go. |
bfabio
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enables 4 linters from the planned phase 3 rollout.
errorlint: replace type assertions/switches on
errorwitherrors.Asinparser.goandpubliccode-parser/; fix%v→%winvalidations.go.forcetypeassert: use ok-form for
PublicCodeV0/PublicCodeV1casts infields.go; callfe.Error()directly invalidators/validator.gosinceFieldErroralready embedserror.goconst: extract the
"file"URL scheme string to aschemeFileconstant inparser.go(3 occurrences).gocritic: rewrite if-else chain to switch in
validators/validator.go; rewrite single-case switch to if inpubliccode-parser/.