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(lint): errors reported by golangci-lint: S1009: should omit nil check; printf: non-constant format string #19772 #19773

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

chengfang
Copy link
Contributor

Fixes #19772
This PR fixes various errors reported by golangci-lint version 1.60.3.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@chengfang chengfang requested a review from a team as a code owner September 3, 2024 20:29
Copy link

bunnyshell bot commented Sep 3, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

bunnyshell bot commented Sep 3, 2024

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 48.14815% with 14 lines in your changes missing coverage. Please review.

Project coverage is 55.94%. Comparing base (6cdba1e) to head (6659414).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
server/application/application.go 20.00% 4 Missing ⚠️
cmd/argocd/commands/app.go 0.00% 2 Missing ⚠️
...cationset/services/scm_provider/bitbucket_cloud.go 0.00% 1 Missing ⚠️
server/cluster/cluster.go 0.00% 1 Missing ⚠️
server/project/project.go 50.00% 1 Missing ⚠️
server/repocreds/repocreds.go 0.00% 1 Missing ⚠️
server/repository/repository.go 0.00% 1 Missing ⚠️
util/db/repository_secrets.go 50.00% 1 Missing ⚠️
util/kube/portforwarder.go 0.00% 1 Missing ⚠️
util/notification/settings/legacy.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19773      +/-   ##
==========================================
+ Coverage   55.85%   55.94%   +0.09%     
==========================================
  Files         320      320              
  Lines       44057    44057              
==========================================
+ Hits        24609    24649      +40     
+ Misses      16896    16855      -41     
- Partials     2552     2553       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

applicationset/utils/utils.go Outdated Show resolved Hide resolved
@pasha-codefresh
Copy link
Member

Small comment and LGTM. Great work

@chengfang chengfang changed the title fix(lint): errors reported by golangci-lint: S1009: should omit nil check; printf: non-constant format string #19772 chore(lint): errors reported by golangci-lint: S1009: should omit nil check; printf: non-constant format string #19772 Sep 4, 2024
… check; printf: non-constant format string

Signed-off-by: Cheng Fang <cfang@redhat.com>
@pasha-codefresh
Copy link
Member

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🏅 Score: 85
🧪 No relevant tests
🔒 No security concerns identified
🔀 Multiple PR themes

Sub-PR theme: ApplicationSet Updates

Relevant files:

  • applicationset/controllers/applicationset_controller.go
  • applicationset/generators/duck_type.go
  • applicationset/generators/git.go
  • applicationset/services/scm_provider/bitbucket_cloud.go
  • applicationset/utils/utils.go

Sub-PR theme: Command and Controller Enhancements

Relevant files:

  • cmd/argocd/commands/app.go
  • controller/appcontroller.go
  • controller/state.go
  • hack/gen-resources/generators/cluster_generator.go

Sub-PR theme: Server and API Updates

Relevant files:

  • server/application/application.go
  • server/cluster/cluster.go
  • server/logout/logout_test.go
  • server/project/project.go
  • server/repocreds/repocreds.go
  • server/repository/repository.go

⚡ Key issues to review

Simplification
The nil check for currentAppStatus.TargetRevisions has been removed, which simplifies the code but assumes that TargetRevisions is never nil. Ensure this assumption is always valid to prevent potential nil dereference.

Logic Change
The condition for verifyCommit has been changed to check only the length of appProject.Spec.SignatureKeys. Ensure that this change doesn't affect scenarios where gpg.IsGPGEnabled() might return false.

Simplification
Simplified the condition for adding finalizers by removing the nil check. Verify that replacedTmpl.ObjectMeta.Finalizers is always initialized to avoid nil slice assignment.

Condition Simplification
The condition for checking diffOptions.revisions has been simplified by removing the nil check. Confirm that this field is always properly initialized.

Error Handling
Changed error handling from status.Errorf to status.Error which might affect how errors are formatted and displayed. Ensure that this change aligns with the error handling strategy across the application.

@pasha-codefresh
Copy link
Member

I have checked in all the cases where we removed nil check, we actually use slices and let fuction will return 0 and not panic.

@pasha-codefresh pasha-codefresh enabled auto-merge (squash) September 4, 2024 14:33
@pasha-codefresh pasha-codefresh merged commit e3e02f0 into argoproj:master Sep 4, 2024
26 of 27 checks passed
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.

errors reported by golangci-lint: S1009: should omit nil check; printf: non-constant format string
5 participants