Fix the issues reported by PHP_CodeSniffer

Created on 8 August 2023, over 1 year ago
Updated 16 August 2024, 3 months ago
๐Ÿ“Œ Task
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Shiv_Sharma

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 @Shiv_Sharma
  • Assigned to kpoornima
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kpoornima

    looking on it

  • Merge request !6#3379900-fixing phpcs errors โ†’ (Open) created by kpoornima
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kpoornima

    Please review and merge

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Nishant

    I have checkout 3379900-phpcs-errors this branch and run the above command, I saw some phpcs cs error, I am posting below.

    FILE: /var/www/html/web/modules/live_weather/src/Plugin/Block/LiveWeatherBlock.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/live_weather/src/Form/LiveWeatherDeleteForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/live_weather/src/Form/LiveWeatherForm.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/live_weather/src/Controller/LiveWeatherController.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/live_weather/src/LiveWeather.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Serialization\Json.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreya_98

    Review this phpcs fixed issues .

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

    Hi @Shreya_th,
    I have tested your patch and found no errors. I've attached a screenshot for your reference.

    These are the steps I followed:

    1. Took clone from git version 3.0.0 in drupal 10.1.x

    2. Ran this command:

    ./vendor/bin/phpcs --standard="Drupal,DrupalPractice" --extensions="php,module,inc,install,test,profile,theme,md,yml" modules/contrib/live_weather/

    3. Applied patch and again ran phpcs command.

    I found no error. Moving it to RTBC.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
       public function submitForm(array &$form, FormStateInterface $form_state) {
    -    parent::submitForm($form, $form_state);
    +    // parent::submitForm($form, $form_state);.
       }

    If a method is merely calling the parent method, that method can be removed. There is no need to comment out the code.

       protected $httpClient;
    -
       /**
        * A logger instance.
        *
        * @var \Psr\Log\LoggerInterface
        */
       protected $logger;
    -
       /**
        * The configuration factory service.
        *

    Between a line defining a class property and the comment for the next property there must be an empty line.

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

    Updated patch #6 by addressing #10 and some other phpcs issues (missing type hint), please review it.

    Thanks!

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vsheokeen NCR

    Took clone from latst version
    Ran the PHPCS commands
    Applied the Patch
    Ran again all commands.

    Now it looks clean. So moving to RTBC

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +      '#description' => $this->t(
    +    'Enter Where On Earth IDentification of location. Find WOEID to use this url http://woeid.rosselliot.co.nz'),
    +    ];

    The second line is not correctly indented.
    It is probably better to leave the method call on a single line, as it is easier to understand. The fact the first line ends with ( and the last line ends with ] is a bit confusing.

       public function submitForm(array &$form, FormStateInterface $form_state) {
    -    parent::submitForm($form, $form_state);
       }

    The full method must be deleted.

    +   * @param string|null $woeid
    +   *   The Where On Earth IDentifier of the location.

    IDentifier should be identifier. It is not necessary to say of the location, since a Where on Earth identifier is surely for a location.

    +        'oauth_nonce' =>
    +        uniqid(mt_rand(1, 1000)),

    The second line is not correctly indented. It is probably better to put the code on a single line.

    -        CURLOPT_HEADER => false,
    +        CURLOPT_HEADER =>
    +        FALSE,

    There is not need to put FALSE on a new line.

    +      '#title' =>
    +      $this->t('Location list'),
    +      '#description' =>
    +      $this->t('Select locations to display in block'),

    The second line is not correctly indented and it is not necessary to use two lines.

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

    Updated patch #11 by addressing #13, please review it.

    Thanks!

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
       /**
        * The Drupal configuration factory.
        *
        * @var \Drupal\Core\Config\ConfigFactoryInterface
        */
       protected $configFactory;
    -
       /**
        * The Live weather controller.
        *

    That empty line must be kept.

       /**
    -   * {@inheritdoc}
    +   * Creates an instance of the LiveWeatherForm plugin.
    +   *
    +   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
    +   *   The service container.
    +   * @param array $configuration
    +   *   An associative array of configuration settings.
    +   * @param string $plugin_id
    +   *   The plugin ID for the plugin instance.
    +   * @param mixed $plugin_definition
    +   *   The plugin definition.
    +   *
    +   * @return static
    +   *   A new instance of the LiveWeatherForm plugin.
        */
       public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

    Since that is a method defined in an interface, the existing documentation comment is already correct.

       /**
    -   * {@inheritdoc}
    +   * Builds the form for configuring the block settings.
    +   *
    +   * @param array $form
    +   *   An associative array representing the form structure.
    +   * @param \Drupal\Core\Form\FormStateInterface $form_state
    +   *   The current state of the form.
    +   *
    +   * @return array
    +   *   The built form structure.
        */
    -  public function blockForm($form, FormStateInterface $form_state) {

    The existing documentation comment is already correct.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12

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

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Yashaswi18

    Applied patch provided in #14, patch applied cleanly, all phpcs issues are fixed. The reviews yet to be addressed.
    Ran this command to check :
    phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml live_weather/

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The merge request has more recent changes. That needs to be reviewed, not the patch.

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Set to NW.

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Please check my feedback.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    I have checkout 3379900-phpcs-errors this branch and run the above command.
    There are no errors found.

    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 live_weather/
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $
    
    
    
  • Status changed to Needs work 3 months ago
  • Hi @everyone,

    Applied the latest changes on MR!6, one error was thrown by my terminal. Please see below:

    live_weather git:(main) โœ— curl https://git.drupalcode.org/project/live_weather/-/merge_requests/6.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 18602    0 18602    0     0  46684      0 --:--:-- --:--:-- --:--:-- 48191
    patching file README.md
    patching file src/Controller/LiveWeatherController.php
    patching file src/Form/LiveWeatherDeleteForm.php
    patching file src/Form/LiveWeatherForm.php
    patching file src/Form/LiveWeatherSettingsForm.php
    patching file src/LiveWeather.php
    patching file src/LiveWeatherInterface.php
    patching file src/Plugin/Block/LiveWeatherBlock.php
    โžœ  live_weather git:(main) โœ— ..
    โžœ  contrib git:(main) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig live_weather
    
    FILE: ...-site/drupal-orgissue/web/modules/contrib/live_weather/src/LiveWeather.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     190 | ERROR | [x] Doc comment short description must end with a full stop
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 365ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

  • Pipeline finished with Success
    3 months ago
    Total: 219s
    #255741
  • Assigned to apaderno
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    3 months ago
    Total: 219s
    #255744
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    avpaderno โ†’ changed the visibility of the branch 3379900-gitlab-ci-reports to hidden.

  • Pipeline finished with Success
    3 months ago
    Total: 498s
    #255747
Production build 0.71.5 2024