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 dead / unreachable code in core/calendar block renderer. #14546

Merged

Conversation

@svenvanhal
Copy link
Contributor

@svenvanhal svenvanhal commented Mar 21, 2019

Description

The core/calendar block registration file contains variable assignments after a return statement (hence dead code). After removing this code, I discovered that the variables in question ($previous_monthnum and $previous_year) are never used anyway (not in this function, not in get_calendar and never in the entire codebase for that matter).

This PR removes dead code and unused variables to prevent any future ambiguities or bugs.

How has this been tested?

Tests pass, not sure how to test server side rendering well
This change seems safe / harmless, however

Types of changes

Refactor, non-breaking

@gziolo
Copy link
Member

@gziolo gziolo commented Mar 21, 2019

@jorgefilipecosta - what was the reason these global variables had to be updated? If it is still necessary, they should be assigned back to the initial value before the return statement.

@svenvanhal svenvanhal force-pushed the remove/dead_code branch from c759fee to b74bd6e Mar 21, 2019
@svenvanhal svenvanhal force-pushed the remove/dead_code branch from b74bd6e to 40e5caa Mar 21, 2019
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

The change looks good to me 👍
Thank you for submitting this fix!

@jorgefilipecosta jorgefilipecosta merged commit 9d3292b into WordPress:master Mar 21, 2019
1 check passed
mkevins added a commit to mkevins/gutenberg that referenced this issue Mar 26, 2019
…rdPress#14546)

## Description
The `core/calendar` block registration file contains variable assignments after a `return` statement (hence dead code). After removing this code, I discovered that the variables in question (`$previous_monthnum` and `$previous_year`) are never used anyway (not in this function, not in `get_calendar` and never in the entire codebase for that matter).

This PR removes dead code and unused variables to prevent any future ambiguities or bugs.

## How has this been tested?
Tests pass, not sure how to test server side rendering well
This change seems safe / harmless, however

## Types of changes
Refactor, non-breaking
@youknowriad youknowriad added this to the 5.4 (Gutenberg) milestone Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants