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

Remove redundant len check in GroupSheets and UngroupSheets #1685

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Remove redundant len check in GroupSheets and UngroupSheets #1685

merged 1 commit into from
Oct 12, 2023

Conversation

Juneezee
Copy link
Contributor

@Juneezee Juneezee commented Oct 6, 2023

PR Details

This pull request is a minor code cleanup.

From the Go specification (https://go.dev/ref/spec#For_range):

"1. For a nil slice, the number of iterations is 0."

len returns 0 if the slice is nil (https://pkg.go.dev/builtin#len). Therefore, checking len(v) > 0 before a loop is unnecessary.

Description

Remove redundant len(sheetViews) > 0 around loop

if len(sheetViews) > 0 {
	for idx := range sheetViews {
		...
	}
}

to

for idx := range sheetViews {
	...
}

Related Issue

Motivation and Context

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2023

Codecov Report

Merging #1685 (747f814) into master (07f2c68) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master    #1685      +/-   ##
==========================================
- Coverage   98.99%   98.99%   -0.01%     
==========================================
  Files          32       32              
  Lines       27436    27433       -3     
==========================================
- Hits        27160    27157       -3     
  Misses        183      183              
  Partials       93       93              
Flag Coverage Δ
unittests 98.99% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
sheet.go 100.00% <100.00%> (ø)

From the Go specification [1]:

  "1. For a nil slice, the number of iterations is 0."

`len` returns 0 if the slice or map is nil [2]. Therefore, checking
`len(v) > 0` around a loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range
[2]: https://pkg.go.dev/builtin#len

Signed-off-by: Eng Zer Jun <[email protected]>
@xuri xuri added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 7, 2023
Copy link
Member

@xuri xuri left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution.

@xuri xuri merged commit f752f2d into qax-os:master Oct 12, 2023
39 checks passed
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this pull request Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants