Fix the issues reported by phpcs

Created on 25 April 2023, about 1 year ago
Updated 29 June 2023, 12 months ago

Problem/Motivation

FILE: /var/www/html/web/modules/contrib/socrata/socrata_views/src/Plugin/views/query/Soql.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
99 | ERROR | Missing member variable doc comment
---------------------------------------------------------------------------------------------

FILE: /var/www/html/web/modules/contrib/socrata/socrata_catalog_search/src/SocrataCatalogSearchSelectQuery.php
--------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------
12 | ERROR | Doc comment is empty
--------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/web/modules/contrib/socrata/socrata_catalog_search/src/Plugin/views/field/SocrataList.php
-------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
47 | ERROR | Public method name "SocrataList::render_item" is not in lowerCamel format
-------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/web/modules/contrib/socrata/socrata_catalog_search/src/Plugin/views/filter/SocrataDomain.php
----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
14 | ERROR | Missing member variable doc comment
----------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/web/modules/contrib/socrata/socrata_catalog_search/src/Plugin/views/filter/SocrataFullText.php
------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------
14 | ERROR | Missing member variable doc comment
------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/web/modules/contrib/socrata/src/Entity/Endpoint.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
101 | ERROR | The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run phpcs

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇺🇸United States PapaGrande

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

  • Issue created by @PapaGrande
  • 🇺🇸United States PapaGrande

    Some of the fixes could be done by a novice, but don't worry if you can't figure out fixes for all the doc comments.

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India Nishant

    Reviewed your patch#4, and it's applied successfully.

  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States PapaGrande

    Thanks, @vimal_nadar.

    +++ b/socrata_catalog_search/src/Plugin/views/field/SocrataList.php
    @@ -44,7 +44,7 @@ class SocrataList extends PrerenderList {
    +  public function renderItem($count, $item) {
    

    The method name shouldn't be changed as it's actually implementing https://api.drupal.org/api/drupal/core%21modules%21views%21src%21Plugin%....
    Instead, please add a phpcs ignore (https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignorin...) to make the code sniffer not fail the method name.

    Reviewers, please don't just test applying the patch. Review the code changes to ensure they make sense in the context of the module and confirm the functionality is still working.

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India vimal_nadar

    @PapaGrande updated with the required changes.

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi @vimal_nadar

    The errors still exist after applying Patch #8 to the Socrata module against the 8.x-1.x-dev version and with Drupal core 9.5.6.

    Please see the attached screenshots.

    Thanks.

  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States PapaGrande

    @roberttabigue, thanks for reviewing, but I think you're sniffing the 7.x-1.x version. This issue is for 8.x-1.x.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  // phpcs:disable
       public function render_item($count, $item) {
    +    // phpcs:enable

    It is sufficient to use phpcs:ignore instead of phpcs:disable.
    Also, the method should have a documentation comment, even if that would simply contain {@inheritDoc}.

    +  /**
    +   * The name of the field to use for domain filtering.
    +   *
    +   * @var string
    +   *   The name of the field to use for domain filtering.
    +   */

    There is no need to repeat the short description after @var. That is not what the Drupal coding standards say to do, anyway.

    +  /**
    +   * Indicates whether this form element has an #aggregate callback set.
    +   *
    +   * @var bool
    +   *   TRUE if the data should be aggregated, FALSE otherwise.

    There are no descriptions to add on the line after @var.

    -    return Url::fromUri($this->getUrl(), ['query' => $params, 'absolute' => TRUE])->toString();
    +    return Url::fromUri($this->getUrl(), [
    +      'query' => $params,
    +      'absolute' => TRUE,
    +    ])->toString();
       }

    Lines are allowed to be longer than 80 characters, if they are more readable.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
       /**
    -   * {@inheritdoc}
    +   * Renders an individual item.
    +   *
    +   * @param int $count
    +   *   The count of the item being rendered.
    +   * @param array $item
    +   *   The item to be rendered.
    +   *
    +   * @return string
    +   *   The rendered item.
    +   *
    +   * @inheritdoc

    The existing documentation comment is already correct. The change is not.
    When a documentation comment contains just {@inheritdoc}, it means it is a method inherited from the parent class or defined from an interface. There is no need to describe its parameters or the return value, since the purpose of {@inheritdoc} is to avoid duplicate information already given.

    +  /**
    +   * The name of the search field used for full-text search queries.
    +   *
    +   * @var string
    +   *   The name of the search field.

    Same error already reported. (After the line containing @var, there are not descriptions to be added.)

    +    // phpcs:ignore
         return Url::fromUri($this->getUrl(), ['query' => $params, 'absolute' => TRUE])->toString();

    I am not sure which error is being suppressed there.

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
       /**
        * {@inheritdoc}
    +   *
    +   * This method returns the bare value of the item's #plain_text key
    +   * to avoid double-escaping the string.
        */

    The return value is already documented in the parent classes or an interface those classes implement; there is no need to repeat it. That's why {@inheritdoc} is used.
    Since you are leaving {@inheritdoc}, I take it is correct to use it. In this case, the change is not correct.

  • 🇮🇳India vimal_nadar

    @apaderno do you want me to remove the description which I have written after the inheritdoc? or I need to add something else as i am still confused with comment 16 ?

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    {@inheritdoc} is sufficient as documentation comment, when it is used.

  • Assigned to vimal_nadar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi @vimal_nadar,

    Failed to reflect the fixes due to errors when applying patch #20.

    Kindly refer the screenshots attached, please.

    Thank you.

  • Assigned to nitin_lama
  • Issue was unassigned.
  • 🇮🇳India nitin_lama

    #20 patch applies cleanly. @roberttabigue

    There were still some phpcs errors and warning left.

    I've fixed some issues. Not sure how to fix remaining issue.

    Remaining issues.

  • First commit to issue fork.
  • @skpal opened merge request.
  • Assigned to skpal
  • 🇮🇳India skpal Bhubaneswar

    I have opened a merge request. Please review.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India skpal Bhubaneswar
  • Status changed to RTBC about 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi @skpal,

    I reviewed your changes and all good for me.
    And after applying your latest MR, confirmed all PHPCS errors have been fixed.

    I reran this command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml

    Applied to Socrata module with 8.x-1.x-dev version and with the Drupal core version of 9.5.x.

    Attaching screenshots.

    I'm moving this again to RTBC for review.

    Thanks!

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India skpal Bhubaneswar

    Hi @apaderno,

    I have updated the commit with the requested changes. Please review.

    Thanks in advance.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India skpal Bhubaneswar
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India skpal Bhubaneswar
  • Status changed to RTBC 12 months ago
  • 🇵🇭Philippines roberttabigue

    Hi @apaderno, @skpal

    I reviewed the latest changes and I can verify that all works for me.
    Applied the latest MR as well, reran the phpcs command, and confirmed no PHPCS errors were found.

    Attached screenshot for your reference.

    Moving this now to RTBC.

    I hope everything is in order.
    Thank you.

Production build 0.69.0 2024