-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added more lint checks and fixed some warnings. #2610
Conversation
internal/arduino/sketch/sketch.go:108:14: nilness: impossible condition: non-nil == nil (govet) if mainFile == nil { ^
This allows a deeper lint-check of printf style functions, like: commands/instances.go:344:46: printf: github.com/arduino/arduino-cli/internal/i18n.Tr format %v reads arg #1, but call has 0 args (govet) s := status.Newf(codes.FailedPrecondition, i18n.Tr("Loading index file: %v"), err)
This commit fixes invalid calls to i18n.Tr. 1. Missing positional arguments, for example: return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s"), tool, err) in the above case the positional arguments must be part of the Tr call: - return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s"), tool, err) + return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s", tool, err)) 2. This also makes the fmt.Errorf call useless and it could be replaced by the less expensive errors.New: - return fmt.Errorf(i18n.Tr("installing %[1]s tool: %[2]s", tool, err)) + return errors.New(i18n.Tr("installing %[1]s tool: %[2]s", tool, err)) but we have cases of useless calls even when the string is a constant, for example: - err := fmt.Errorf(i18n.Tr("no instance specified")) + err := errors.New(i18n.Tr("no instance specified")) Unfortunately, this imperfection is not detected by the linter. 3. The "%w" directive is not supported directly in i18n.Tr, so we have to wrap it around another fmt.Errorf: - return nil, fmt.Errorf(i18n.Tr("reading library headers: %w"), err) + return nil, fmt.Errorf("%s: %w", i18n.Tr("reading library headers"), err)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2610 +/- ##
==========================================
- Coverage 70.30% 70.26% -0.04%
==========================================
Files 222 222
Lines 21262 21262
==========================================
- Hits 14948 14940 -8
- Misses 5131 5147 +16
+ Partials 1183 1175 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)configuration.schema.json
updated if new parameters are added.What kind of change does this PR introduce?
What is the current behavior?
No change
What is the new behavior?
Does this PR introduce a breaking change, and is titled accordingly?
No
Other information