Fix the issues reported by phpcs

Created on 29 June 2023, over 1 year ago

Problem/Motivation

There are some issues which are reported by PHP code sniffer within the module.

FILE: D:\xampp\htdocs\know-how\modules\custom\tmgmt_openai\src\OpenAiTranslatorUi.php

FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES

139 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
148 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead

FILE: D:\xampp\htdocs\know-how\modules\custom\tmgmt_openai\src\Plugin\tmgmt\Translator\OpenAiTranslator.php

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE

82 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead

FILE: D:\xampp\htdocs\know-how\modules\custom\tmgmt_openai\tmgmt_openai.info.yml

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE

6 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"

Proposed resolution

Need to fix the following issues using the php code standard commands.

๐Ÿ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Prachi6824

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 @Prachi6824
  • Assigned to Prachi6824
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Prachi6824

    Hello,

    I have created a patch to solve all the errors related to phpcs within the module

    Please review and apply it .

  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether

    Hi @prachi6824

    I reviewed patch #2 and there are still remaining issues reported by phpcs shown below:

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig tmgmt_openai

    FILE: ...denttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/tmgmt_openai/tmgmt_openai.info.yml
    ----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging
       |         | automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging
       |         | automatically
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging
       |         | automatically
    ----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/tmgmt_openai/README.md
    --------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------
     47 | WARNING | Line exceeds 80 characters; contains 84 characters
    --------------------------------------------------------------------------------------------------------
    
    
    FILE: ...rainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/tmgmt_openai/src/OpenAiTranslatorUi.php
    ----------------------------------------------------------------------------------------------------------
    FOUND 8 ERRORS AND 1 WARNING AFFECTING 9 LINES
    ----------------------------------------------------------------------------------------------------------
     15 | ERROR   | [ ] Missing @var tag in member variable comment
     20 | ERROR   | [x] Expected 1 space after "=>"; 0 found
     30 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
     42 | ERROR   | [x] Short array syntax must be used to define arrays
     52 | ERROR   | [x] Short array syntax must be used to define arrays
     59 | ERROR   | [x] Short array syntax must be used to define arrays
     69 | ERROR   | [x] Short array syntax must be used to define arrays
     80 | ERROR   | [x] Short array syntax must be used to define arrays
     94 | ERROR   | [x] Short array syntax must be used to define arrays
    ----------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------
    
    
    FILE: ...rg-issues-site/docroot/modules/contrib/tmgmt_openai/src/Plugin/tmgmt/Translator/OpenAiTranslator.php
    ----------------------------------------------------------------------------------------------------------
    FOUND 27 ERRORS AND 4 WARNINGS AFFECTING 30 LINES
    ----------------------------------------------------------------------------------------------------------
      16 | ERROR   | [x] When importing a class with "use", do not include a leading \
      45 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      46 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      47 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      48 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      49 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      50 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      51 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      52 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      53 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      54 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      55 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      56 | ERROR   | [x] Expected 5 space(s) before asterisk; 3 found
      84 | WARNING | [x] A comma should follow the last multiline array item. Found: )
     101 | ERROR   | [x] Data types in @param tags need to be fully namespaced
     118 | WARNING | [ ] Line exceeds 80 characters; contains 85 characters
     130 | WARNING | [ ] Line exceeds 80 characters; contains 85 characters
     141 | ERROR   | [x] Short array syntax must be used to define arrays
     154 | ERROR   | [x] Data types in @param tags need to be fully namespaced
     157 | ERROR   | [x] Parameter comment must end with a full stop
     161 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
     163 | ERROR   | [ ] Return type "array object" must not contain spaces
     166 | ERROR   | [x] Data types in @throws tags need to be fully namespaced
     167 | ERROR   | [ ] @throws tag comment must end with a full stop
     171 | ERROR   | [x] Short array syntax must be used to define arrays
     171 | ERROR   | [x] Short array syntax must be used to define arrays
     173 | ERROR   | [x] Short array syntax must be used to define arrays
     188 | ERROR   | [ ] The array declaration extends to column 142 (the limit is 80). The array content
         |         |     should be split up over multiple lines
     190 | ERROR   | [x] Whitespace found at end of line
     233 | ERROR   | [x] Object operator not indented correctly; expected 10 spaces but found 12
     237 | ERROR   | [x] Short array syntax must be used to define arrays
    ----------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 25 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------
    
    Time: 438ms; Memory: 12MB

    Please check.
    Thank you.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Addressed #3, Updated patch.

    Errors/warning remaining are:
    I think we can ignore these warning. Please review.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Created MR1 for the changes.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡น๐Ÿ‡ผTaiwan amourow

    The MR needs to rebase to the latest code.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia bharath-kondeti Hyderabad
  • Status changed to Needs work about 1 year ago
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Addressed the unresolved comments partially.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Issue summary updated

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Updated the IS for the remaining issues.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Venkatraman Ganesan โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    MR #19 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/tmgmt_openai (1.0.x)
    $ curl https://git.drupalcode.org/project/tmgmt_openai/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4127    0  4127    0     0   4848      0 --:--:-- --:--:-- --:--:--  4861
    patching file src/OpenAiTranslatorUi.php
    patching file src/Plugin/tmgmt/Translator/OpenAiTranslator.php
    patching file tmgmt_openai.install
    

    Still some errors remaining.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml tmgmt_openai/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\README.md
    -------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------
     47 | WARNING | Line exceeds 80 characters; contains 84 characters
    -------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\src\Plugin\tmgmt\Translator\OpenAiTranslator.php
    ----------------------------------------------------------------------------------------------------------------------
    FOUND 13 ERRORS AFFECTING 13 LINES
    ----------------------------------------------------------------------------------------------------------------------
     129 | ERROR | Missing parameter comment
     130 | ERROR | Missing parameter comment
     132 | ERROR | Description for the @return value must be on the next line
     164 | ERROR | Missing parameter comment
     165 | ERROR | Missing parameter comment
     167 | ERROR | Description for the @return value must be on the next line
     197 | ERROR | Doc comment is empty
     213 | ERROR | Doc comment is empty
     220 | ERROR | Doc comment is empty
     230 | ERROR | Description for the @return value must be on the next line
     245 | ERROR | Doc comment short description must be on a single line, further text should be a separate paragraph
     258 | ERROR | Doc comment short description must be on a single line, further text should be a separate paragraph
     296 | ERROR | @throws tag comment must end with a full stop
    ----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\tmgmt_openai.info.yml
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
     6 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ----------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\tmgmt_openai.install
    ------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------
     14 | WARNING | Line exceeds 80 characters; contains 119 characters
    ------------------------------------------------------------------------------------------
    
    Time: 331ms; Memory: 12MB
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Anjali Mehta

    Anjali Mehta โ†’ made their first commit to this issueโ€™s fork.

  • First commit to issue fork.
  • First commit to issue fork.
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12
  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shank115

    I ran phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml tmgmt_openai and found these errors:

    FILE: /home/sites/tmgmt_openai/src/Plugin/tmgmt/Translator/OpenAiTranslator.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 19 ERRORS AFFECTING 17 LINES
    -----------------------------------------------------------------------------------------------------------------------
      37 | ERROR | [x] Additional blank lines found at end of doc comment
      43 | ERROR | [x] Additional blank lines found at end of doc comment
     131 | ERROR | [ ] Missing parameter comment
     132 | ERROR | [ ] Missing parameter comment
     133 | ERROR | [x] Separate the @param and @return sections by a blank line.
     133 | ERROR | [ ] Description for the @return value must be on the next line
     165 | ERROR | [ ] Missing parameter comment
     166 | ERROR | [ ] Missing parameter comment
     167 | ERROR | [x] Separate the @param and @return sections by a blank line.
     167 | ERROR | [ ] Description for the @return value must be on the next line
     197 | ERROR | [x] Missing function doc comment
     210 | ERROR | [x] Missing function doc comment
     214 | ERROR | [x] Missing function doc comment
     221 | ERROR | [ ] Description for the @return value must be on the next line
     236 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
     249 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
     276 | ERROR | [x] Parameter comment must end with a full stop
     287 | ERROR | [ ] @throws tag comment must end with a full stop
     415 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/sites/tmgmt_openai/src/OpenAiTranslatorUi.php
    -------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     16 | ERROR | [x] Do not append variable name "$models" to the type declaration in a member variable comment
    -------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/sites/tmgmt_openai/tmgmt_openai.install
    ------------------------------------------------------------------------------------------------------------------------------
    FOUND 7 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
    ------------------------------------------------------------------------------------------------------------------------------
      3 | ERROR   | [x] The open comment tag must be the only content on the line
      4 | ERROR   | [x] The second line in the file doc comment must be "@file"
      4 | ERROR   | [x] Function comment short description must start with exactly one space
      5 | ERROR   | [ ] Wrong function doc comment end; expected "*/", found "**/"
      7 | WARNING | [x] Unused use statement
     11 | ERROR   | [x] There must be no blank lines after the function comment
     14 | ERROR   | [x] Opening brace should be on the same line as the declaration
     17 | WARNING | [ ] Line exceeds 80 characters; contains 118 characters
     17 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
    ------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/sites/tmgmt_openai/README.md
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     47 | WARNING | Line exceeds 80 characters; contains 84 characters
    ----------------------------------------------------------------------
    
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    MR #26 applied successfully.

    $ curl https://git.drupalcode.org/project/tmgmt_openai/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7516    0  7516    0     0  15117      0 --:--:-- --:--:-- --:--:-- 15153
    patching file README.md
    patching file src/OpenAiTranslatorUi.php
    patching file src/Plugin/tmgmt/Translator/OpenAiTranslator.php
    patching file tmgmt_openai.install
    

    Still some errors remaining.

    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml tmgmt_openai/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\src\Plugin\tmgmt\Translator\OpenAiTranslator.php
    ----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------
     255 | WARNING | Line exceeds 80 characters; contains 85 characters
     267 | WARNING | Line exceeds 80 characters; contains 85 characters
    ----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\tmgmt_openai.info.yml
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
     6 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ----------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\tmgmt_openai\tmgmt_openai.install
    ------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------
     14 | WARNING | Line exceeds 80 characters; contains 119 characters
    ------------------------------------------------------------------------------------------
    
    Time: 333ms; Memory: 12MB
    
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Couldn't find any issues. Please refer the screenshot.

  • Arijit Acharya โ†’ made their first commit to this issueโ€™s fork.

  • I encountered some of the warnings, listing them below. I also created a MR to fix them.
    Sorry there has been a type in creating the branch, the issue id anyhow got missed in the branch name while creating the branch. It was not intensional, I regret for it.
    Kindly review and merge.

    FILE: ...app/web/modules/custom/tmgmt_openai-3371272/tmgmt_openai.install
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     14 | WARNING | Line exceeds 80 characters; contains 119 characters
    ----------------------------------------------------------------------
    
    
    FILE: ...pp/web/modules/custom/tmgmt_openai-3371272/tmgmt_openai.info.yml
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     6 | WARNING | All dependencies must be prefixed with the project
       |         | name, for example "drupal:"
    ----------------------------------------------------------------------
    
    
    FILE: ..._openai-3371272/src/Plugin/tmgmt/Translator/OpenAiTranslator.php
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------
     255 | WARNING | Line exceeds 80 characters; contains 85 characters
     267 | WARNING | Line exceeds 80 characters; contains 85 characters
    ----------------------------------------------------------------------
    
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether

    Hi

    I reviewed MR!10, and confirmed it fixes the issues reported by phpcs.

    tmgmt_openai curl https://git.drupalcode.org/project/tmgmt_openai/-/merge_requests/10.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7849    0  7849    0     0  24386      0 --:--:-- --:--:-- --:--:-- 24917
    patching file README.md
    patching file 'src/OpenAiTranslatorUi.php'
    patching file 'src/Plugin/tmgmt/Translator/OpenAiTranslator.php'
    patching file tmgmt_openai.info.yml
    patching file tmgmt_openai.install
    โžœ  tmgmt_openai cd ..
    โžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig tmgmt_openai
    โžœ  contrib

    Moving this to RBTC.
    Thank you.

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

    After applying patch, still found some phpcs warnings...
    hence, reopening this issue.

    Sharing ss:

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata
  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    Merged at https://www.drupal.org/project/ai_tmgmt โ†’ , granted credit there.
    Thanks all!

  • Status changed to Closed: outdated about 1 month ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom scott_euser

    And the specific issue credited ๐Ÿ“Œ Add gitlab CI and fix issues Active

Production build 0.71.5 2024