Skip to content

remove unnecessary nil check#3517

Merged
vangent merged 1 commit into
google:masterfrom
hrtsegv:remove-unnecessary-nil-check
Jan 21, 2025
Merged

remove unnecessary nil check#3517
vangent merged 1 commit into
google:masterfrom
hrtsegv:remove-unnecessary-nil-check

Conversation

@hrtsegv

@hrtsegv hrtsegv commented Jan 21, 2025

Copy link
Copy Markdown
Contributor

pubsub/pubsub.go:565: remove unnecessay nil check.

var slice []byte
if slice != nil && len(slice) > 0 {}
// is the same as
if len(slice) > 0 {}

because len(slice) where slice == nil is always equal to 0,

staticcheck will highlight this optimization with the following message:

pubsub/pubsub.go:565:9: should omit nil check; len() for []*gocloud.dev/pubsub/driver.Message is defined as zero (S1009)

for reference: staticcheck S1009

@codecov

codecov Bot commented Jan 21, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.25%. Comparing base (9e81e8d) to head (404f338).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3517      +/-   ##
==========================================
- Coverage   73.26%   73.25%   -0.02%     
==========================================
  Files         113      113              
  Lines       15065    15065              
==========================================
- Hits        11038    11036       -2     
- Misses       3261     3263       +2     
  Partials      766      766              

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

@vangent vangent merged commit eaaf976 into google:master Jan 21, 2025
sandeepvinayak pushed a commit to sandeepvinayak/go-cloud that referenced this pull request Apr 10, 2025
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.

2 participants