Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Title: Automatic fixing @deprecated doc text » Automatically fixing @deprecated doc text
StatusFileSize
new3.99 KB

Here 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.

jonathan1055’s picture

StatusFileSize
new3.77 KB

More work done, to cater for additional common faults.

jonathan1055’s picture

StatusFileSize
new4.21 KB
klausi’s picture

Cool, 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.

jonathan1055’s picture

When 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.

jonathan1055’s picture

StatusFileSize
new10.57 KB

I'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

jonathan1055’s picture

StatusFileSize
new11.6 KB

Futher work-in-progress. Not asking for any review yet.

jonathan1055’s picture

jonathan1055’s picture

StatusFileSize
new12.3 KB

Ignore 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

jonathan1055’s picture

Just 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.

klausi’s picture

Yes, please create a pull request so that we see the automated tests run.

jonathan1055’s picture

The 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.

klausi’s picture

Sorry, 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.

jonathan1055’s picture

Yes, OK, there is no point in breaking things and making work.

Moving on, and following up your question in #5

Cool, 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.

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.

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new9.01 KB

Tidied 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

klausi’s picture

Status: Needs review » Needs work

Thanks! 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.

jonathan1055’s picture

Thanks. I have responded on the PR.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new20.07 KB
new17.79 KB

I have responded to all your questions/requests on PR 90 and pushed new changes. I have added a new DeprecatedUnitTest.inc.fixed test 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.

klausi’s picture

Status: Needs review » Needs work

Thanks, 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.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new259.08 KB

I 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!

 /**
- * Ensures standard format of a @deprecated text.
+ * Ensures standard format of @ deprecated tag text in docblock.
  *

deprecated sniff api

klausi’s picture

Status: Needs review » Fixed

Thanks, merged!

  • f9fb9a1 committed on 8.x-3.x
    feat(Deprecated): Add fixer for Drupal core deprecated tag formatting (#...
jonathan1055’s picture

Status: Fixed » Needs review
StatusFileSize
new4.86 KB

I response to Klausi's request on PR90 to remove the empty if block, 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

klausi’s picture

Status: Needs review » Fixed

Thanks, committed!

jonathan1055’s picture

Assigned: jonathan1055 » Unassigned

Thanks 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.

  • jonathan1055 authored e3c6e11 on 8.x-3.x
    fix(Depreacted): Improve fixer for deprecated @see URL (#3057988 by...
klausi’s picture

Ah right, forgot to push to drupal.org. Done now!

jonathan1055’s picture

Thanks 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.

klausi’s picture

Usually 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.

jonathan1055’s picture

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.

That would be perfect, thanks.

klausi’s picture

Done, Coder 8.3.9 "Deprecated Donut" has been released.

jonathan1055’s picture

Thank you @klausi, that is great. I will raise an issue to get core to start using Coder 8.3.9

jonathan1055’s picture

Jungle 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 :-)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jonathan1055’s picture

StatusFileSize
new282.55 KB
new288.79 KB

Following 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?