Skip to content

Some static-check fixes #1700

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 4 commits into from
Mar 28, 2022
Merged

Some static-check fixes #1700

merged 4 commits into from
Mar 28, 2022

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Mar 28, 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)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)

What kind of change does this PR introduce?
Fixes a lot of staticcheck linter warnings. Two of them are actually non-critical bugs in i18n resource handling.

What is the current behavior?
No change in behaviour

Does this PR introduce a breaking change, and is
titled accordingly?

No breaking change.

cmaglie added 4 commits March 28, 2022 10:21
commands/core/search_test.go:24:2: package "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1" is being imported more than once (ST1019)
        commands/core/search_test.go:25:2: other import of "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
i18n/cmd/po/parser.go:34:2: should check returned error before deferring file.Close() (SA5001)
i18n/cmd/po/parser.go:105:48: cutset contains duplicate characters (SA1024)
arduino/libraries/librariesindex/json.go:33:38: unknown JSON option "required" (SA5008)
arduino/libraries/librariesindex/json.go:34:38: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:39:37: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:40:37: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:44:37: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:45:37: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:51:51: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:53:51: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:57:51: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:58:51: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:59:51: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:69:34: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:70:34: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:71:34: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:88:36: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:89:36: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:90:36: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:95:30: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:96:30: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:97:30: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:98:30: unknown JSON option "required" (SA5008)
arduino/cores/packageindex/index.go:99:30: unknown JSON option "required" (SA5008)
arduino/cores/tools.go:30:35: unknown JSON option "required" (SA5008)
arduino/cores/tools.go:37:36: unknown JSON option "required" (SA5008)
arduino/cores/tools.go:45:18: unknown JSON option "required" (SA5008)
arduino/sketch/sketch.go:51:14: unknown JSON option "required" (SA5008)
arduino/sketch/sketch.go:53:14: unknown JSON option "omitepty" (SA5008)
cli/lib/search.go:103:16: unknown JSON option "required" (SA5008)
cli/lib/search.go:107:24: unknown JSON option "required" (SA5008)
cli/lib/search.go:183:9: the argument is already a string, there's no need to use fmt.Sprintf (S1025)
arduino/builder/sketch.go:165:5: should use !bytes.Equal(existingBytes, source) instead (S1004)
arduino/builder/sketch_test.go:133:2: this value of err is never used (SA4006)
arduino/cores/board.go:125:3: the surrounding loop is unconditionally terminated (SA4004)
arduino/cores/packagemanager/package_manager.go:432:4: should replace loop with platforms = append(platforms, platform.GetAllInstalled()...) (S1011)
arduino/cores/status.go:191:28: func ToolDependency.extractTool is unused (U1000)
arduino/cores/status.go:203:28: func ToolDependency.extractRelease is unused (U1000)
arduino/libraries/librariesindex/json.go:141:9: empty branch (SA9003)
arduino/monitors/null.go:48:14: should use time.Since instead of time.Now().Sub (S1012)
arduino/resources/checksums.go:79:5: should use !bytes.Equal(algo.Sum(nil), digest) instead (S1004)
arduino/resources/checksums.go:155:6: func createPackageFile is unused (U1000)
arduino/resources/helpers.go:65:12: this condition occurs multiple times in this if/else if chain (SA4014)
arduino/resources/helpers_test.go:40:24: unnecessary use of fmt.Sprintf (S1039)
cli/feedback/feedback.go:187:12: should use String() instead of fmt.Sprintf (S1025)
cli/globals/globals.go:31:2: var tr is unused (U1000)
cli/lib/args.go:89:6: should use strings.EqualFold instead (SA6005)
commands/daemon/monitor.go:176:6: this value of slots is never used (SA4006)
@cmaglie cmaglie requested a review from a team March 28, 2022 08:44
@cmaglie cmaglie self-assigned this Mar 28, 2022
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Mar 28, 2022
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

Very nice!

That "required" option used in the json struct tags caused me a lot of confusion when I encountered it in this code base but couldn't find any information in the json package docs. I searched all over for documentation about it, found nothing, but couldn't believe it didn't have any purpose.

@cmaglie cmaglie merged commit 38ebf64 into arduino:master Mar 28, 2022
@cmaglie cmaglie deleted the staticcheck-fixes branch March 28, 2022 12:31
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.

3 participants