Fix coding standards

Created on 17 April 2024, 2 months ago
Updated 8 June 2024, 20 days ago

Problem/Motivation

When adding the GitLab CI template, several coding standards issues are identified. Let's fix these.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇯🇵Japan ptmkenny

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

Merge Requests

Comments & Activities

  • Issue created by @ptmkenny
  • Merge request !28Fix coding standards → (Merged) created by ptmkenny
  • 🇯🇵Japan ptmkenny

    There are three unused variables:

    FILE: /var/www/html/web/modules/dev/feeds_ex/src/Feeds/Parser/QueryPathXmlParser.php
    ------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------
     128 | WARNING | Unused variable $parser.
    ------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/dev/feeds_ex/feeds_ex.theme.inc
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     29 | WARNING | Unused variable $source.
    ----------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/dev/feeds_ex/tests/src/Unit/Feeds/Parser/HtmlParserTest.php
    -------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------
     229 | WARNING | Unused variable $config.
    -------------------------------------------------------------------------------------------
    

    Since unused variables may be a sign of work in progress, I didn't do anything to them and defer to a maintainer.

  • Status changed to Needs review 2 months ago
  • 🇯🇵Japan ptmkenny

    The remaining issues:

    FILE: /var/www/html/web/modules/dev/feeds_ex/src/Feeds/Parser/XmlParser.php
    ---------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------
     307 | ERROR | Function libxml_disable_entity_loader() has been deprecated
     321 | ERROR | Function libxml_disable_entity_loader() has been deprecated
    ---------------------------------------------------------------------------
    

    These deprecations seem like they would better be addressed in a separate issue.

    FILE: /var/www/html/web/modules/dev/feeds_ex/src/Feeds/Parser/ParserBase.php
    -----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------
     245 | WARNING | Line exceeds 80 characters; contains 93 characters
     386 | WARNING | Only string literals should be passed to t() where possible
    -----------------------------------------------------------------------------
    

    Line 386:

          $this->getMessenger()->addMessage($this->t($error['message'], $error['variables']), $error['severity'] <= RfcLogLevel::ERROR ? 'error' : 'warning', FALSE);
    

    I'm not sure why this is translated; it seems like error messages from the parser should just be displayed as is. But I am probably misunderstanding something :)

    In any case, the MR fixes the majority of the coding standards issues with the exceptions stated above. So I'm setting to "Needs review" for feedback.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    run-tests.sh fatal error
  • 🇳🇱Netherlands MegaChriz

    I think it would be a good to rebase this one and see what GitLab CI has to say about the coding standards after these changes.

    And now I'm heading back to the kitchen. :)

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    92 pass, 6 fail
  • Pipeline finished with Failed
    2 months ago
    Total: 459s
    #149403
  • 🇯🇵Japan ptmkenny

    Huh, Drupal.org doesn't test for unused variables. So according to GitLab CI, the only remaining issues are those in #4.

  • 🇯🇵Japan ptmkenny

    Hmm, now the unit tests are broken again. Since they are also broken in the PHPStan issue, it's probably not my fixes here that broke them. Maybe it's because the tests are now running on Drupal 10.2 instead of 9.5?

    I'll try to look at this tomorrow.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 2 months ago
    92 pass, 6 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    92 pass, 6 fail
  • 🇯🇵Japan ptmkenny

    Current status: Now that 📌 Remove deprecated libxml_disable_entity_loader() Postponed is its own issue, the only two remaining coding standards items to address are:

    FILE: /var/www/html/web/modules/dev/feeds_ex/src/Feeds/Parser/ParserBase.php
    -----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------
     245 | WARNING | Line exceeds 80 characters; contains 93 characters
     386 | WARNING | Only string literals should be passed to t() where possible
    -----------------------------------------------------------------------------
    

    Line 245 is commented out code, so maybe it should just be left in place as a reminder?
    For line 346, see my comment in #4.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    92 pass, 6 fail
  • 🇳🇱Netherlands MegaChriz

    I merged in the latest changes from 8.x-1.x into it the MR. Maybe that helps?

  • 🇳🇱Netherlands MegaChriz

    The tests broke because some tests methods that were disabled by adding an underscore now run. Perhaps it is a good idea to add markTestIncomplete() to these test methods instead. These tests are about things that I didn't understand when I starting porting Feeds Extensible Parsers from D7 to D8.

    And ideally, it would be good to identify what the disabled tests were supposed to cover exactly and see if that would still make sense in the D8+ version.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    116 pass
  • Pipeline finished with Success
    2 months ago
    Total: 412s
    #151873
  • 🇯🇵Japan ptmkenny

    Ok! With markTestIncomplete(), then we are back to the issues in #9.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 2 months ago
    116 pass
  • Pipeline finished with Success
    2 months ago
    Total: 418s
    #157033
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 month ago
    116 pass
  • Pipeline finished with Skipped
    about 1 month ago
    #181839
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 month ago
    116 pass
  • Status changed to Fixed about 1 month ago
  • 🇳🇱Netherlands MegaChriz

    I've just added phpcs:ignore lines to ignore the remaining phpcs issues. In some cases it is allowed to pass a PHP variable to t(). The core module 'Database Log' does it too. For example in dblog.admin.inc: t($type) and in DbLogController: $this->t($dblog->type).

    The commented out code is kept for now, but in the comment above I added more information about why the commented out code is there. And what the next step is for possibly resolving it.

    Merged the code!

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

Production build 0.69.0 2024