Fix coding standard bugs per gitlab-ci

Created on 11 June 2024, 7 months ago
Updated 1 August 2024, 5 months ago

Fix the cspell, phpcs and phpstan coding errors reported on gitlab-ci pipelines, e.g.: https://git.drupalcode.org/project/views_rss/-/pipelines/196484

Also then require cspell, eslint, phpcs and phpstan tests to pass before the test, i.e. set "allow_failure" to "false".

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇺🇸United States DamienMcKenna NH, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @DamienMcKenna
  • Status changed to Needs review 7 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    2 fail
  • 🇮🇳India dev16.addweb

    Hi, I have tested phpcs issues and fix below issues and created patch, Please review.

    /modules/custom/views_rss/
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/views_rss/src/Plugin/views/style/RssFields.php
    -------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------
     52 | ERROR | Class property $channel_elements should use lowerCamel naming without underscores
    -------------------------------------------------------------------------------------------------------------------------------------
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/views_rss/tests/src/Functional/DisplayFeedTest.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
     199 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
     199 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    -----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 646ms; Memory: 14MB
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    2 pass
  • Pipeline finished with Success
    7 months ago
    Total: 172s
    #202601
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    2 pass
  • Pipeline finished with Success
    7 months ago
    #202610
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    2 pass
  • Assigned to ivnish
  • Status changed to Needs review 7 months ago
  • ivnish Kazakhstan

    I fixed all CI issues, but before merge we need to manual testing. Please use patch from MR and test it on your dev/stage sites (not prod)

    Link to patch https://git.drupalcode.org/project/views_rss/-/merge_requests/8.patch

  • ivnish Kazakhstan

    I manually tested MR version on my site. It works fine

  • Status changed to Needs work 7 months ago
  • 🇺🇸United States DamienMcKenna NH, USA

    Great work, everyone! I really appreciate you all for working through this.

    A few minor things need some tweaks.

    • While I appreciate that DeprecationHelper exists, I think we should just do the old method_exists() check for now, for compatibility with older core releases.
    • getID3 should be added as a test dependency so that the @phpstan-ignore class.notFound bits aren't needed for getID3().
    • The @phpstan-ignore variable.undefined, empty.variable bits should be redone to avoid needing the phpstan-ignore lines.
    • Why were the "Need more information" titles removed?
    • Code that is commented out should be wrapped with @code / @endcode.
  • ivnish Kazakhstan

    While I appreciate that DeprecationHelper exists, I think we should just do the old method_exists() check for now, for compatibility with older core releases.

    I'm tried this code but phpstan still warnings about renderPlain method.

    $renderer = \Drupal::service('renderer');
    $output = method_exists($renderer, 'renderInIsolation') ?
      $renderer->renderInIsolation($item['rendered'], FALSE) :
      $renderer->renderPlain($item['rendered'], FALSE);
    

    Can you explain how to fix this?

    getID3 should be added as a test dependency so that the @phpstan-ignore class.notFound bits aren't needed for getID3().

    Fixed

    The @phpstan-ignore variable.undefined, empty.variable bits should be redone to avoid needing the phpstan-ignore lines.

    There is a strange situation with $element_groups variable. It is never defined (looks like legacy code). Can you look to that code https://git.drupalcode.org/project/views_rss/-/merge_requests/8/diffs#a6... and give advice?

    Why were the "Need more information" titles removed?

    Because fromTextAndUrl method has only 2 parameters, not 3

    Code that is commented out should be wrapped with @code / @endcode.

    Fixed

  • 🇺🇸United States DamienMcKenna NH, USA

    For the DeprecationHelper change, IIRC the short term fix should be to use phpstan's commands to ignore that line, and then we can open a D12 compatibility issue to fix this later on once we're no longer supporting older releases.

    I think we need to dig into the D7 code to see where $element_groups came from.

    Thank you for making the other changes.

  • Status changed to Needs review 6 months ago
  • ivnish Kazakhstan

    I fixed all issues

    Damien, please review

  • Status changed to Fixed 6 months ago
  • 🇺🇸United States DamienMcKenna NH, USA

    Good work! Committed. Thank you.

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

Production build 0.71.5 2024