Fix the issue reported by phpcs.

Created on 21 June 2023, over 1 year ago
Updated 5 January 2024, 12 months ago

Problem/Motivation

Getting following error/warnings:

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_exif\README.md
------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------
82 | WARNING | Line exceeds 80 characters; contains 83 characters
88 | WARNING | Line exceeds 80 characters; contains 107 characters
------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_exif\src\ExifTagMapper.php
------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------
65 | ERROR | Doc comment is empty
99 | ERROR | Doc comment is empty
------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_exif\src\Plugin\FileMetadata\Exif.php
-----------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
-----------------------------------------------------------------------------------------------------------
44 | ERROR | Doc comment is empty
54 | ERROR | Doc comment is empty
86 | ERROR | Doc comment is empty
182 | ERROR | Doc comment is empty
189 | ERROR | Doc comment is empty
326 | ERROR | Doc comment is empty
349 | ERROR | Doc comment is empty
370 | ERROR | Doc comment is empty
-----------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_exif\tests\src\Kernel\FileMetadataExifTest.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 21 ERRORS AFFECTING 21 LINES
---------------------------------------------------------------------------------------------------------------------------------------
24 | ERROR | Missing member variable doc comment
31 | ERROR | Doc comment is empty
208 | ERROR | The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
209 | ERROR | The array declaration extends to column 115 (the limit is 80). The array content should be split up over multiple lines
212 | ERROR | The array declaration extends to column 84 (the limit is 80). The array content should be split up over multiple lines
213 | ERROR | The array declaration extends to column 123 (the limit is 80). The array content should be split up over multiple lines
217 | ERROR | The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
224 | ERROR | The array declaration extends to column 85 (the limit is 80). The array content should be split up over multiple lines
225 | ERROR | The array declaration extends to column 125 (the limit is 80). The array content should be split up over multiple lines
228 | ERROR | The array declaration extends to column 88 (the limit is 80). The array content should be split up over multiple lines
229 | ERROR | The array declaration extends to column 113 (the limit is 80). The array content should be split up over multiple lines
233 | ERROR | The array declaration extends to column 92 (the limit is 80). The array content should be split up over multiple lines
234 | ERROR | The array declaration extends to column 88 (the limit is 80). The array content should be split up over multiple lines
235 | ERROR | The array declaration extends to column 85 (the limit is 80). The array content should be split up over multiple lines
240 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
241 | ERROR | The array declaration extends to column 127 (the limit is 80). The array content should be split up over multiple lines
244 | ERROR | The array declaration extends to column 98 (the limit is 80). The array content should be split up over multiple lines
245 | ERROR | The array declaration extends to column 125 (the limit is 80). The array content should be split up over multiple lines
249 | ERROR | The array declaration extends to column 103 (the limit is 80). The array content should be split up over multiple lines
250 | ERROR | The array declaration extends to column 97 (the limit is 80). The array content should be split up over multiple lines
251 | ERROR | The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_font\README.md
------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------
15 | WARNING | Line exceeds 80 characters; contains 91 characters
------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_font\src\Plugin\FileMetadata\Font.php
-----------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------
25 | ERROR | Doc comment is empty
32 | ERROR | Doc comment is empty
84 | ERROR | Doc comment is empty
101 | ERROR | Doc comment is empty
108 | ERROR | Doc comment is empty
-----------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\file_mdm_font\tests\src\Kernel\FileMetadataFontTest.php
--------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------------------
18 | ERROR | Missing member variable doc comment
26 | ERROR | Doc comment is empty
--------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
12 | WARNING | Line exceeds 80 characters; contains 93 characters
16 | WARNING | Line exceeds 80 characters; contains 94 characters
77 | WARNING | Line exceeds 80 characters; contains 115 characters
84 | WARNING | Line exceeds 80 characters; contains 93 characters
114 | WARNING | Line exceeds 80 characters; contains 82 characters
----------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\Element\FileMetadataCaching.php
------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------
17 | ERROR | Doc comment is empty
29 | ERROR | Doc comment is empty
------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\FileMetadata.php
---------------------------------------------------------------------------------
FOUND 20 ERRORS AFFECTING 16 LINES
---------------------------------------------------------------------------------
36 | ERROR | Missing short description in doc comment
36 | ERROR | Parameter $pluginManager is not described in comment
36 | ERROR | Parameter $logger is not described in comment
36 | ERROR | Parameter $fileSystem is not described in comment
36 | ERROR | Parameter $configFactory is not described in comment
51 | ERROR | Doc comment is empty
58 | ERROR | Doc comment is empty
65 | ERROR | Doc comment is empty
76 | ERROR | Doc comment is empty
91 | ERROR | Doc comment is empty
101 | ERROR | Doc comment is empty
119 | ERROR | Doc comment is empty
142 | ERROR | Doc comment is empty
175 | ERROR | Doc comment is empty
195 | ERROR | Doc comment is empty
215 | ERROR | Doc comment is empty
223 | ERROR | Doc comment is empty
231 | ERROR | Doc comment is empty
239 | ERROR | Doc comment is empty
247 | ERROR | Doc comment is empty
---------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\FileMetadataException.php
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
12 | ERROR | Doc comment is empty
------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\FileMetadataManager.php
----------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
----------------------------------------------------------------------------------------
29 | ERROR | Doc comment is empty
62 | ERROR | Doc comment is empty
70 | ERROR | Doc comment is empty
83 | ERROR | Doc comment is empty
96 | ERROR | Doc comment is empty
110 | ERROR | Doc comment is empty
----------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\Form\SettingsForm.php
--------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------------------
26 | ERROR | Doc comment is empty
41 | ERROR | Doc comment is empty
48 | ERROR | Doc comment is empty
55 | ERROR | Doc comment is empty
108 | ERROR | Doc comment is empty
119 | ERROR | Doc comment is empty
--------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\Plugin\FileMetadata\FileMetadataPluginBase.php
---------------------------------------------------------------------------------------------------------------
FOUND 21 ERRORS AFFECTING 21 LINES
---------------------------------------------------------------------------------------------------------------
92 | ERROR | Doc comment is empty
106 | ERROR | Doc comment is empty
137 | ERROR | Doc comment is empty
166 | ERROR | Doc comment is empty
172 | ERROR | Doc comment is empty
188 | ERROR | Doc comment is empty
199 | ERROR | Doc comment is empty
206 | ERROR | Doc comment is empty
214 | ERROR | Doc comment is empty
221 | ERROR | Doc comment is empty
229 | ERROR | Doc comment is empty
236 | ERROR | Doc comment is empty
254 | ERROR | Doc comment is empty
285 | ERROR | Doc comment is empty
343 | ERROR | Doc comment is empty
378 | ERROR | Doc comment is empty
411 | ERROR | Doc comment is empty
442 | ERROR | Doc comment is empty
449 | ERROR | Doc comment is empty
477 | ERROR | Doc comment is empty
508 | ERROR | Doc comment is empty
---------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\Plugin\FileMetadata\GetImageSize.php
-----------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------
20 | ERROR | Doc comment is empty
27 | ERROR | Doc comment is empty
55 | ERROR | Doc comment is empty
68 | ERROR | Doc comment is empty
77 | ERROR | Doc comment is empty
-----------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\src\Plugin\FileMetadataPluginManager.php
-----------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------
19 | ERROR | Doc comment is empty
33 | ERROR | Doc comment is empty
-----------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\tests\src\Functional\SettingsFormTest.php
------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------
19 | ERROR | Missing member variable doc comment
27 | ERROR | Missing member variable doc comment
29 | ERROR | Doc comment is empty
------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\tests\src\Kernel\FileMetadataManagerTest.php
---------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------
18 | ERROR | Missing member variable doc comment
---------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_mdm\tests\src\Kernel\FileMetadataManagerTestBase.php
-------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------
17 | ERROR | Missing member variable doc comment
18 | ERROR | Missing member variable doc comment
20 | ERROR | Doc comment is empty
-------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run the command:

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

Proposed resolution

Above error/warnings need to be fixed

📌 Task
Status

Closed: outdated

Version

3.0

Component

Code

Created by

🇮🇳India arti_parmar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & sqlite-3.27
    last update over 1 year ago
    11 pass
  • 🇮🇳India arti_parmar

    Kindly review patch.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -getimagesize  | X    |       | Caches calls to the PHP ```getimagesize()``` function.        |
    +getimagesize  | X    |       | Caches calls to the PHP ```getimagesize()```
    +function.|

    Since that is Markdown markup for a table, that line cannot be split in two.

    -  a. Use the _FileMetadataManagerInterface::class_ service to prepare collecting metadata for
    -     the file located at a desired URI:
    +  a. Use the _FileMetadataManagerInterface::class_ service to prepare
    +  collecting metadata for the file located at a desired URI:

    Since that line is part of a list, the second line must be indented.

    -  foreach ($my_file_metadata->getSupportedKeys('exif', ['ifds' => TRUE]) as $ifd) {
    +  foreach ($my_file_metadata->getSupportedKeys('exif',
    +  ['ifds' => TRUE]) as $ifd) {

    Control structure conditions must go in a single line, as per current Drupal coding standards.

    -        $rows[] = ['data' => [$key[1], $x ? $x['text'] : NULL, $x ? var_export($x['value'], TRUE) : NULL]];
    +        $rows[] = ['data' => [$key[1], $x ? $x['text'] : NULL,
    +        $x ? var_export($x['value'], TRUE) : NULL]];

    Code lines are not required to be shorter than 81 characters. Line length and wrapping , part of the Drupal coding standards, says:

    • Lines containing longer function names, function/class definitions, variable declarations, etc are allowed to exceed 80 characters.
    • Control structure conditions may exceed 80 characters, if they are simple to read and understand.

    (Emphasis is mine.)

       /**
    -   * @param string|null $uri
    -   *   The URI of the file.
    -   * @param string $hash
    -   *   The hash used to reference the URI by file_mdm.
    +   * {@inheritdoc}
        */
       public function __construct(

    {@inheritdoc} is not used in documentation comments for constructors.
    This makes me wonder: Was {@inheritdoc} correctly used for the methods that can use it?

    +  /**
    +   * Constructor.
    +   *
    +   * @param Traversable $namespaces
    +   *   An object that implements \Traversable which contains the root paths
    +   *   keyed by the corresponding namespace to look for plugin implementations.
    +   * @param \Drupal\Core\Cache\CacheBackendInterface $cache
    +   *   The cache backend to be used.
    +   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
    +   *   The module handler.
    +   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
    +   *   The factory for configuration objects.
    +   */

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

    +  /**
    +   * Module extension list.
    +   *

    A definite article is missing in the description.
    It is not a list, but a service.

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

    The user who provided the patch/MR cannot change the status to Reviewed & tested by the community. Furthermore, since the status is Needs work, a new patch/MR needs to be provided.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & sqlite-3.27
    last update over 1 year ago
    11 pass
  • 🇮🇳India sakthi_dev

    Please review.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -Plugin        | Read | Write | Description                                                  |
    +Plugin        | Read | Write | Description|
     --------------|:----:|:-----:|--------------------------------------------------------------|
     exif          | X    | X     | Uses the [PHP Exif Library](https://github.com/lsolesen/pel) to read/write EXIF information to image files, bypassing the limitations of the standard PHP Exif extensions which only provides read capabilities. Enable the _file_mdm_exif_ submodule to enable this plugin.        |
     font          | X    |       | Uses the [PHP Font Lib](https://github.com/PhenX/php-font-lib) to read font information from TTF/OTF/WOFF font files. Enable the _file_mdm_exif_ submodule to enable this plugin.         |
    -getimagesize  | X    |       | Caches calls to the PHP ```getimagesize()``` function.        |
    +getimagesize  | X    |       | Caches calls to the PHP ```getimagesize()``` function.|
     0        | Width of the image                                           |
     1        | Height of the image                                          |
     2        | The _IMAGETYPE_*_ constant indicating the type of the image  |
    -3        | Text string with the correct _height="yyy" width="xxx"_ string that can be used directly in an IMG tag |
    +3        | Text string with the correct _height="yyy" width="xxx"_ string
    +that can be used directly in an IMG tag |
     mime     | The MIME type of the image                                   |
     channels | 3 for RGB pictures and 4 for CMYK pictures                   |
     bits     | The number of bits for each color                            |

    Since that is Markdown markup for a table, it should not be changed.

    -  a. Use the _FileMetadataManagerInterface::class_ service to prepare collecting metadata for
    -     the file located at a desired URI:
    +  a. Use the _FileMetadataManagerInterface::class_ service to prepare
    +    collecting metadata for the file located at a desired URI:

    The existing text is already correct.

    -2. __Use a known local temp copy of the remote file to avoid remote file access:__
    +2. __Use a known local temp copy of the remote file to avoid remote 
    +file access:__

    Since that text is part of a list, the second line should be indented. Then, since that line should be bold, I am not sure it can be split on two lines.

    +    $this->assertNull($file_metadata->getMetadata('exif',
    +    [1, 'imagedescription']));

    If the code is going to be split on two lines, the second line must be indented too, to make more evident that array is an argument of $file_metadata->getMetadata().
    Also, the parentheses should be placed on a new line, which is what has been done with the next changed lines.

    +    $desc_tag = $this->container->get(ExifTagMapperInterface::class)->resolveKeyToIfdAndTag([1,
    +      'imagedescription',
    +    ]);

    That is the correct way to format the code.

    +   * Constructs a new FileMetadata Object.
    +   *
    +   * @param \Drupal\file_mdm\Plugin\FileMetadataPluginManagerInterface $pluginManager
    +   *   The plugin manager.
    +   * @param \Psr\Log\LoggerInterface $logger
    +   *   The logger.
    +   * @param \Drupal\Core\File\FileSystemInterface $fileSystem
    +   *   The file System.
    +   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
    +   *   The config Factory.

    The method description is missing the class namespace.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function __construct(string $message, string $plugin_id = NULL, string $method = NULL, \Exception $previous = NULL) {

    {@inheritdoc} is not used in documentation comments for constructors.
    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and end with object.

    +  /**
    +   * Module extension extension.
    +   *
    +   * @var \Drupal\Core\Extension\ModuleExtensionList
    +   */
       protected readonly ModuleExtensionList $moduleList;

    The property description is not correct.

  • Assigned to nitin_lama
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & sqlite-3.27
    last update over 1 year ago
    11 pass
  • 🇮🇳India nitin_lama India

    Addressed #7. Please review.

  • Issue was unassigned.
  • First commit to issue fork.
  • 🇮🇳India sidharth_soman Bangalore

    Patch #9 applies cleanly and solves most of the issues. The only ones remaining are:

    C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig file_mdm-3368294
    
    FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\file_mdm-3368294\file_mdm_exif\README.md
    ----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------
     82 | WARNING | Line exceeds 80 characters; contains 83 characters
     88 | WARNING | Line exceeds 80 characters; contains 107 characters
    ----------------------------------------------------------------------------------------------------
    
    
    FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\file_mdm-3368294\README.md
    --------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------
      12 | WARNING | Line exceeds 80 characters; contains 93 characters
      16 | WARNING | Line exceeds 80 characters; contains 94 characters
      77 | WARNING | Line exceeds 80 characters; contains 115 characters
      84 | WARNING | Line exceeds 80 characters; contains 93 characters
     114 | WARNING | Line exceeds 80 characters; contains 82 characters
    --------------------------------------------------------------------------------------
    
    
    FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\file_mdm-3368294\src\Plugin\FileMetadataPluginManager.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     32 | ERROR | Expected type hint "Traversable"; found "\Traversable" for $namespaces
    ---------------------------------------------------------------------------------------------------------------------
    
    Time: 6.91 secs; Memory: 8MB
    

    I assume the above are to be left as it is for readability/accessibility purposes.

  • Status changed to Closed: outdated 12 months ago
Production build 0.71.5 2024