Fix the issues reported by phpcs

Created on 6 July 2023, over 1 year ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/ata_st/alter_admin_table.module
--------------------------------------------------------------------------------
FOUND 18 ERRORS AFFECTING 9 LINES
--------------------------------------------------------------------------------
14 | ERROR | [x] Opening brace should be on the same line as the declaration
15 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
16 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
17 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
17 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
18 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
18 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
19 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
19 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
20 | ERROR | [x] Case breaking statements must be followed by a single blank
| | line
20 | ERROR | [x] Case breaking statement indented incorrectly; expected 4
| | spaces, found 3
21 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
21 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
22 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 18 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/ata_st/README.md
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
--------------------------------------------------------------------------------
1 | WARNING | [ ] File has mixed line endings; this may cause incorrect
| | results
1 | WARNING | [ ] File encoding is invalid, expected UTF-8
1 | ERROR | [ ] File contains UTF-16 (LE) byte order mark, which may
| | corrupt your application
3 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
4 | WARNING | [ ] Line exceeds 80 characters; contains 124 characters
6 | WARNING | [ ] Line exceeds 80 characters; contains 204 characters
7 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
9 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
12 | WARNING | [ ] Line exceeds 80 characters; contains 136 characters
26 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
31 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
38 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
39 | WARNING | [ ] Line exceeds 80 characters; contains 152 characters
40 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
45 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/ata_st/src/Controller/HelperController.php
------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 8 LINES
------------------------------------------------------------------------------
11 | ERROR | [x] Opening brace should be on the same line as the declaration
12 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
16 | ERROR | [x] Return comment indentation must be 3 spaces, found 1 spaces
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
18 | ERROR | [x] Expected 1 blank line before function; 0 found
19 | ERROR | [x] Opening brace should be on the same line as the declaration
20 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
21 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
23 | ERROR | [x] Expected 1 blank line after function; 0 found
------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/ata_st/alter_admin_table.info.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------------

Time: 79ms; Memory: 8MB

Steps to reproduce

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

Remaining tasks

Patch review

📌 Task
Status

Needs review

Version

1.1

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 Needs work 10 months ago
  • 🇮🇳India Ashutosh Ahirwal India

    Provided patch does not get applied throwing errors.

  • First commit to issue fork.
  • Status changed to Needs review 10 months ago
  • 🇮🇳India viren18febS

    I have added a patch for the fixes. please review once.

  • 🇮🇳India pray_12

    Hi,
    I applied the patch #4.
    The above patch is throwing error.

  • 🇮🇳India Yashaswi18

    Applied both the provided patches. Both are throwing errors.

    error: while searching for:
    /**
    * Controller for the salutation message.
    */
    class HelperController extends ControllerBase
    {
    /**
    * Hello World.
    *
    * @return array
    * Our message.
    */
    public function test()
    {
    return [
    '#markup' => $this->t('Hello World'),
    ];
    }
    }

    error: patch failed: src/Controller/HelperController.php:7
    error: src/Controller/HelperController.php: patch does not apply

  • Merge request !8Fixed phpcs issues → (Open) created by Unnamed author
  • Status changed to Needs work 4 months ago
  • 🇵🇭Philippines cleavinjosh

    Hi @pray_12,

    I applied MR!8 but encountered an error.

    ➜  ata_st curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2701    0  2701    0     0   7000      0 --:--:-- --:--:-- --:--:--  7015
    Checking patch alter_admin_table.module...
    error: while searching for:
    /**
     * Implements hook_help().
     */
    function alter_admin_table_help($route_name, RouteMatchInterface $route_match)
    {
    	switch ($route_name) {
    		case 'help.page.hello_world':
    			$output = '';
    			$output .= '<h3>' . t('About') . '</h3>';
    			$output .= '<p>' . t('This is help board.') . '</p>';
    			return $output;
    		default:
    	}
    }
    
    error: patch failed: alter_admin_table.module:10
    error: alter_admin_table.module: patch does not apply
    Checking patch alter_admin_table.routing.yml...
    error: while searching for:
        _form: 'Drupal\alter_admin_table\Form\NodeViewCountSettingsForm'
        _title: 'Alter Selection Settings'
      requirements:
        _permission: 'administer modules'
    error: patch failed: alter_admin_table.routing.yml:23
    error: alter_admin_table.routing.yml: patch does not apply
    Checking patch src/Form/AlterSettingsForm.php...
    error: src/Form/AlterSettingsForm.php: No such file or directory

    Thank you.

  • 🇵🇭Philippines cleavinjosh

    Hi,

    I cloned the module and applied MR!8 on 1.1.x, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    ➜  ata_st git:(1.1.x) curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2701    0  2701    0     0   6030      0 --:--:-- --:--:-- --:--:--  6042
    patching file alter_admin_table.module
    patching file alter_admin_table.routing.yml
    patching file src/Form/AlterSettingsForm.php
    ➜  ata_st git:(1.1.x) ✗ ..
    ➜  contrib git:(main) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml ata_st
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/ata_st/README.md
    ------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    ------------------------------------------------------------------------------------------------------------------
      1 | WARNING | [ ] File has mixed line endings; this may cause incorrect results
      1 | WARNING | [ ] File encoding is invalid, expected UTF-8
      1 | ERROR   | [ ] File contains UTF-16 (LE) byte order mark, which may corrupt your application
      3 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      4 | WARNING | [ ] Line exceeds 80 characters; contains 124 characters
      6 | WARNING | [ ] Line exceeds 80 characters; contains 204 characters
      7 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      9 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
     12 | WARNING | [ ] Line exceeds 80 characters; contains 136 characters
     26 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
     31 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     38 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     39 | WARNING | [ ] Line exceeds 80 characters; contains 152 characters
     40 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
     45 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------
    
    Time: 119ms; Memory: 10MB
    
    ➜  contrib git:(main) ✗

    I also applied patch#4 and it has the same results.

    Thank you.

  • 🇮🇳India akulsaxena

    Merge Request Created

  • 🇮🇳India akulsaxena

    Hi @sumit_thakur,
    I changed the encoding from UTF-16 to UTF-8 as requested in the last comment and solved the phpcs issues in Readme.md file.
    On creating the MR, it shows "File suppressed by a .gitattributes entry or the file's encoding is unsupported."
    What encoding do we need to use in Readme.md?

  • 🇵🇭Philippines cleavinjosh

    Hi @akulsaxena,

    Thank you for providing an MR. I applied MR!8, it was applied smoothly. However, I am still seeing the issues from last time.

    Here are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    ➜  ata_st git:(1.1.x) curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2880    0  2880    0     0   6891      0 --:--:-- --:--:-- --:--:--  6889
    patching file alter_admin_table.module
    patching file alter_admin_table.routing.yml
    patching file src/Form/AlterSettingsForm.php
    ➜  ata_st git:(1.1.x) ✗ ..
    ➜  contrib git:(main) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml ata_st
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/ata_st/README.md
    ------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    ------------------------------------------------------------------------------------------------------------------
      1 | WARNING | [ ] File has mixed line endings; this may cause incorrect results
      1 | WARNING | [ ] File encoding is invalid, expected UTF-8
      1 | ERROR   | [ ] File contains UTF-16 (LE) byte order mark, which may corrupt your application
      3 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      4 | WARNING | [ ] Line exceeds 80 characters; contains 124 characters
      6 | WARNING | [ ] Line exceeds 80 characters; contains 204 characters
      7 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      9 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
     12 | WARNING | [ ] Line exceeds 80 characters; contains 136 characters
     26 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
     31 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     38 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     39 | WARNING | [ ] Line exceeds 80 characters; contains 152 characters
     40 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
     45 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------
    
    Time: 201ms; Memory: 10MB
    
    ➜  contrib git:(main) ✗

    Please check and advise.
    Thank you.

  • 🇮🇳India akulsaxena

    Hey @cleavinjosh , @sumit_thakur and @hubham-rathore-0,
    Tried to reconvert README.md file into UTF-8, and tried to solve the PHPCS error.
    Please check it once.

  • 🇵🇭Philippines cleavinjosh

    Hi @akulsaxena,

    Thank you for updating the MR. I applied MR!8, it was applied smoothly and I still see the same issues.

    ➜  ata_st git:(1.1.x) curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2880    0  2880    0     0   7150      0 --:--:-- --:--:-- --:--:--  7146
    patching file alter_admin_table.module
    patching file alter_admin_table.routing.yml
    patching file src/Form/AlterSettingsForm.php
    ➜  ata_st git:(1.1.x) ✗ ..
    ➜  contrib git:(main) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml ata_st
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/ata_st/README.md
    ------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    ------------------------------------------------------------------------------------------------------------------
      1 | WARNING | [ ] File has mixed line endings; this may cause incorrect results
      1 | WARNING | [ ] File encoding is invalid, expected UTF-8
      1 | ERROR   | [ ] File contains UTF-16 (LE) byte order mark, which may corrupt your application
      3 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      4 | WARNING | [ ] Line exceeds 80 characters; contains 124 characters
      6 | WARNING | [ ] Line exceeds 80 characters; contains 204 characters
      7 | WARNING | [ ] Line exceeds 80 characters; contains 200 characters
      9 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
     12 | WARNING | [ ] Line exceeds 80 characters; contains 136 characters
     26 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
     31 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     38 | WARNING | [ ] Line exceeds 80 characters; contains 158 characters
     39 | WARNING | [ ] Line exceeds 80 characters; contains 152 characters
     40 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
     45 | ERROR   | [x] Expected 1 newline at end of file; 0 found
    ------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------
    
    Time: 135ms; Memory: 10MB

    Thank you.

  • 🇵🇭Philippines cleavinjosh

    For some reason, when applying the MR, the README.md was not patched.

  • Merge request !9Fixed phpcs issues → (Open) created by cleavinjosh
  • 🇵🇭Philippines cleavinjosh

    cleavinjosh changed the visibility of the branch 3372895-phpcs-issues-fix to hidden.

  • 🇵🇭Philippines cleavinjosh

    Hi,

    Not sure why but after some further testing, after fetching the issue fork, git apply -v now works. I first noticed it on my newly created branch but it also works with the MR!8.

    ➜  ata_st git:(1.1.x) curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2880    0  2880    0     0   7191      0 --:--:-- --:--:-- --:--:--  7218
    Checking patch README.md...
    error: missing binary patch data for 'README.md'
    error: binary patch does not apply to 'README.md'
    error: README.md: patch does not apply
    Checking patch alter_admin_table.module...
    Checking patch alter_admin_table.routing.yml...
    Checking patch src/Form/AlterSettingsForm.php...
    ➜  ata_st git:(1.1.x) git remote add ata_st-3372895 git@git.drupal.org:issue/ata_st-3372895.git
    git fetch ata_st-3372895
    Enter passphrase for key '/Users/interns/.ssh/id_rsa':
    remote: Enumerating objects: 26, done.
    remote: Counting objects: 100% (26/26), done.
    remote: Compressing objects: 100% (17/17), done.
    remote: Total 19 (delta 10), reused 0 (delta 0), pack-reused 0 (from 0)
    Unpacking objects: 100% (19/19), 2.68 KiB | 80.00 KiB/s, done.
    From git.drupal.org:issue/ata_st-3372895
     * [new branch]      1.0.x                    -> ata_st-3372895/1.0.x
     * [new branch]      1.1.x                    -> ata_st-3372895/1.1.x
     * [new branch]      3372895-fix-the-issues   -> ata_st-3372895/3372895-fix-the-issues
     * [new branch]      3372895-phpcs-issues-fix -> ata_st-3372895/3372895-phpcs-issues-fix
    ➜  ata_st git:(1.1.x) curl https://git.drupalcode.org/project/ata_st/-/merge_requests/8.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2880    0  2880    0     0   7624      0 --:--:-- --:--:-- --:--:--  7619
    Checking patch README.md...
    Checking patch alter_admin_table.module...
    Checking patch alter_admin_table.routing.yml...
    Checking patch src/Form/AlterSettingsForm.php...
    Applied patch README.md cleanly.
    Applied patch alter_admin_table.module cleanly.
    Applied patch alter_admin_table.routing.yml cleanly.
    Applied patch src/Form/AlterSettingsForm.php cleanly.
    ➜  ata_st git:(1.1.x) ✗

    Changing the status to needs review for others.

    Please check and advise.
    Thank you.

  • 🇮🇳India akulsaxena

    @cleavinjosh Is the patch now fixing the error in readme file when you apply it using git apply -v?

  • 🇵🇭Philippines cleavinjosh

    Hi @akulsaxena,

    Yes, it is now working. However, for some reason, it won't work right after I cloned the module. But after I fetch this issue fork’s repository, it works.

    I don't know if it is connected.

  • Status changed to Needs review 8 days ago
  • 🇮🇳India akulsaxena

    Hey @cleavinjosh
    The patch was made for the issue branch 1.1.x-dev.
    The module is released till tag 1.1.2 which is 4 commits behind the 1.1.x branch. So the patch is failing there if you clone the module. When we move to 1.1.x branch which is up to date with the upstream repository, the patch works and solves the issue.

  • 🇵🇭Philippines cleavinjosh

    Hi @akulsaxena,

    Thank you for the explanation.

    Since the patch now works, this can be moved to RTBC.

    Thank you.

Production build 0.71.5 2024