Fix the issues reported by phpcs

Created on 10 July 2023, over 1 year ago
Updated 2 July 2024, 5 months ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/simple_proxy/src/StreamProxyManager.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
150 | ERROR | Type hint "\Drupal\simple_proxy\Entity\StreamProxy" missing for
| | $stream_proxy
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/simple_proxy/src/StreamProxyListBuilder.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
--------------------------------------------------------------------------------
58 | ERROR | Expected type hint "ConfigFactoryInterface"; found
| | "ConfigFactory" for $config_factory
58 | ERROR | Expected type hint "StreamHandlerManagerInterface"; found
| | "StreamHandlerPluginManager" for $stream_handler_manager
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/simple_proxy/src/Commands/SimpleProxyCommands.php
-------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------
75 | ERROR | Type hint "array" missing for $options
107 | WARNING | Unused variable $uri.
-------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/simple_proxy/src/Entity/StreamProxy.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
1 | ERROR | An error occurred during processing; checking has been aborted.
| | The error message was: Malformed inline YAML string: [ at line 20
| | (near "arguments: [").
--------------------------------------------------------------------------------

FILE: .../html/vb/d_cont/simple_proxy/src/EventSubscriber/SimpleProxySubscriber.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
61 | ERROR | Expected type hint "GetResponseEvent"; found "RequestEvent" for
| | $event
--------------------------------------------------------------------------------

FILE: ...l/vb/d_cont/simple_proxy/src/Plugin/StreamHandler/PrivateStreamHandler.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
74 | WARNING | Unused variable $request_path_info.
--------------------------------------------------------------------------------

FILE: ...ml/vb/d_cont/simple_proxy/src/Plugin/StreamHandler/PublicStreamHandler.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
72 | WARNING | Unused variable $request_path_info.
--------------------------------------------------------------------------------

Time: 341ms; Memory: 12MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig simple_proxy/

Remaining tasks

Patch review

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    I have applied provided patch.
    Patch get apply cleanly.
    moving to RTBC

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

    Thank you Ashutosh for testing the patch.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The report is for seven files, but the patch changes only six files.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -  public function download($arg1 = 'test', $options = [
    +  public function download($arg1 = 'test', array $options = [
         'stream_proxy_id' => '',
         'fid' => 0,
       ]) {

    Method and function declarations must be on a single line.

    -    $request_path_info = rawurldecode($request->getPathInfo());
    +    // $request_path_info =
    +    rawurldecode($request->getPathInfo());

    The existing line and the changed line are not even equivalent. Comments starting with // are single-line comments.
    Furthermore, if a line must be removed, it does not need to be commented out; it is removed.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Updated patch #1 by addressing #5, please review it.

    Thanks!

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -    foreach ($results as $uri) {
    +    foreach ($results as $results) {

    I do not see any reason to change the variable name, but the changed code is not correct.

  • Assigned to imustakim
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad

    Fixed all the issues related to phpcs.
    Updated the patch.
    Please review.

  • Status changed to Needs work 6 months ago
  • Hi @imustakim,

    Applied patch #9 successfully, it threw errors mostly about "Multi-line function declarations ...".

    simple_proxy git:(1.0.x) curl https://www.drupal.org/files/issues/2023-10-24/3373619-9.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 12810  100 12810    0     0  38383      0 --:--:-- --:--:-- --:--:-- 39537
    patching file src/Commands/SimpleProxyCommands.php
    patching file src/Controller/ModalCredentialsController.php
    patching file src/Entity/StreamProxy.php
    patching file src/EventSubscriber/ImageDownloadControllerSubscriber.php
    patching file src/EventSubscriber/SimpleProxySubscriber.php
    patching file src/Form/CredentialsForm.php
    patching file src/Plugin/ConfigurableStreamHandlerPlugin.php
    patching file src/Plugin/StreamHandler/PrivateStreamHandler.php
    patching file src/Plugin/StreamHandler/PublicStreamHandler.php
    patching file src/Plugin/StreamHandlerPluginBase.php
    patching file src/StreamProxyListBuilder.php
    patching file src/StreamProxyManager.php
    โžœ  simple_proxy git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig simple_proxy
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/StreamProxyManager.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------
     96 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/Plugin/ConfigurableStreamHandlerPlugin.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     38 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/Plugin/StreamHandler/PrivateStreamHandler.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     35 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/Plugin/StreamHandler/PublicStreamHandler.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------
     34 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/Plugin/StreamHandlerPluginBase.php
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------
     89 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/simple_proxy/src/Commands/SimpleProxyCommands.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------------------------------
     50 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     75 | ERROR | [x] Expected 1 space between comma and "'fid'"; 0 found
     75 | ERROR | [x] Expected one space after the comma, 0 found
     75 | ERROR | [x] Comma not allowed after last value in single-line array declaration
     75 | ERROR | [x] Expected one space after the comma, 0 found
    --------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------
    
    Time: 833ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    silvi.addweb โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !2resolve phpcs issues โ†’ (Open) created by Unnamed author
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    Please review MR!2, added changes of patch #9 and also solved other issues reported by phpcs.

  • Status changed to RTBC 5 months ago
  • Hi @silvi.addweb,

    Applied MR!2's plain diff, confirmed all errors/issues fixed.

    simple_proxy git:(1.0.x) curl https://git.drupalcode.org/project/simple_proxy/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 15997    0 15997    0     0  42491      0 --:--:-- --:--:-- --:--:-- 43588
    patching file src/Commands/SimpleProxyCommands.php
    patching file src/Controller/ModalCredentialsController.php
    patching file src/Entity/StreamProxy.php
    patching file src/EventSubscriber/ImageDownloadControllerSubscriber.php
    patching file src/EventSubscriber/SimpleProxySubscriber.php
    patching file src/Form/CredentialsForm.php
    patching file src/Plugin/ConfigurableStreamHandlerPlugin.php
    patching file src/Plugin/StreamHandler/PrivateStreamHandler.php
    patching file src/Plugin/StreamHandler/PublicStreamHandler.php
    patching file src/Plugin/StreamHandlerPluginBase.php
    patching file src/StreamProxyListBuilder.php
    patching file src/StreamProxyManager.php
    โžœ  simple_proxy git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig simple_proxy
    โžœ  contrib git:(main) โœ—

    Will now move this to RTBC

    Thanks,
    Jake

Production build 0.71.5 2024