Skip to content

Conversation

@atombrella
Copy link
Contributor

What this PR does / why we need it:

Use errors.As instead of type-casting, errors.Is for comparison and use of %w for error formatting in fmt.Errorf. The changes do not fully fix all of errorlint. I don't feel comfortable touching files under v1-3 as this may break compatibility with API users.

I have not successfully been able to change the use of switch with comparison of the error type. There are a few instances of this:

pkg/provenance/sign_test.go:401:9: type switch on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
	switch err.(type) {
	       ^
pkg/strvals/parser.go:247:4: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
			case io.EOF:
			^
pkg/strvals/parser.go:379:3: switch on an error will fail on wrapped errors. Use errors.Is to check for specific errors (errorlint)
		case io.EOF:

Special notes for your reviewer:

If applicable:

  • this PR contains user facing changes (the docs needed label should be applied if so)
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 20, 2025
@atombrella atombrella changed the title Fix more errorlint warnings. Use errors.As and errors.Is for error handling. Fix more errorlint warnings. Use errors.As and errors.Is for error handling. Dec 20, 2025
Use errors.As instead of type-casting, errors.Is for comparison and
use of %w for error formatting in fmt.Errorf. The changes do not fully
fix all of errorlint. I don't feel comfortable touching files under v1-3
as this may break compatibility with api users.

Signed-off-by: Mads Jensen <[email protected]>
Signed-off-by: Mads Jensen <[email protected]>
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from b16ab16 to 711204d Compare December 20, 2025 11:33
const warnStartDelim = "HELM_ERR_START"
const warnEndDelim = "HELM_ERR_END"
const recursionMaxNums = 1000
const (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this should be in a separate PR. Anyway, it's just a bit a syntactic sugar :)

@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 6ec8cd9 to 711204d Compare December 20, 2025 16:16
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 18e7091 to 6ded2ff Compare December 20, 2025 17:13
Signed-off-by: Mads Jensen <[email protected]>
Signed-off-by: Mads Jensen <[email protected]>
@atombrella atombrella force-pushed the feature/errorlint_as_round_2 branch from 6ded2ff to e597f7f Compare December 20, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants