Closed (fixed)
Project:
Drupal core
Version:
8.3.x-dev
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Sep 2015 at 16:13 UTC
Updated:
11 Sep 2016 at 17:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #4
duaelfrAs agreed between the mentors at Drupalcon, according to issues to avoid for novices, I am untagging this issue as "Beginner". This issue contains changes across a very wide range of files and might create too many other patches to need to be rerolled at this particular time. This patch has an automated way to be rerolled later so better to implement it after Drupalcon.
Comment #6
pfrenssenComment #8
alexpottNeeds reworking phpcs.xml.dist is now inclusive so the rule needs adding and also we could split this up into specific errors generated by the sniff to make it a bit more managable.
Comment #9
pfrenssenComment #10
pfrenssenComment #11
andypostre-roll, also added
Drupal.WhiteSpace.ScopeIndenttophpcs.xml.distComment #12
pfrenssenComment #13
alexpott@andypost can we split this issue up into specific errors defined by
Drupal.WhiteSpace.ScopeIndentthis way the issue becomes reviewable. See the current phpcs.xml.dist for how to do this - I committed #2707641: Ensure core compliance to Drupal.Commenting.FunctionComment.ParamCommentIndentation (part 2) which does this.Comment #14
mile23Using the technique described here: #2571965-63: [meta] Fix PHP coding standards in core, stage 1 I came up with these stats:
Incorrectisn't very good at auto-fixing. It wants to make changes like this:...which ruins the readability of hard-coded YAML strings in tests.
That leaves us with
IncorrectExact, which has a large number of errors, and which also isn't so good at auto-correcting in some circumstances.There are a number of cases where namespace brackets confuse IncorrectExact on auto-correcting. Those will need to be manually fixed and reviewed carefully.
Here's a patch limited to
core/lib/which should give us some idea of how reviewable this is.Comment #15
andypostHere's a re-roll and fix to title and scope
Both ones needs new issues
Comment #17
vprocessor commentedComment #18
vprocessor commentedfixed
Comment #19
vprocessor commentedhad been fixed indents problems
Comment #21
vprocessor commentedfixed
Comment #22
mile23Seems a little severe for a coding standards patch...
Comment #23
klausiunrelated change?
Comment #24
chishah92 commentedHi Klausi ,
Can you please explain the unrelated change in this yml file and do we need to revert that in the next patch?
Thanks
~Chirag
Comment #25
mile23@chishah92: Klausi and I were saying that the patch is wrong. It removes YML files which is out of scope for this issue.
Comment #26
chishah92 commentedHave fixed the YML file deletion in the new patch.
Thanks!
~Chirag
Comment #27
mile23Right, but now you're *adding* a YML file for a coding standards issue.
Please pull the 8.2.x branch again, re-do the work according to the instructions in the issue summary, and make another patch.
Thanks.
Comment #28
dawehnerThis patch now adds new files. Let's ensure to reroll against 8.2.x
Comment #29
hussainwebI just reran phpcbf to fix the standards this way:
phpcbf --standard=Drupal --sniffs=Drupal.WhiteSpace.ScopeIndent --exclude=WhiteSpace.ScopeIndent.Incorrect .Comment #30
andriyun commentedThere are a lot of weird corrections like below one.
Seems like patch was created using wrong way
First line for this block fixed incorrectly.
We no need fix here.
Comment #31
andriyun commentedAfter invetigation on autofixes by phpcbf I see bunch of other wrong fixes:
Wrong indentation fix for break statement
Wrong indentation fix for square brackets array
Wrong indentation fix for square bracket array elements
After phpcbf it need a lot of manual changes and restores.
So we should fix sniffer in coder first
Comment #32
andriyun commentedI propose fix this issue in two steps.
1. Fix first part where we will include small fixes from phpcbf with manual correction.
2. Cover other part with huge fixes when we will found correct solution for that.
In attached files you can find patch for first step.
Remaining scope:
In second step we need rewrite each file from follow list more then 80%
Comment #33
andypostYep, makes sense to file new issue and fix sniffer
Comment #34
klausiThe change to core/phpcs.xml.dist is missing? We should enable the sniff there. If phpcbf does not work as desired please file an issue in the Coder issue queue with a snippet to reproduce the problem.
Comment #35
andriyun commentedAdded changes to phpcs.xml.dist
Comment #37
klausiThat is not correct - the rule ref should only have 3 parts. The last "Incorrect" should be removed. You may need to define excludes for this sniff where we filter out something - see the other sniffs in this file where we do that.
If I run phpcs with this patch and the latest Coder version then I get a couple of Drupal.WhiteSpace.ScopeIndent.IncorrectExact fails, is that intentional?
Comment #38
eric_a commentedComment #39
alexpottWe need to fix coder to correctly implement coding standards - opened #2787555: Drupal.WhiteSpace.ScopeIndent.IncorrectExact so we can use it for core for the exact rule.
Drupal.WhiteSpace.ScopeIndent.Incorrectlooks like we need to finalise the standards for anonymous functions before we attempt that.Comment #40
alexpottCreated #2787567: Refactor \Drupal\Component\Assertion\Handle to not break PSR-0/4 one class per file to handle one of the tricky situations.
Comment #41
alexpottCreated #2787577: When tests use multiple namespaces they should do so in a coding standards compliant way to handle alot of the test issues with multiple namespaces.
Need to open separate issues for:
core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.phpcore/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.phpcore/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php[Edit: The first 3 are now part of #2787577: When tests use multiple namespaces they should do so in a coding standards compliant way]
Comment #42
alexpottLooking at coder in order to not have issues with the switch element we need to fix #2572795: Fix coding standard for closures - Drupal.WhiteSpace.ScopeClosingBrace and Generic.Functions.OpeningFunctionBraceKernighanRitchie first.
Comment #43
alexpottCreated #2787655: Fix \Drupal\Tests\Core\Form\FormTestBase to not have multiple namespaces to address the final test class with namespacing indent issues.
Comment #44
alexpottThe blockers have landed...
So much win... the fixer is not perfect... but the rule is it identifies places where the indentation is wrong 100% of the time.
Comment #45
alexpottThis is the one meh - but I don't think it is a blocker... because there is prior art... just need to find it :)
The breaks here are dead code...
Probably should delete this dead code.
Comment #46
alexpottSelf-review.
Comment #47
klausiI verified the changes with git diff --color-words and they look good! The break statement removals also look good.
I tested with Coder 8.2.8 with the patch applied and there are still 2 errors reported:
There is a weirdly formatted array in there :(
We need to fix that one way or the other because the output of phpcs should be empty with this patch.
Comment #48
alexpott@klausi that's really weird my coder is checked out to 8.2.8 and I don't see this. Yes the indentation is wrong but I wonder why?
Comment #49
alexpottTurns out we should just enable the entire sniff... since there is only one more file to fix.
still not sure what is happening with #47.
Maybe code sniffer version... mine is PHP_CodeSniffer version 2.5.1 (stable) by Squiz (http://www.squiz.net)
Comment #50
dawehnerThat one is a bit weird to be honest. I get where this rule is coming from.
Opened a follow up for that: #2788481: Implement documentSelfTokens and addSelfTokens in \Drupal\user\Plugin\views\field\Permissions
+1 for using more <<
Comment #51
alexpottYeah #50.1 is the only bit of ugliness. I think we document this differently elsewhere... gonna search.
Comment #52
alexpottYep ... looking in \Drupal\views\EntityViewsData::mapSingleFieldViewsData we do
Comment #53
dawehnerTo be honest
50.1is a bit of a pointless comment, it just documents what the code is already doing.Comment #54
alexpottSo let's be consistent and consistent in the same switch statement about documenting fall-throughs.
Comment #55
dawehnerWFM
Comment #56
klausiRTBC + 1. My phpcs output is clean now, looks like my phpcs installation was messed in my last comment - sorry.
Comment #58
klausiRandom test fail, back to RTBC.
Filed #2790685: FieldHandlersUpdateTest has random test fails.
Comment #59
alexpottThis is eligible for commit during rc - unfortunately it is not possible to apply #54 to 8.2. Going to roll a patch for that.
Comment #60
alexpottPatches for both branches - 8.3 one is same as #54.
Comment #62
dawehnerSome random failure in the meantime
Comment #63
catchI got this seemingly unrelated coding standards fail when committing:
But fixed it on commit (to both 8.3.x and 8.2.x).