Opened 7 years ago
Closed 6 years ago
#44225 closed defect (bug) (fixed)
PHPCS: Assignment must be the first block of code on a line
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 5.1 |
Component: | General | Keywords: | has-patch commit |
Focuses: | coding-standards | Cc: |
Description
Although WordPress-Core standard is reporting this as an error, I would like to ask if the following block of code was overlooked and kept intentionally.
File: wp-admin/includes/plugin.php
Line number: 146
The code block being reported is:
<?php $allowed_tags = $allowed_tags_in_links = array( 'abbr' => array( 'title' => true ), 'acronym' => array( 'title' => true ), 'code' => true, 'em' => true, 'strong' => true, );
While according to the standards it should be:
<?php $allowed_tags_in_links = array( 'abbr' => array( 'title' => true ), 'acronym' => array( 'title' => true ), 'code' => true, 'em' => true, 'strong' => true, ); $allowed_tags = $allowed_tags_in_links;
Does this create additional overhead if the declaration and assignment are done in two lines? I have uploaded a patch to meet WordPress-Core standard but will love to know if this is really a necessity! And if not, why.
Attachments (1)
Change History (9)
#2
@
7 years ago
- Keywords 2nd-opinion removed
I would like to ask if the following block of code was overlooked and kept intentionally.
@subrataemfluence No, this block wasn't kept intentionally, but these kind of errors can not be auto-fixed by the tooling we used to clean up the code as they generally need a developer to check what is the best course of action.
So far, mostly the errors and warnings which can be auto-fixed have made it into core. Most manual fixes still need to be done.
Does this create additional overhead if the declaration and assignment are done in two lines?
It creates additional overhead in the head of developers who can't find the assignment ;-)
For PHP it makes no difference at all. This rule is about code readability.
I have uploaded a patch to meet WordPress-Core standard
Thanks for that and I concur with @GaryJ that the patch looks good. I unfortunately can't add the commit
keyword.
Patch looks good to me :-)