Fix coding standards

Created on 30 March 2024, 9 months ago
Updated 31 July 2024, 5 months ago

Problem/Motivation

The Gitlab CI pipeline identified several coding standards issues: https://git.drupalcode.org/issue/jsonapi_links-3437151/-/jobs/1197339

Let's fix these.

šŸ“Œ Task
Status

Needs work

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 !8Fixes for coding standards ā†’ (Open) created by ptmkenny
  • Status changed to Needs review 9 months ago
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    This fixes all of the coding standards issues identified except 2:

    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------
     33 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     39 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------
    

    I think dependency injection can be a separate issue than other coding standard fixes because DI can sometimes cause problems, so it should be a separate commit.

  • Status changed to Needs work 5 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @ptmkenny,

    I applied MR!8, it was applied smoothly and fixed most of the issues.

    However, I encountered more issues than you mentioned in comment #3 after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  jsonapi_links git:(1.0.x) curl https://git.drupalcode.org/project/jsonapi_links/-/merge_requests/8.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3822    0  3822    0     0   9055      0 --:--:-- --:--:-- --:--:--  9078
    patching file README.md
    patching file src/EventSubscriber/ResponseSubscriber.php
    patching file src/Form/SettingsForm.php
    āžœ  jsonapi_links git:(1.0.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml jsonapi_links
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/jsonapi_links/jsonapi_links.routing.yml
    ------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Expected 1 newline at end of file; 2 found
    ------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/jsonapi_links/jsonapi_links.services.yml
    -------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     5 | ERROR | [x] Expected 1 newline at end of file; 2 found
    -------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/jsonapi_links/jsonapi_links.links.task.yml
    ---------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------
     12 | ERROR | [x] Expected 1 newline at end of file; 2 found
    ---------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/jsonapi_links/src/EventSubscriber/ResponseSubscriber.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------
     33 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     39 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------------
    
    Time: 113ms; Memory: 10MB
    
    āžœ  contrib

    Please check and advise.
    Thank you.

Production build 0.71.5 2024