Skip to content
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

Minor fix added return value to the compile function in command/compile #1

Merged
merged 3 commits into from
Mar 27, 2019

Conversation

Rocketct
Copy link
Collaborator

Fix return value in Command/compile/compile.go

cc: @cmaglie check and let me know the errors

@Rocketct Rocketct force-pushed the daemon branch 4 times, most recently from d424e15 to 34440d6 Compare March 25, 2019 16:51
@cmaglie cmaglie merged commit 6555b10 into cmaglie:daemon Mar 27, 2019
cmaglie added a commit that referenced this pull request May 21, 2024
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)
cmaglie added a commit that referenced this pull request May 21, 2024
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)
cmaglie added a commit that referenced this pull request May 21, 2024
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)
cmaglie added a commit that referenced this pull request May 24, 2024
…uino#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.Tr
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