Skip to content

ci: enable errorlint, forcetypeassert, goconst, gocritic linters#347

Merged
bfabio merged 1 commit intoitalia:mainfrom
creed-bratton:enable-linters-phase3
Mar 26, 2026
Merged

ci: enable errorlint, forcetypeassert, goconst, gocritic linters#347
bfabio merged 1 commit intoitalia:mainfrom
creed-bratton:enable-linters-phase3

Conversation

@creed-bratton
Copy link
Copy Markdown
Contributor

Enables 4 linters from the planned phase 3 rollout.

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/PublicCodeV1 casts in fields.go; call fe.Error() directly in validators/validator.go since FieldError already embeds error.

goconst: extract the "file" URL scheme string to a schemeFile constant in parser.go (3 occurrences).

gocritic: rewrite if-else chain to switch in validators/validator.go; rewrite single-case switch to if in publiccode-parser/.

parser.go Outdated
publiccodeValidator "github.com/italia/publiccode-parser-go/v5/validators"
)

const schemeFile = "file"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't provide any actual value, it's just noise

@creed-bratton creed-bratton force-pushed the enable-linters-phase3 branch 2 times, most recently from d93b9e0 to b47d27b Compare March 26, 2026 08:34
@creed-bratton
Copy link
Copy Markdown
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/.
@creed-bratton creed-bratton force-pushed the enable-linters-phase3 branch from b47d27b to 7db78db Compare March 26, 2026 08:42
@creed-bratton
Copy link
Copy Markdown
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 bfabio merged commit e7b56ea into italia:main Mar 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants