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

chore: use golangci lint #986

Merged
merged 1 commit into from
Jul 13, 2023
Merged

chore: use golangci lint #986

merged 1 commit into from
Jul 13, 2023

Conversation

kranurag7
Copy link
Contributor

What this PR does / why we need it:
The following are the places that's giving some errors as of now according to the linter.

output of running golangci locally

$ golangci-lint run
cmd/oras/root/attach.go:94:22: Error return value of `cmd.MarkFlagRequired` is not checked (errcheck)
        cmd.MarkFlagRequired("artifact-type")
                            ^
cmd/oras/root/discover.go:191:13: Error return value is not checked (errcheck)
                        printJSON(ref)
                                 ^
cmd/oras/internal/display/print.go:119:9: Error return value is not checked (errcheck)
                        Print("Tagging", ref)
                             ^
cmd/oras/internal/display/print.go:139:9: Error return value is not checked (errcheck)
                        Print("Tagging", ref)
                             ^
cmd/oras/internal/option/packer_test.go:73:14: Error return value of `os.WriteFile` is not checked (errcheck)
        os.WriteFile(testFile, []byte(testContent), fs.ModePerm)
                    ^
cmd/oras/internal/option/remote.go:276:30: Error return value of `repo.SetReferrersCapability` is not checked (errcheck)
                repo.SetReferrersCapability(*opts.distributionSpec.referrersAPI)
                                           ^
cmd/oras/internal/option/remote_test.go:54:29: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
                        json.NewEncoder(w).Encode(testTagList)
                                                 ^
cmd/oras/internal/option/remote_test.go:236:28: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errcheck)
                json.NewEncoder(w).Encode(testTagList)
                                         ^
internal/cache/target_test.go:180:12: Error return value of `w.Write` is not checked (errcheck)
                                w.Write(blob)
                                       ^
internal/graph/graph_test.go:142:14: Error return value of `memory.Push` is not checked (errcheck)
                memory.Push(ctx, descs[i], bytes.NewReader(blobs[i]))
                           ^
internal/graph/graph_test.go:258:14: Error return value of `memory.Push` is not checked (errcheck)
                memory.Push(ctx, descs[i], bytes.NewReader(blobs[i]))
                           ^
internal/graph/graph_test.go:356:14: Error return value of `memory.Push` is not checked (errcheck)
                memory.Push(ctx, descs[i], bytes.NewReader(blobs[i]))

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #981

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header?

@codecov-commenter
Copy link

Codecov Report

Merging #986 (cba6d7a) into main (bf33bb7) will not change coverage.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@           Coverage Diff           @@
##             main     #986   +/-   ##
=======================================
  Coverage   81.26%   81.26%           
=======================================
  Files          53       53           
  Lines        2776     2776           
=======================================
  Hits         2256     2256           
  Misses        352      352           
  Partials      168      168           

@shizhMSFT shizhMSFT changed the title use golangci lint chore: use golangci lint Jun 28, 2023
Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

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

Suggested to align with other actions.

Also this PR requires fixing of all detected issues otherwise the PR check will fail. @kranurag7 Do you want to do the fixing? If not have time I can add another PR to fix all the lint issues found.

.github/workflows/golangci-lint.yml Outdated Show resolved Hide resolved
.github/workflows/golangci-lint.yml Show resolved Hide resolved
@kranurag7 kranurag7 mentioned this pull request Jul 4, 2023
4 tasks
@qweeah
Copy link
Contributor

qweeah commented Jul 12, 2023

@kranurag7 Can you add signoff as is suggested in https://github.com/oras-project/oras/pull/986/checks?check_run_id=14956872091:

  • In your local branch, run: git rebase HEAD~3 --signoff
  • Force push your changes to overwrite the branch: git push --force-with-lease origin golangci

@TerryHowe
Copy link
Member

I just rebased, so you are going to have to git pull and take care of DCO

Signed-off-by: Anurag <contact.anurag7@gmail.com>
Copy link
Member

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

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

LGTM

@qweeah qweeah merged commit 3092656 into oras-project:main Jul 13, 2023
@kranurag7 kranurag7 deleted the golangci branch July 13, 2023 08:55
qweeah pushed a commit to qweeah/oras that referenced this pull request Jul 21, 2023
Signed-off-by: Anurag <contact.anurag7@gmail.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
qweeah pushed a commit to qweeah/oras that referenced this pull request Jul 21, 2023
Signed-off-by: Anurag <contact.anurag7@gmail.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
shizhMSFT pushed a commit to shizhMSFT/oras that referenced this pull request Aug 3, 2023
Signed-off-by: Anurag <contact.anurag7@gmail.com>
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.

add Github actions to lint go code
4 participants