Fix the issues reported by phpcs

Created on 10 July 2023, over 1 year ago
Updated 8 March 2024, 10 months ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/sidekick/sidekick.module
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 7 WARNINGS AFFECTING 11 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
34 | ERROR | [x] Expected 1 space after IF keyword; 0 found
34 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
40 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | 'Acolono'
55 | ERROR | [x] Expected newline after closing brace
60 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | TRUE
70 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | ]
73 | ERROR | [x] Expected newline after closing brace
77 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | message
80 | ERROR | [x] Expected newline after closing brace
84 | WARNING | [ ] Translatable strings must not begin or end with white
| | spaces, use placeholders with t() for variables
84 | WARNING | [ ] Avoid backslash escaping in translatable strings when
| | possible, use "" quotes instead
84 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | )
94 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/sidekick/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
53 | WARNING | Line exceeds 80 characters; contains 90 characters
----------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/sidekick/src/Form/SettingsForm.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------
40 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | TRUE
46 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | )
49 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | )
64 | ERROR | [x] Expected 1 space after IF keyword; 0 found
64 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/sidekick/src/Controller/SidekickController.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
--------------------------------------------------------------------------------
41 | ERROR | [ ] Missing short description in doc comment
42 | ERROR | [ ] Missing parameter comment
43 | ERROR | [ ] Missing parameter comment
44 | ERROR | [ ] Missing parameter comment
72 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | 'Acolono'
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/sidekick/src/SidekickService.php
--------------------------------------------------------------------------------
FOUND 22 ERRORS AND 3 WARNINGS AFFECTING 15 LINES
--------------------------------------------------------------------------------
20 | ERROR | [ ] Class property $http_client should use lowerCamel naming
| | without underscores
22 | ERROR | [ ] Missing short description in doc comment
23 | ERROR | [x] Expected "key_status_api" but found "$key_status_api" for
| | @var tag in member variable comment
25 | ERROR | [ ] Class property $key_status_api should use lowerCamel naming
| | without underscores
34 | ERROR | [x] Expected 1 blank line before function; 2 found
39 | ERROR | [ ] Missing short description in doc comment
40 | ERROR | [ ] Missing parameter comment
40 | ERROR | [ ] Missing parameter type
41 | ERROR | [ ] Missing parameter comment
41 | ERROR | [ ] Missing parameter type
42 | ERROR | [ ] Description for the @return value is missing
52 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | $language_code
53 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | )
57 | WARNING | [ ] Unused variable $apiResponse.
57 | ERROR | [ ] The array declaration extends to column 101 (the limit is
| | 80). The array content should be split up over multiple
| | lines
59 | ERROR | [x] Expected newline after closing brace
59 | ERROR | [x] Expected 1 space before "|"; 0 found
59 | ERROR | [x] Expected 1 space after "|"; 0 found
59 | ERROR | [x] Expected 1 space before "|"; 0 found
59 | ERROR | [x] Expected 1 space after "|"; 0 found
59 | ERROR | [x] Expected 1 space before "|"; 0 found
59 | ERROR | [x] Expected 1 space after "|"; 0 found
62 | ERROR | [x] Expected 1 space(s) after cast statement; 0 found
65 | ERROR | [x] Expected 1 newline at end of file; 0 found
65 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 82ms; Memory: 10MB

Steps to reproduce

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

Remaining tasks

Patch review

๐Ÿ“Œ Task
Status

Needs work

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 Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Provided patch is not working.
    Throwing error while applying patch.

    git apply -v coding-standard-fixes_3.patch
    coding-standard-fixes_3.patch:10: trailing whitespace.
    * Shyamlal Sawhney (shyam-sawhney) - https://www.drupal.org/u/shyam-sawhney โ†’ /
    Checking patch README.md...
    error: while searching for:
    -----------

    Current maintainers:
    * Shyamlal Sawhney (shyam-sawhney) - https://www.drupal.org/u/shyam-sawhney โ†’ / developed by
    * Nico Grienauer (Grienauer) - https://www.drupal.org/u/grienauer โ†’

    error: patch failed: README.md:50
    error: README.md: patch does not apply
    Checking patch sidekick.module...
    error: while searching for:
    <?php

    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\Language\LanguageInterface;
    use Drupal\Core\Url;

    error: patch failed: sidekick.module:1
    error: sidekick.module: patch does not apply
    Checking patch sidekick.services.yml...
    error: while searching for:
    services:
    sidekick.service:
    class: Drupal\sidekick\SidekickService
    arguments: ['@http_client']

    error: patch failed: sidekick.services.yml:1
    error: sidekick.services.yml: patch does not apply
    Checking patch src/Controller/SidekickController.php...
    error: while searching for:
    protected $configManager;

    /**
    * @param \Drupal\Core\Session\AccountInterface $account
    * @param \Drupal\Core\Language\LanguageManagerInterface $language
    * @param \Drupal\Core\Config\ConfigManagerInterface $configManager
    */
    public function __construct(AccountInterface $account, LanguageManagerInterface $language, ConfigManagerInterface $configManager) {
    $this->account = $account;

    error: patch failed: src/Controller/SidekickController.php:39
    error: src/Controller/SidekickController.php: patch does not apply
    Checking patch src/Form/SettingsForm.php...
    error: while searching for:
    '#type' => 'textfield',
    '#title' => $this->t('API Key'),
    '#default_value' => $this->config('sidekick.settings')->get('api_key'),
    '#required' => TRUE
    ];
    $form['display_type'] = [
    '#type' => 'select',
    '#options' => [
    'inline' => $this->t('Inline'),
    'modal' => $this->t('Modal')
    ],
    '#title' => $this->t('Display type'),
    '#default_value' => $this->config('sidekick.settings')->get('display_type')
    ];

    return parent::buildForm($form, $form_state);

    error: patch failed: src/Form/SettingsForm.php:37
    error: src/Form/SettingsForm.php: patch does not apply
    Checking patch src/SidekickService.php...
    error: while searching for:
    *
    * @var \GuzzleHttp\ClientInterface
    */
    protected $http_client;

    /**
    * @var $key_status_api
    */
    protected $key_status_api;

    /**
    * Constructs a SidekickService object.
    *
    * @param \GuzzleHttp\ClientInterface $http_client
    * The HTTP client.
    */
    public function __construct(ClientInterface $http_client) {
    $this->http_client = $http_client;
    $this->key_status_api = 'https://assistant.ai-sidekick.app/api/v1/apikey-status';
    }

    /**
    * @param $api_key
    * @param $language_code
    * @return array|mixed
    */
    public function checkKeyStatus($api_key, $language_code) {
    try {
    $response = $this->http_client->post($this->key_status_api, [
    'headers' => [
    'Content-Type' => 'application/json',
    ],
    'body' => json_encode([
    'token' => $api_key,
    'language' => $language_code
    ])
    ]);

    $statusCode = $response->getStatusCode();
    return $apiResponse = ['status' => $statusCode, 'message' => json_decode($response->getBody())];

    } catch (ClientException|RequestException|TransferException|BadResponseException $exception) {
    watchdog_exception('sidekick', $exception, NULL, [], 6);

    return json_decode((string)$exception->getResponse()->getBody());
    }
    }
    }
    error: patch failed: src/SidekickService.php:17
    error: src/SidekickService.php: patch does not apply

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

    zkhan.aamir โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I was about to apply and test the MR !3 in my local but it seems that it doesn't apply properly, I used two method on how to apply patch and both seems to fail.

    โžœ  sidekick git:(master) โœ— curl https://git.drupalcode.org/project/sidekick/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 46098    0 46098    0     0  89522      0 --:--:-- --:--:-- --:--:-- 90923
    patching file README.md
    2 out of 2 hunks failed--saving rejects to README.md.rej
    patching file sidekick.module
    No such line 96 in input file, ignoring
    15 out of 15 hunks failed--saving rejects to sidekick.module.rej
    patching file 'src/Controller/SidekickController.php'
    1 out of 1 hunks failed--saving rejects to 'src/Controller/SidekickController.php.rej'
    patching file 'src/Form/SettingsForm.php'
    No such line 106 in input file, ignoring
    9 out of 9 hunks failed--saving rejects to 'src/Form/SettingsForm.php.rej'
    File to patch: 
    No file found--skip this patch? [y] 
    8 out of 8 hunks ignored--saving rejects to Oops.rej
    patching file 'src/SidekickService.php'
    No such line 66 in input file, ignoring
    10 out of 10 hunks failed--saving rejects to 'src/SidekickService.php.rej'
    โžœ  sidekick git:(master) โœ— curl https://git.drupalcode.org/project/sidekick/-/merge_requests/3.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 46098    0 46098    0     0  73311      0 --:--:-- --:--:-- --:--:-- 74231
    Skipped patch 'README.md'.
    Skipped patch 'sidekick.module'.
    Skipped patch 'src/Controller/SidekickController.php'.
    Skipped patch 'src/Form/SettingsForm.php'.
    Skipped patch 'src/ImageWidget.php'.
    Skipped patch 'src/SidekickService.php'.
    โžœ  sidekick git:(master) โœ— 
    

    Please advise

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    This needs a new MR or changes in the MR.

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

    Hi

    MR #7 does not apply successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/sidekick (1.0.x)
    $ curl https://git.drupalcode.org/project/sidekick/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 48323    0 48323    0     0   106k      0 --:--:-- --:--:-- --:--:--  106k
    patching file README.md
    patching file sidekick.module
    Hunk #2 FAILED at 14.
    Hunk #3 succeeded at 71 (offset -3 lines).
    Hunk #4 FAILED at 102.
    Hunk #5 succeeded at 122 (offset -3 lines).
    Hunk #6 FAILED at 150.
    Hunk #7 succeeded at 173 (offset -1 lines).
    Hunk #8 succeeded at 182 (offset -1 lines).
    Hunk #9 succeeded at 199 (offset -1 lines).
    Hunk #10 succeeded at 228 (offset -1 lines).
    Hunk #11 succeeded at 277 (offset -1 lines).
    Hunk #12 FAILED at 290.
    Hunk #13 succeeded at 353 (offset 8 lines).
    Hunk #14 succeeded at 394 (offset 8 lines).
    Hunk #15 succeeded at 405 (offset 8 lines).
    4 out of 15 hunks FAILED -- saving rejects to file sidekick.module.rej
    patching file src/Controller/SidekickController.php
    patching file src/Form/SettingsForm.php
    Hunk #6 succeeded at 163 (offset 1 line).
    Hunk #7 succeeded at 196 (offset 1 line).
    patching file src/ImageWidget.php
    patching file src/SidekickService.php
    Hunk #1 FAILED at 6.
    Hunk #2 succeeded at 20 (offset 1 line).
    Hunk #3 FAILED at 64.
    Hunk #4 FAILED at 130.
    Hunk #5 succeeded at 245 (offset 10 lines).
    Hunk #6 succeeded at 267 (offset 10 lines).
    Hunk #7 succeeded at 285 with fuzz 2 (offset 10 lines).
    3 out of 7 hunks FAILED -- saving rejects to file src/SidekickService.php.rej
    
Production build 0.71.5 2024