Fix the issues reported by phpcs

Created on 30 March 2023, about 1 year ago
Updated 7 June 2024, 19 days ago

GitLab CI reports PHP_CodeSniffer errors/warnings that should be fixed.

FILE: ...elp-3351232/web/modules/custom/contextual_help-3351232/src/HelpManager.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  6 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Component\Serialization\Json.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
 18 | ERROR | [ ] Missing member variable doc comment
    |       |     (Drupal.Commenting.VariableComment.Missing)
 64 | ERROR | [ ] Missing parameter type
    |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...3351232/web/modules/custom/contextual_help-3351232/src/Controller/Help.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  8 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is
    |       |     Drupal\Component\Plugin\Exception\PluginNotFoundException.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
 18 | ERROR | [ ] Missing member variable doc comment
    |       |     (Drupal.Commenting.VariableComment.Missing)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 123ms; Memory: 6MB

 
 

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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

Merge Requests

Comments & Activities

  • Issue created by @sidharth_soman
  • 🇮🇳India sidharth_soman Bangalore

    Finding the above errors. I'll work on solving them.

  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I have fixed all of the above except for the dependency injection. Please review the MR.
    Thanks.

  • Assigned to omkar_yewale
  • 🇮🇳India omkar_yewale Mumbai

    Hi sidharth_soman, I have made some updates to the code and fixed the issue related to the

    \Drupal calls should be avoided in classes, use dependency injection instead

    Please review the patch.

  • Issue was unassigned.
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
       public function applies(RouteMatchInterface $route_match): bool {
         return $route_match->getRouteName() === 'system.admin_content';
    +
       }
    

    An empty line is not necessary after a return line.

    +  /**
    +   * Constructs a Help object.
    +   *
    +   * @param \Drupal\contextual_help\HelpManager $help_manager
    +   *   The help manager service.
    

    The short description is missing the class namespace.

    +  /**
    +   * The RedirectDestinationInterface service.
    +   *
    +   * @var \Drupal\Core\Routing\RedirectDestinationInterface
    

    That is not the service name, but the class name. The service could be probably be described as The redirect service. or The redirect destination service. as another comment describes it. I would rather use the description used on Drupal::destination() in both the cases: The redirect destination helper.

    +   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
    +   *   Cache backend instance to use.
    

    That description is missing an article.

       /**
        * Get a link to the help plugin text by plugin definition.
        *
    -   * @param $definition
    +   * @param array $definition
        *   The plugin definition.
    

    Since that comment is changed, the verb used on the short description should be changed to use the third person singular (which is an on-topic change since this issue is about coding standards).

  • First commit to issue fork.
  • @kalash-j opened merge request.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India kalash-j jaipur

    I have created the MR !2 with the required changes please check

  • Status changed to Needs work 9 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India sakthi_dev

    Addressed the comment on MR. Please review.

  • 🇮🇳India kalash-j jaipur

    i have done required changes that were mention in MR !2 comments

  • Status changed to Needs work 19 days ago
  • 🇮🇳India deepak5423

    @kalash-j there are still some phpcs issue left.

  • Pipeline finished with Success
    19 days ago
    Total: 148s
    #193411
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 19 days ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Canceled
    19 days ago
    Total: 126s
    #193421
  • Pipeline finished with Success
    19 days ago
    Total: 184s
    #193424
Production build 0.69.0 2024