Created on 31 January 2023, about 2 years ago
Updated 1 February 2023, about 2 years ago

Problem/Motivation

Make sure we're compliant with coding standards.

📌 Task
Status

Fixed

Version

4.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

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

Comments & Activities

  • Issue created by @jurgenhaas
  • Status changed to Fixed about 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • 🇨🇦Canada No Sssweat

    There are a few more Drupal coding standards to fix.

    FILE: ...les/contrib/elastic_email/src/EventSubscriber/InitSubscriber.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     96 | WARNING | t() calls should be avoided in classes, use
        |         | \Drupal\Core\StringTranslation\StringTranslationTrait
        |         | and $this->t() instead
    ----------------------------------------------------------------------
    
    
    FILE: .../contrib/elastic_email/src/Controller/ElasticEmailController.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     96 | WARNING | t() calls should be avoided in classes, use
        |         | \Drupal\Core\StringTranslation\StringTranslationTrait
        |         | and $this->t() instead
    ----------------------------------------------------------------------
    
    
    FILE: ...ules/contrib/elastic_email/src/Form/ElasticEmailSettingsForm.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------
     68 | WARNING | t() calls should be avoided in classes, use
        |         | \Drupal\Core\StringTranslation\StringTranslationTrait
        |         | and $this->t() instead
     71 | WARNING | \Drupal calls should be avoided in classes, use
        |         | dependency injection instead
    ----------------------------------------------------------------------
  • Status changed to Needs work about 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Hmm, thanks for reporting this. I wonder why my PHPCS test isn't picking them up. Need to verify my settings, I guess. Which settings are you using for PHPCS?

  • 🇨🇦Canada No Sssweat

    I am using the coder module → which brings two standards, "Drupal" and "DrupalPractice"

    phpcs.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <ruleset name="phpcs-standard">
      <description>Codestyle ruleset for Drupal</description>
    
      <!-- Specify standards. -->
      <rule ref="Drupal"/>
      <rule ref="DrupalPractice"/>
    
      <!-- Set ignore extensions. -->
      <!-- @todo remove .css to check also the css files. -->
      <!-- @see https://www.drupal.org/node/2867601#comment-12075633 -->
      <arg name="ignore" value="*.css,*.md,*.txt"/>
    
      <!--Exclude folders used by common frontend tools. These folders match the file_scan_ignore_directories setting in default.settings.php-->
      <exclude-pattern>*/bower_components/*</exclude-pattern>
      <exclude-pattern>*/node_modules/*</exclude-pattern>
      <!--Exclude third party code.-->
      <exclude-pattern>*/vendor/*</exclude-pattern>
    
      <!-- Specify folders. -->
      <file>web/modules/contrib/elastic_email</file>
    <!--  <file>web/themes/custom</file>-->
    </ruleset>
  • Status changed to Needs review about 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    That's interesting. I'm using only the Drupal standard, not DrupalPractive. And it seems, that DrupalCI is doing the same thing because in all my other projects where I have automated tests enabled, it doesn't report any code style issues. But I just checked, if I were to use DrupalPractice, it recognizes quite a few more. I'll have to check with the Coding Standard team on Slack to see what's going on here.

    Anyways, for this issue, I've removed the 4 remaining issues. Thanks again for poiting them out.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Here is the link to the question on Slack: https://drupal.slack.com/archives/C02LJCF78E8/p1675235373281869

    Let's see what we get out of this.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Made a couple more changes as we now require PHP 8.1 or later.

  • Status changed to RTBC about 2 years ago
  • 🇨🇦Canada No Sssweat

    Looks good.

  • Status changed to Fixed about 2 years ago
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Great, thanks for reviewing.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Sounds like the PHPCS standard Drupal is the equivalent that's used by Drupal Core and reflects the current coding standard used in DrupalCI. But of course it's better to use DrupalPractice as it helps to improve code quality.

    The processes around coding standards are documented at https://www.drupal.org/project/coding_standards →

    Other notable issues around that topic are 🌱 [meta] Fix PHP coding standards in core Active and 📌 [META] Fix DrupalPractice best practice in Core Needs work

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

Production build 0.71.5 2024