Closed (fixed)
Project:
Coder
Version:
8.x-3.x-dev
Component:
Coder Sniffer
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 May 2019 at 19:09 UTC
Updated:
4 Sep 2020 at 12:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jonathan1055 commentedHere is a patch which can fix the common errors in @deprecated doc comments. If this proves sucessful then I will create a PR.
The code needs tidying up, as it is work-in-progress at the moment.
Comment #3
jonathan1055 commentedMore work done, to cater for additional common faults.
Comment #4
jonathan1055 commentedComment #5
klausiCool, is this something you plan to later add to Coder? Or just a temporary fixer hack to aid your conversion?
I understand if polishing the fixer for any generic use case might be hard and this only works for core.
Comment #6
jonathan1055 commentedWhen I started the automatic fixer work I did not know, but now that it can fix 520 core faults I think it would be worth adding to coder. A developer could easily introduce one of these fixable faults and this would assist in making the code clean. Yes, it does only work for core at the moment, but could be extended to projects.
I also want to do the same for @trigger_error() as I am sure there are plenty of fixable messages within the 793 currently reported faults.
Comment #7
jonathan1055 commentedI've done some more more on fixing the core @deprecated text. This is not finished yet, but want to add this patch to drupal.org so that I can use it in the core issue #3048498: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard
Comment #8
jonathan1055 commentedFuther work-in-progress. Not asking for any review yet.
Comment #9
jonathan1055 commentedMore work-in-progress, to help fix more on #3048498: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard
Comment #10
jonathan1055 commentedIgnore patch #9, I rolled it against an out-of-date 8.x-3.x branch. Patch #10 should apply OK to the latest Coder dev on drupal.org
Comment #11
jonathan1055 commentedJust to update the situation, of the 675 @deprecated text layout coding standards faults in core 8.9, this automated fixing corrected 653 (96.7%) and these have been committed in #3048498-61: [≈Nov. 11] Fix Drupal.Commenting.Deprecated coding standard
The remaining 22 are manual and I have patch for those on the follow-up #3094454: Fix remaining @deprecated manually and enable the coding standard. Very interestingly was one single case where fixing the @deprecated coding standard caused a previously unthrown deprecation in Core to be seen and highlighted. It was only a quirk of the deprecation listener + how the core function @deprecated tag was written that meant the deprecation message was being hidden - see #3009848-5: Fully deprecate WorkflowDeleteAccessCheck
In preparation for the first sniff to be enabled in core, please would you consider commiting this small patch which aligns the sniff names with my work-in-progress. I realised that the sniff names unnecessarily long, repeating 'Deprecated' and 'TriggerError'. If you'd like a PR for this, let me know. The tests pass on my Travis build.
Comment #12
klausiYes, please create a pull request so that we see the automated tests run.
Comment #13
jonathan1055 commentedThe PR is https://github.com/pfrenssen/coder/pull/64
Tests at higher PHP versions will fail - see #3097302: Travis Phpunit failures at PHP 7.2 and 7.3 - deprecated each(), but the Coder tests pass OK at the lower PHP versions.
Comment #14
klausiSorry, just realized now that we can't change those names now because they are already in a stable release of Coder (8.3.6). Changing them now would mean the next release would break people's PHPCS configuration where they for example silenced those sniffs.
We could shorten them in Coder 9, but to be honest it does not seem worth the config breaking change. So I think we should stick with those slightly longer names forever.
Comment #15
jonathan1055 commentedYes, OK, there is no point in breaking things and making work.
Moving on, and following up your question in #5
Is there any precedent in Coder where phpcbf can do automatic fixes that apply to Core only, but for contrib we just give the normal error/warning but without providing the fix? The fixes for core have been very sucessful saving lots of manual effort. However, in places it may prove tricky to provide an automated fix for a contrib project.
Comment #16
jonathan1055 commentedTidied up patch #10. I have left in the automatic fixing for basic layout for 'drupal' projects. There is no downside that it does not give auto fixing for contrib projects.
Now that #3009848: Fully deprecate WorkflowDeleteAccessCheck is in I want to finish off #3094454: Fix remaining @deprecated manually and enable the coding standard and that needs the changes in this patch. The sniff won't be able to be turned on in Core until this change makes it to a Coder release, but at least with this patch up here I can apply it during the testing via drupalci.yml
The PR for this is https://github.com/pfrenssen/coder/pull/90
Comment #17
klausiThanks! Left some comments on the pull request.
We usually don't distinguish between core and contrib code. If people don't like the sniff in contrib they can disable it in their phpcs.xml.dist file.
The automated fix should just take whatever contrib module name is used in the message.
Comment #18
jonathan1055 commentedThanks. I have responded on the PR.
Comment #19
jonathan1055 commentedI have responded to all your questions/requests on PR 90 and pushed new changes. I have added a new
DeprecatedUnitTest.inc.fixedtest to verify the auto-fixes, improved the comments, added a debug parameter and fixed the actual code for coding standards.Here is a patch and interdiff.
Comment #20
klausiThanks, looks like the pull request is a bit messed up. Please merge in 8.x-3.x correctly so that we can review only your changes.
Comment #21
jonathan1055 commentedI have pushed a clean branch to the same PR https://github.com/pfrenssen/coder/pull/90
There are two commits, the first matches patch 16 which you reviewed, so the second commit shows the work I have done in response.
I also fixed the oddity in the rendering of the API page DeprecatedSniff.php/class/DeprecatedSniff which currently picks out the @deprecated comment and renders the page as if this sniff is itself deprecated!
Comment #22
klausiThanks, merged!
Comment #24
jonathan1055 commentedI response to Klausi's request on PR90 to remove the empty
ifblock, I realised that the fixable url sniff is only done for functions. The @deprecated sniff also has to work for doc blocks (which it does) so the fixable @see url is required. Added this, and a line in the unit test to check it. The sniff caters not just for . but also ! ? and ;https://github.com/pfrenssen/coder/pull/97
Comment #25
klausiThanks, committed!
Comment #26
jonathan1055 commentedThanks that's great. What is the process for getting updates committed on Github back to drupal.org? Is is a manual thing, or a nightly automatic push? Just curious, and it also might affect current ideas in Devel module where Moshe is planning to move to GitLab. See #3126895: Move testing and issues to gitlab.com if you are interested.
Comment #28
klausiAh right, forgot to push to drupal.org. Done now!
Comment #29
jonathan1055 commentedThanks that's great.
#3094454: Fix remaining @deprecated manually and enable the coding standard has already been committed to core 9.1 and 9.0 and the new sniff enabled in full as there were only a handful of fixes required.
We want it to be ported to 8.9 so that the standards can be enabled there too, but it needs the commits within this issue to make it into a full release and that release to be used in Core (or a lot of manual work to add missing %extra-info% which these commits separate out into a separate sniff which can then be ignored initially).
I know that Core 8.9 has only recently been updated to use Coder to 8.3.8 #3121885: Update coder to 8.3.8 but could you tell me when you expect Coder 8.3.9 to be tagged? Thanks.
Comment #30
klausiUsually I try to make Coder releases every 3 months, but we can do it a bit earlier to get this out :)
I want to look at a couple of other needs review issues, so it will take some time. I'm aiming to do that in the next 2 weeks.
Comment #31
jonathan1055 commentedThat would be perfect, thanks.
Comment #32
klausiDone, Coder 8.3.9 "Deprecated Donut" has been released.
Comment #33
jonathan1055 commentedThank you @klausi, that is great. I will raise an issue to get core to start using Coder 8.3.9
Comment #34
jonathan1055 commentedJungle was already ahead of me, within 40 mins of you tagging the new release we have #3134731: Update coder to 8.3.9 so that's saved me the trouble :-)
Comment #36
jonathan1055 commentedFollowing up my comment in #21 the API at 8.9 has now been fixed, but 8.8 still shows the outdated Sniff source rendering.
What can be done (if anything) to refresh the API page for 8.8?