Skip to content

Conversation

alingse
Copy link
Contributor

@alingse alingse commented Mar 31, 2024

Thank you for contributing to Velero!

Please add a summary of your change

TLDR: FIx a bug

I am writing a linter called sundrylint to address some real-world bugs that I discovered during my work.

When we range over a slice and call the append function within the loop body, we are not appending all elements, but only the ones that we specifically iterate over during the range operation.

for _, n := range ns {
   rs = append(rs, n)       # this is ok
   rs = append(rs, ns...)   # this is wrong
}

I read the code in here https://github.com/vmware-tanzu/velero/blob/main/test/util/velero/velero_utils.go#L171-L174

I think it was just to append the not exists in origin plugins

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

Signed-off-by: alingse <alingse@foxmail.com>
@alingse alingse force-pushed the fix-append-all-when-range-it branch from 981765a to 2ef22c0 Compare March 31, 2024 16:13
@alingse
Copy link
Contributor Author

alingse commented Mar 31, 2024

/kind changelog-not-required

@github-actions github-actions bot added the kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes label Mar 31, 2024
@blackpiglet blackpiglet added kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes and removed kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes labels Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.84%. Comparing base (3d6dab0) to head (2ef22c0).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7602   +/-   ##
=======================================
  Coverage   61.84%   61.84%           
=======================================
  Files         265      265           
  Lines       29356    29356           
=======================================
  Hits        18155    18155           
  Misses       9913     9913           
  Partials     1288     1288           

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

@Lyndon-Li Lyndon-Li merged commit de2cb52 into vmware-tanzu:main Apr 1, 2024
@alingse alingse deleted the fix-append-all-when-range-it branch April 1, 2024 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants