-
Notifications
You must be signed in to change notification settings - Fork 11
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
Upstream 8.x-2.x #6
Conversation
… that should have use statements instead
…eport classes in the same namespace
…mbers in short array syntax
…d and declaration
…losing parenthesis
…ate file exclusion
…Declaration sniff for compatibility with existing phpcs.xml configs
…slatableMarkup and TranslationWrapper
…Comment incorrectly triggers error for error classes with underscores
…njection should be used
…ncatenated to t() calls
…mment indenation
Update to PHPCS 3.3.1
@seamuslee001 looks like we're overdue for a merge from upstream! When I did this in #2 I had to go through and adjust a handful of things that either modify sniffs we don't use or introduce new sniffs that are inappropriate or too strict. For reference, these are our changes as compared to the latest commit prior to my last merge: ErichBSchulz/coder@4eefe23...civicrm:8.x-2.x-civi |
@agh1 i think they are still there but would appreciate thoughts on https://github.com/seamuslee001/coder/blob/8.x-2.x-civi/coder_sniffer/Drupal/ruleset.xml#L196 you can see the propertyDec;aration is still commented out but there are 2 new PSR2 declarations maybe they need to be commented out as well @totten |
btw this is the diff that is produced when i run a diff against the main branch @agh1 @totten https://gist.github.com/seamuslee001/6965863fc1f40aadea93760e2b8cff37 |
@seamuslee001 I'd generally take an empirical/measured approach -- we should enable as many rules as we can without producing crazy backlog of tasks. So if, for example, Perhaps relevant: https://www.php-fig.org/psr/psr-2/#3-namespace-and-use-declarations -- on a substantive level, PSR-2's namespace/use policy seems pretty reasonable. If we do go a cleanup route, and if it touches many files, then there's a stickier question -- because we currently apply the same ruleset to all tests on all versions. Finding a way to transition might be a longer discussion? Or, for low-tech approach, we could (1) merge the cleanups to code now and (2) activate new ruleset after a month or two. |
@totten i can take a look tomorrow i guess but also not 100% sure what the rule covers so wouldn't be sure exactly what might be checking for |
So you shouldn't have to know much about the rules to get a read on their impact. One can start by spotchecking a subset, e.g. this one takes (only) 40 sec on my laptop:
That should give a sign (with clearer warning text) if there's anything extremely amiss. If it looks promising on the subset, then repeat with larger filesets. That's slower, so you'll either need to do it in the background, or get some coffee, or execute in parallel fashion. In the past, I improvised (running multiple threads in different console-tabs), but there might be a simpler way to parallel-task:
|
@totten so i ran that and this is the output it gave me https://gist.github.com/seamuslee001/380b7cd2e1bcab20d26f0ed0dc2389c7 |
Cool. To help visualize the distribution of issues, I did some string munging and got: https://gist.github.com/totten/26f3595e54f0d6428c7419eff71475dd Based on this sample of 519 PHP file and 763 issues, we have a rate of ~1.47 issues per file. Extrapolating to 2761 PHP files in There are automated cleanups for some things (via Poking through, the output highlights a bunch of good issues, but some things seem problematic:
TBH, the fastest thing is probably disabling suspicious rules so that we can focus on cleaning up the stuff that's more clear-cut. If there's time+patience left over, then dig deeper into the problematic ones. |
If I recall correctly we left it last time such that we knew some rules would trip up some files but it was better to have those get flagged occasionally than to try doing an autoclean. Does that sound right? For array indentation, a lot of the issue is arrays that are spelled out in the arguments of functions. I think I recall a lot of spots where it looked reasonable but didn't fit the sniff's idea of where it should be indented. I wonder if of @totten's suspicious rules we should keep the namespaced classes (it won't affect as much of our code), array indents (we already have rules about this, so this is probably just a refinement), and comments after statements (same thing) and disable the others. |
@totten @agh1 i have updated the rules and it now outputs https://gist.github.com/7ef89a0f8752312a40b23a4d8878a2e8 |
Hmm, I don't think so. There's currently a wide cap between the version of Using current For a benchmark, I did a couple batches of cleanup. It took me 20-30 min to handle one batch of 100 files (with assistance from phpcbf autoclean). With 2100 PHP files, that's ~7 hours of cleanup work to get the level of current |
@totten i have just updated to exclude some more rules which might be useful down the track but not right now |
@totten this is now the ouput after running phpcbf-civi and then running civilint https://gist.github.com/23a1a4da3a5560fb3dd04cd71e597411 |
Alrighty, merging this. We're charging forth with upfront cleanups in other PRs, and it's clearer how to proceed there if this is merged (i.e. if there's one clear branch specifying the target ruleset). We can still tweak/disable rules as needed. It won't go live until we update buildkit. |
No description provided.