Skip to content

[skip changelog] Remove spurious argument from error message #1827

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

Merged
merged 1 commit into from
Aug 9, 2022
Merged

[skip changelog] Remove spurious argument from error message #1827

merged 1 commit into from
Aug 9, 2022

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Aug 8, 2022

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • [N/A] Docs have been added / updated (for bug fixes / features)
  • [N/A] UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

github.com/arduino/arduino-cli/i18n.Tr provides a fmt.Printf-style interface, where the first argument may serve as a template filled by subsequent arguments according to its format verbs.

The call modified in this PR contains a subsequent argument, but no verb in the format string to use it. This generates some cryptic content in the error message.

For example:

Error during install: Error downloading tool arduino:[email protected]: no versions available for the current OS%!(EXTRA *cores.ToolRelease=arduino:[email protected])

(note the unexpected %!(EXTRA *cores.ToolRelease=arduino:[email protected]))

What is the new behavior?

The cryptic content is not present in the error message:

For example:

Error during install: Error downloading tool arduino:[email protected]: no versions available for the current OS

The tool name is already provided in the correctly configured Message field of the error, so there is no need to include it in the Cause field as well, so the spurious argument can be removed entirely rather than the alternative fix of adjusting the format string argument. I suspect the spurious argument was simply the result of a copy/paste error.

Does this PR introduce a breaking change?

No breaking change

`github.com/arduino/arduino-cli/i18n.Tr` provides a `fmt.Printf`-style interface, where the first argument may serve as
a template filled by subsequent arguments according to its format verbs.

This call contains a subsequent argument, but no verb in the format string to use it. This generates some cryptic
content in the error message.

For example:

Error during install: Error downloading tool arduino:[email protected]: no versions available for the current OS%!(EXTRA *cores.ToolRelease=arduino:[email protected])

The tool name is already provided in the correctly configured `Message` field of the error, so there is no need to
include it in the `Cause` field as well, so the spurious argument can be removed entirely rather than the alternative
fix of adjusting the format string argument. I suspect the spurious argument was simply the result of a copy/paste error.
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Aug 8, 2022
@per1234 per1234 self-assigned this Aug 8, 2022
@codecov
Copy link

codecov bot commented Aug 8, 2022

Codecov Report

Merging #1827 (1a61693) into master (c7163b7) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master    #1827   +/-   ##
=======================================
  Coverage   35.86%   35.86%           
=======================================
  Files         231      231           
  Lines       19324    19324           
=======================================
  Hits         6930     6930           
  Misses      11569    11569           
  Partials      825      825           
Flag Coverage Δ
unit 35.86% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arduino/cores/packagemanager/download.go 22.89% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@cmaglie
Copy link
Member

cmaglie commented Aug 9, 2022

I think that there is a way to let golint to detect this kind of errors (i.e. tell the linter that tr is a printf style function and check that the arguments match the format string), but I never investigated how.

@per1234 per1234 merged commit 9075512 into arduino:master Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants