Problem/Motivation
We skip coding standards warnings in a number of files with @codingStandardsIgnoreFile
.
From https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignorin...
Before PHP_CodeSniffer version 3.2.0, use
// @codingStandardsIgnoreFile
instead of// phpcs:ignoreFile
. The@codingStandards
syntax is deprecated and will be removed in PHP_CodeSniffer version 4.0.
Coder currently depends on PHPCS 3.5.6 so we can do this now prior to the next major version bump of PHPCS.
Steps to reproduce
Proposed resolution
Replace the comments as suggested.
Remaining tasks
Consider whether we should really ignore all sniffs for each file with phpcs:ignoreFile, or only disable some sniffs with phpcs:disable.
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#24 | 3207968-24.patch | 46.85 KB | quietone |
#24 | interdiff-17.24.txt | 1.93 KB | quietone |
#17 | interdiff-15-17.txt | 710 bytes | quietone |
#17 | 3207968-17.patch | 46.55 KB | quietone |
#17 | interdiff-15-17.txt | 710 bytes | quietone |
Comments
Comment #2
longwaveComment #3
quietone CreditAttribution: quietone as a volunteer commentedMade with
Comment #4
claudiu.cristeaComment #5
quietone CreditAttribution: quietone as a volunteer commentedAnd run the same command on sites directory.
Comment #6
longwaveDidn't spot these initially either; while we are here I guess we should change them too for consistency.
These need to become
phpcs:ignore
,phpcs:disable
orphpcs:enable
as appropriate.Comment #7
quietone CreditAttribution: quietone as a volunteer commentedTesting locally and found that some of these file no longer need to ignore lines so this is not a one for one replacement.
Comment #8
longwaveComments below might be a bit of scope creep but I think better to fix them here than open lots of new issues for these tiny little changes.
I think we should just fix the coding standards issues on these lines.
And here.
What issue are we ignoring here?
I think this can just be removed?
Maybe we can use // phpcs:ignore Drupal.Semantics.FunctionT.EmptyString here?
Comment #9
longwaveAlso a wider question: in phpcs.xml.dist we ignore the Diff component:
Should we do this for the Doctrine tests instead of adding a line to each file?
(we could do the same for ProxyClass implementations, but I think as those can live in any namespace and are machine-generated it is worth explicitly including the tag)
Comment #10
quietone CreditAttribution: quietone as a volunteer commentedAgree, let's fix these now. This patch address all the points in #8
Comment #11
quietone CreditAttribution: quietone as a volunteer commented#9. Now the change for doctrine. This removes ignoreFile lines from 29 files, if my count is correct leaving 45 files with
phpcs:ignoreFile
.Comment #12
SpokjeMe like, just (at least for now) one nit:
Now it looks like
Doctrine
stuff is excluded because it'sused by common frontend tools
.I think this added line deserves it's own comment to make clear why its excluded.
(Didn't want to interfere with the running tests and their status changing magic upon a failure, so left this issue on NR)
Comment #13
SpokjeComment #14
quietone CreditAttribution: quietone as a volunteer commentedAdding a related issue I found but haven't yet read.
Comment #15
quietone CreditAttribution: quietone as a volunteer commented#12. Good point. This moves the line to 'exclude third party code' and adds a blank line for readability.
I read the related issue and it was to remove all the @codingstandardIgnoreFile lines and put exclusions in phpcs.xml. Not quite the same as what is being done here. We could expand the scope of this and add more exclusions, we have already added one. Or it could be a follow up to this. I can't decide which is better.
longwave mentioned the proxy class and tstoeckler commented about that in the related issue.
Comment #16
longwaveThis was missed from #8.2, I think we just need to move the brace to the declaration line? Otherwise this looks good to me.
I didn't find the duplicate issue earlier, oops. I think this is hopefully less controversial. My personal opinion is that we should use the config file to exclude wide groups of files (e.g. entire namespaces) but then use inline comments for individual files that have individual reasons for being ignored.
Comment #17
quietone CreditAttribution: quietone as a volunteer commented#16. Yes, I missed that. Oops.
Yes, let's save any controversy for another time.
Comment #18
longwaveThanks, this looks good to me now.
I also opened #3208698: Make ProxyClass implementations follow coding standards as I think the best fix overall would be to make the ProxyClass implementations actually follow the standards, this should be possible with a little more effort in the generator code.
Comment #19
SpokjeFinal nit/remark/suggestion:
Should we leave a comment in files NOT created by the generate-proxy-class script _why_ they are
phpcs:ignoreFile
?Like for example:
I had to search for a bit _why_ this file was ignored. Could save somebody some time someday.
Bows as he accepts the prize for the most usage of the word "some" in a sentence.
Comment #20
quietone CreditAttribution: quietone as a volunteer commented@Spokje, good idea. I am all for saving people work in the future. I think it would be OK to do that in #2891586: Remove @codingStandardsIgnoreFile from file and ignore those in phpcs.xml.dist because whether the phpcs:ignoreline are removed or become exclude lines in the phpcs.xml file or not, the changes should be documented. For me, it makes sense to do all that research in one issue.
Comment #21
Spokje@quietone: Fine by me, let's leave this at RTBC
Comment #22
quietone CreditAttribution: quietone as a volunteer commentedThere is a duplicate of this issue #2891586: Remove @codingStandardsIgnoreFile from file and ignore those in phpcs.xml.dist with a similar patch. I suggest credit be added for jibran, tstoeckler, and xjm.
Comment #23
Spokje@quietone:
In #19 I suggested adding comments to each
phpcs:ignoreFile
with an explanation why it's excluded.In #20 you replied:
Since we (or rather you) closed #2891586: Remove @codingStandardsIgnoreFile from file and ignore those in phpcs.xml.dist as a duplicate, that commenting won't be happening there.
Do we want to do the commenting in this issue? Or a follow-up?
Comment #24
quietone CreditAttribution: quietone as a volunteer commented@Spokje, thanks! I completely forgot about that.
Spokje and I had a chat about this and after a bit of going in circles on my part I agree that documentation should be added here while we are modifying these files. It will save effort in the future. Thanks to Spokje for stopping my spin :-).
So, I went through patch and added comments where there it isn't obvious why the file is excluded. the comment is similar to #9, I went with namespace instead of filename as per DocParser.php. I also made the comment much shorter and started it on the same line as the ignoreFile. The idea was to reduce the visual impact since most people want to read the 'read' comments or the code.
Oh, core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php doesn't need the ignoreFile any more either.
Comment #25
longwaveGreat work, I agree with all the additions in #24 so back to RTBC.
Comment #27
longwaveRandom fail in EntityReferenceWidgetTest.
Comment #28
Spokje#3191559-3: [random test failure] Random test fail in EntityReferenceWidgetTest
Comment #30
SpokjeRrrrrrrrandom test failure #3210432: [random test failure] LayoutBuilderQuickEditTest::testQuickEditIgnoresDuplicateFields(), ordered retest.
Comment #31
longwaveComment #32
Spokje*tips hat @longwave*
Comment #35
catchRestoring status after HEAD was broken.
Comment #37
SpokjeRandom Test-failure (#3208791: [random test failure] Random fail in LayoutBuilderDisableInteractionsTest), back to RTBC
Comment #40
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!