Closed (fixed)
Project:
Coder
Version:
8.3.x-dev
Component:
Coder Sniffer
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2023 at 15:44 UTC
Updated:
10 Feb 2024 at 17:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
catchMoving this to gitlab templates in case it's possible via a phpcs configuration change in the default template rather than changing the actual sniff.
Comment #3
fjgarlin commentedThe file to change would be: https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/scripts...
Core uses: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/phpcs.xml.dis...
I don’t know how far we should get in tweaking the default file, but maybe we can take some of the rules from core.
I don’t know what drupalci did, but it’d be worth checking.
Having said all that, if a module has a phpcs file, it will be respected.
Comment #4
jonathan1055 commentedI know that Drupal CI is about to be replaced by Gitlab-CI but the coding standards ruleset is a core file, so this should surely be a Core issue, in the Core queue? I think the linked scripts/phpcs.xml.dist is the file for this project to use on its own files? We should not be modifying it to make changes for other projects.
Comment #5
fjgarlin commentedThe file is used as a fallback if a contrib module does not have one. See https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/include...
If drupalci uses for contrib the core file (doesn’t it contain core paths in it??) we could mirror the same here.
It’s still unclear to me where this issue appeared. The fixes here would affect all contrib, but not core.
More details and CI runs links would help to narrow down the scope and the possible fix.
Comment #6
jonathan1055 commentedYes indeed. I don't think the issue should have been moved to this queue. It's about relaxing a coder sniff due to the receent Coding Standards change - heres the Change Record (but oddly it is still in draft)
The sniff is Drupal.Commenting.FunctionComment.Missing and I have checked, there is no phpcs config option to ignore the sniff just for constructor methods (I think that was wishful thinking by @catch)
So this issue should go back to the Coder queue, to request a modification to the sniff.
Comment #7
catchCore's file has this already:
The rule has never been enabled for core (like lots of rules), because it can take months to bring core up to a new coder sniff given the amount of 15 year old code in there. So from the point of view of core, this issue would only block enabling that rule. Contrib uses a different file as @fjgarlin points out.
Comment #8
jonathan1055 commentedYes that's right. I might have a quick look at the sniff to see what is involved. Is it just if the function name is __construct then we can ignore the rule?
Comment #9
catchYes exactly. In the original issue we discussed doing it for all magic methods, but it's fine to hardcode it to __construct().
Comment #10
jonathan1055 commentedWhat about __destruct ? Is that also covered by the relaxed rule, or is it just __construct ?
I see in the draft change record it says
Comment #11
catchNo it's only constructors, the change record was wrong. Updated and published it..
Comment #12
jonathan1055 commented@klausi, sorry I created an issue fork here, forgetting that development and MRs should be against https://github.com/pfrenssen/coder
I can't delete the branch, see attached. Can you or someone else do it?
Comment #13
jonathan1055 commentedThe PR is https://github.com/pfrenssen/coder/pull/215
First added test coverage to show that current sniff fails.
Comment #14
jonathan1055 commentedhttps://github.com/pfrenssen/coder/pull/215/files is ready for review
Comment #15
jonathan1055 commentedAdded Change Record to the IS.
Comment #17
klausiMerged, thanks!