Commit dc13ef6
authored
[skip-changelog] Added more lint checks and fixed some warnings. (#2610)
* Enabled more checks in golangci-lint
* Removed unreachable code (impossible condition detected by linter)
internal/arduino/sketch/sketch.go:108:14: nilness: impossible condition: non-nil == nil (govet)
if mainFile == nil {
^
* Removed function alias for i18n.Tr
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)
* Fixed a lot of i18n.Tr formatting errors
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)
* Removed useless call to i18n.Tr1 parent 914e11b commit dc13ef6
File tree
141 files changed
+1168
-1104
lines changed- commands
- cmderrors
- internal
- arduino
- builder
- internal
- compilation
- detector
- preprocessor
- cores
- packageindex
- packagemanager
- discovery/discoverymanager
- httpclient
- libraries
- librariesindex
- librariesmanager
- librariesresolver
- monitor
- resources
- security
- sketch
- cli
- arguments
- board
- burnbootloader
- cache
- compile
- completion
- configuration
- config
- core
- daemon
- debug
- feedback
- result
- generatedocs
- instance
- lib
- monitor
- outdated
- sketch
- updater
- update
- upgrade
- upload
- version
- inventory
- version
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
141 files changed
+1168
-1104
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
36 | 81 | | |
37 | 82 | | |
38 | 83 | | |
| |||
0 commit comments