Fix the issues reported by phpcs

Created on 11 April 2023, about 1 year ago
Updated 18 March 2024, 3 months ago

Problem/Motivation

Fix all the errors and warnings reported by PHPCS for Drupal and DrupalPractice coding standards

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig decoupled_domain/

Proposed resolution

Fixing all the issues in respective files and execute the phpcbf command to beautify the code.

Remaining tasks

FILE: .../web/modules/contrib/decoupled_domain/src/DomainConfigPluginCollection.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
44 | WARNING | Possible useless method overriding detected
--------------------------------------------------------------------------------

FILE: ...dules/contrib/decoupled_domain/src/Plugin/DecoupledDomainEntityManager.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 9 WARNINGS AFFECTING 9 LINES
--------------------------------------------------------------------------------
61 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
63 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
66 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
67 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
87 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
97 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
102 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
104 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
185 | WARNING | t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
--------------------------------------------------------------------------------

FILE: ...l10/web/modules/contrib/decoupled_domain/src/Form/DomainConfigFormBase.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
64 | WARNING | Unused variable $request.
--------------------------------------------------------------------------------

FILE: ...oupled_domain/modules/decoupled_domain_user/decoupled_domain_user.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
7 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
8 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
--------------------------------------------------------------------------------

FILE: ...ed_domain/modules/decoupled_domain_access/decoupled_domain_access.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
7 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
8 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
--------------------------------------------------------------------------------

FILE: ...oupled_domain/modules/decoupled_domain_node/decoupled_domain_node.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
7 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
8 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
--------------------------------------------------------------------------------

FILE: ...ed_domain/modules/decoupled_domain_router/decoupled_domain_router.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
7 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
8 | WARNING | All dependencies must be prefixed with the project name, for
| | example "drupal:"
--------------------------------------------------------------------------------

Time: 1.95 secs; Memory: 12MB

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India urvashi_vora Madhya Pradesh, India

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

  • Issue created by @urvashi_vora
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    I am working on this, will provide a patch shortly.

  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Please review this patch.

    Thanks

  • Issue was unassigned.
  • Status changed to RTBC about 1 year ago
  • 🇵🇭Philippines kenyoOwen

    Hi urvashi_vora

    I applied patch coding-standard-fixes.patch to the “Decoupled Domain” module against Version 1.x-dev and confirmed that the warnings are resolved. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The patch could apply, but the changes are not correct.

    -  - decoupled_domain
    -  - decoupled_domain_user
    +  - drupal:decoupled_domain
    +  - drupal:decoupled_domain_user
    -  - decoupled_domain
    -  - decoupled_router
    +  - drupal:decoupled_domain
    +  - drupal:decoupled_router

    Those are not Drupal core modules; their namespace is not correct.

    -  - decoupled_domain
    -  - node
    +  - drupal:decoupled_domain
    +  - drupal:node

    Only the Node module is a Drupal core module. The other is a module that is part of this very project.

    -  /**
    -   * {@inheritdoc}
    -   *
    -   * @return \Drupal\decoupled_domain\Plugin\DecoupledDomainConfigInterface
    -   *   Single Decoupled domain configuration.
    -   */
    -  public function &get($instance_id) {
    -    return parent::get($instance_id);
    -  }
    -

    The method has been added to show a different type in the @return line. There are many Drupal core classes that do that.

    -    $request = $this->getRequest();
    -
    +    // $request = $this->getRequest();
         if (!($this->config instanceof ConfigurableDecoupledDomainConfigInterface)) {

    If a line is not necessary, it is removed, not commented out.

  • 🇮🇳India kbk1992 Hyderabad

    bharath-kondeti made their first commit to this issue’s fork.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Modified the patch as per suggestion of #5. Please review, thanks.

  • 🇮🇳India Shank115

    I applied the patch provided in #8 and found one warning:

    FILE: /home/sites/decoupled_domain/src/DomainConfigPluginCollection.php
    -----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------
     44 | WARNING | Possible useless method overriding detected
    -----------------------------------------------------------------------
Production build 0.69.0 2024