Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRemove unnecessary variable declaration. #1581
Open
Conversation
codecov
bot
commented
Jul 20, 2020
•
Codecov Report
@@ Coverage Diff @@
## master #1581 +/- ##
=======================================
Coverage 67.95% 67.96%
=======================================
Files 96 96
Lines 8762 8761 -1
=======================================
Hits 5954 5954
+ Misses 1898 1897 -1
Partials 910 910
Continue to review full report at Codecov.
|
|
@gmlewis small refactor PR |
| @@ -129,8 +129,7 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { | |||
| // Deprecated: Use ParsePayload instead, which returns an error | |||
| // rather than panics if JSON unmarshaling raw payload fails. | |||
| func (e *Event) Payload() (payload interface{}) { | |||
| var err error | |||
| payload, err = e.ParsePayload() | |||
| payload, err := e.ParsePayload() | |||
This comment has been minimized.
This comment has been minimized.
gmlewis
Jul 20, 2020
Collaborator
If you're going to make this change, then you should also change line 131 and remove the named return variable because you just declared a new payload and they are no longer the same thing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
MorrisLaw commentedJul 20, 2020
We don't need the
errvariable declaration prior to initialization. Sinceerris not needed as a return value at the end of the function, I think that relying on Go's built-in type inference makes sense here.