Fix the issues reported by phpcs

Created on 9 May 2023, about 1 year ago
Updated 15 February 2024, 4 months ago

Problem/Motivation

Module's code contains several Drupal Coding Standards issues. This task is created to fix them.

<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
Run the command:

phpcs --standard=Drupal
/web/modules/contrib/okta_user_sync/
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
Fix the following coding standards issues and upload the patch or create an MR with fixes.
FILE: \modules\contrib\okta_user_sync\src\MoOktaSupport.php
-----------------------------------------------------------------------------------------------------------
FOUND 44 ERRORS AND 2 WARNINGS AFFECTING 34 LINES
-----------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   5 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  10 | ERROR   | [x] There must be one blank line after the last USE statement; 3 found;
  13 | ERROR   | [ ] More than 2 empty lines are not allowed
  14 | ERROR   | [x] Missing class doc comment
  15 | ERROR   | [x] Opening brace should be on the same line as the declaration
  16 | ERROR   | [ ] Missing member variable doc comment
  17 | ERROR   | [ ] Missing member variable doc comment
  18 | ERROR   | [ ] Missing member variable doc comment
  19 | ERROR   | [ ] Missing member variable doc comment
  19 | ERROR   | [ ] Class property $query_description should use lowerCamel naming without underscores
  20 | ERROR   | [ ] Missing member variable doc comment
  20 | ERROR   | [ ] Class property $query_type should use lowerCamel naming without underscores
  21 | ERROR   | [x] Missing function doc comment
  21 | ERROR   | [x] Expected 1 blank line before function; 0 found
  21 | ERROR   | [x] Expected 1 space before opening brace; found 0
  30 | ERROR   | [x] Missing function doc comment
  31 | ERROR   | [x] Opening brace should be on the same line as the declaration
  47 | ERROR   | [x] Short array syntax must be used to define arrays
  47 | ERROR   | [x] The first index in a multi-value array must be on a new line
  47 | ERROR   | [x] Expected 1 space before "=>"; 0 found
  50 | ERROR   | [x] Closing parenthesis of array declaration must be on a new line
  56 | ERROR   | [x] Concat operator must be surrounded by a single space
  56 | ERROR   | [x] Concat operator must be surrounded by a single space
  57 | ERROR   | [x] Concat operator must be surrounded by a single space
  60 | ERROR   | [x] Concat operator must be surrounded by a single space
  60 | ERROR   | [x] Concat operator must be surrounded by a single space
  62 | ERROR   | [x] Short array syntax must be used to define arrays
  64 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  65 | ERROR   | [x] Short array syntax must be used to define arrays
  72 | WARNING | [x] A comma should follow the last multiline array item. Found: $content
  75 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 3 empty lines
  77 | ERROR   | [ ] More than 2 empty lines are not allowed
  78 | ERROR   | [x] Expected newline after closing brace
  84 | ERROR   | [x] Concat operator must be surrounded by a single space
  84 | ERROR   | [x] Concat operator must be surrounded by a single space
  86 | ERROR   | [x] Short array syntax must be used to define arrays
  88 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  89 | ERROR   | [x] Short array syntax must be used to define arrays
  96 | WARNING | [x] A comma should follow the last multiline array item. Found: $content
 103 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 103 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 103 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 103 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 104 | ERROR   | [x] There should be no white space after an opening "("
 107 | ERROR   | [x] Expected 1 blank line after function; 2 found

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India Shanu Chouhan

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

Comments & Activities

  • Issue created by @Shanu Chouhan
  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India _pratik_ Banglore

    Pushed with commit id 985ef95b

  • @apaderno opened merge request.
  • Issue was unassigned.
  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +  /**
    +   * Query description.
    +   */
    +  public string $queryDescription;

    The documentation comments for class properties need to also contain a @var line.

    +  /**
    +   * Construct instance of Okta support class.
    +   */
    +  public function __construct($email, $query, $queryDescription, $queryType) {

    The description for a constructor must start with Constructs a new followed by the class name (including its namespace), and ends with object.
    The documentation comment for methods must also document the parameters; that is also true for constructors.

    +  /**
    +   * Method to send support query.
    +   */
    +  public function sendSupportQuery(): bool {

    The short description is too generic.
    The parameters must be described; the return value must be described.

  • Assigned to nitin_lama
  • Issue was unassigned.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  public string $query_description;
    -  public string $query_type;
    -  public function __construct($email, $query, $query_description, $query_type){
    +
    +  /**
    +   * Query description.
    +   *
    +   * @var string
    +   */
    +  public string $queryDescription;
    +
    +  /**
    +   * Query type property.
    +   *
    +   * @var string
    +   */
    +  public string $queryType;

    Those are public properties. They cannot be renamed without breaking back compatibility. While it is true that class properties should follow the low camel case naming convention, changing a property name should be done in a new branch.

    +  /**
    +   * Contructs a new MoOktaSupport object.
    +   *
    +   * @param string $email
    +   *   The email variable.
    +   * @param string $query
    +   *   The query variable.
    +   * @param string $queryDescription
    +   *   The queryDescription variable.
    +   * @param string $queryType
    +   *   The queryType variable.
    +   */
    +  public function __construct($email, $query, $queryDescription, $queryType) {

    The short description is still not correct.

    +  /**
    +   * Method to send support query.
    +   *
    +   * @return bool
    +   *   TRUE if successful, FALSE if not.
    +   */
    +  public function sendSupportQuery(): bool {

    Method descriptions must not start with Method.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama

    8.1 still needs to be addressed. I tried to resolve the other pointers. Please review.

  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
Production build 0.69.0 2024