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

Enable errcheck linter for test packages #3034

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

anishbista60
Copy link
Contributor

@anishbista60 anishbista60 commented Aug 15, 2024

Change Overview

Enabled errcheck linter for test package

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test
  • 🏗️ Build

Issues

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@anishbista60
Copy link
Contributor Author

anishbista60 commented Aug 17, 2024

@viveksinghggits could you please review this PR?

pkg/field/field_test.go:7: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	. "gopkg.in/check.v1"

pkg/field/field_test.go:9: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	"github.com/kanisterio/kanister/pkg/field"

pkg/poll/poll_test.go:25: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	"github.com/jpillora/backoff"

how to fix this one ?

@viveksinghggits
Copy link
Contributor

@saima-s can you have a look into this please and try to get it merged.

@saima-s
Copy link
Contributor

saima-s commented Aug 19, 2024

@viveksinghggits could you please review this PR?

pkg/field/field_test.go:7: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	. "gopkg.in/check.v1"

pkg/field/field_test.go:9: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	"github.com/kanisterio/kanister/pkg/field"

pkg/poll/poll_test.go:25: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kanisterio/kanister) -s blank -s dot (gci)
	"github.com/jpillora/backoff"

how to fix this one ?

gci linters expects imports to be in order as mentioned here.
You can arrange imports in the order from this to something like:

        "context"
	"fmt"

	"github.com/kanisterio/kanister/pkg/field"

        . "gopkg.in/check.v1"

@anishbista60
Copy link
Contributor Author

@saima-s do i need to fix above issue i was facing , because there are so many files having this isssue .
Do we have any tool which does everything based on below rule ?

 gci:
    sections:
      - standard
      - default
      - prefix(github.com/kanisterio/kanister)
      - blank
      - dot

@anishbista60 anishbista60 force-pushed the linter-fix branch 4 times, most recently from a66e609 to 81c8366 Compare August 20, 2024 11:37
@anishbista60
Copy link
Contributor Author

anishbista60 commented Aug 20, 2024

@julio-lopez test file are yet to update.
let me fix everything and then I will push all the changes .

@anishbista60
Copy link
Contributor Author

anishbista60 commented Aug 21, 2024

@julio-lopez All set . Now, could you please test it ?

pkg/controller/controller_test.go Outdated Show resolved Hide resolved
pkg/controller/controller_test.go Outdated Show resolved Hide resolved
@anishbista60
Copy link
Contributor Author

@julio-lopez

if err := os.Setenv(kube.PodNSEnvVar, "test"); err != nil {
    t.Fatalf("Error setting env variable: %v", err)
}

Would this approach fine ?

@julio-lopez
Copy link
Contributor

Would this approach fine ?

This is preferred whenever possible

err := os.Setenv(kube.PodNSEnvVar, "test")
c.Assert(err, IsNil)

@anishbista60
Copy link
Contributor Author

Would this approach fine ?

This is preferred whenever possible

err := os.Setenv(kube.PodNSEnvVar, "test")
c.Assert(err, IsNil)

Then , can I replicate through all test file ?

@anishbista60 anishbista60 force-pushed the linter-fix branch 3 times, most recently from 4e3834c to a780611 Compare August 28, 2024 10:02
@anishbista60
Copy link
Contributor Author

@julio-lopez done . Could you please review ?

@julio-lopez julio-lopez changed the title Enable the linters for test packages Enable errcheck linter for test packages Aug 28, 2024
Copy link
Contributor

@julio-lopez julio-lopez left a comment

Choose a reason for hiding this comment

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

@anishbista60 Only a minor request, see inline comment.

Thanks for doing this. This is looking good!

pkg/kube/pod_command_executor_test.go Outdated Show resolved Hide resolved
pkg/kube/pod_command_executor_test.go Outdated Show resolved Hide resolved
pkg/kube/pod_command_executor_test.go Outdated Show resolved Hide resolved
pkg/output/stream_test.go Show resolved Hide resolved
@pavannd1 pavannd1 requested a review from hairyhum August 28, 2024 20:05
Signed-off-by: anishbista60 <anishbista053@gmail.com>
@anishbista60
Copy link
Contributor Author

anishbista60 commented Aug 29, 2024

@julio-lopez Done sir. And one thing i confused about is which issue to mention while raising next PR. if i mentioned issue 2962 then it will automatically closed once it get merged and but we want that issue will close, once all PR get merged . could you suggest me ? . so , that i could aware about in next PR. Thankyou

@julio-lopez
Copy link
Contributor

@julio-lopez Done sir. And one thing i confused about is which issue to mention while raising next PR. if i mentioned issue 2962 then it will automatically closed once it get merged and but we want that issue will close, once all PR get merged . could you suggest me ? . so , that i could aware about in next PR. Thank you

Reference the issue simply as #2962 , do not prepend "Fixes" or "Closes" and you should be OK.

Copy link
Contributor

@julio-lopez julio-lopez left a comment

Choose a reason for hiding this comment

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

@anishbista60
🥇Thanks for doing this.
🙏🏼

@julio-lopez julio-lopez merged commit c5f051a into kanisterio:master Sep 4, 2024
16 checks passed
julio-lopez added a commit that referenced this pull request Sep 5, 2024
Refs:
#3034
#2962

--
Signed-off-by: Anish Bista <anishbista053@gmail.com>
Co-authored-by: Julio López <1953782+julio-lopez@users.noreply.github.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.

4 participants