Fix the issues reported by phpcs

Created on 30 March 2023, almost 2 years ago
Updated 10 July 2024, 8 months 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

RTBC

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 almost 2 years 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 almost 2 years 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 over 1 year ago
  • šŸ‡®šŸ‡³India kalash-j jaipur

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

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • First commit to issue fork.
  • Status changed to Needs review over 1 year 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 9 months ago
  • šŸ‡®šŸ‡³India deepak5423

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

  • Pipeline finished with Success
    9 months ago
    Total: 148s
    #193411
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs review 9 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Canceled
    9 months ago
    Total: 126s
    #193421
  • Pipeline finished with Success
    9 months ago
    Total: 184s
    #193424
  • Hi!
    Reviewed the MR4 present in #17. Found the some of the errors are still present. Moving it to needs work. Attaching screen shot for the reference.

  • Status changed to Needs work 8 months ago
  • Pipeline finished with Success
    8 months ago
    Total: 148s
    #220049
  • Status changed to Needs review 8 months ago
  • šŸ‡®šŸ‡³India kalash-j jaipur

    i have solved the issue @arijit-acharya

  • Status changed to RTBC 8 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @kalash-j,

    I applied MR!4, it was applied smoothly and fixes the phpcs issues.

    āžœ  contextual_help git:(1.0.x) curl https://git.drupalcode.org/project/contextual_help/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8780    0  8780    0     0   6851      0 --:--:--  0:00:01 --:--:--  6854
    patching file .gitlab-ci.yml
    patching file README.md
    patching file css/contextual-help.css
    patching file src/Controller/Help.php
    patching file src/HelpManager.php
    āžœ  contextual_help git:(1.0.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml contextual_help
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3351232-fixing-phpcs-issues to hidden.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3351232-gitlab-ci-reports to hidden.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3351232-gitlab-ci-reports to active.

Production build 0.71.5 2024