Fix the issues reported by phpcs

Created on 24 May 2023, about 1 year ago
Updated 8 June 2023, about 1 year ago

Problem/Motivation

FILE: ...n/drupal10/web/modules/contrib/gravitas_countdown/js/gravitas-countdown.js
--------------------------------------------------------------------------------
FOUND 39 ERRORS AFFECTING 37 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
2 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
3 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
3 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
4 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
4 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
5 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
6 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
8 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
9 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
10 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
11 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
12 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
14 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
17 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
18 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
19 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
21 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
22 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
23 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
24 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
25 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
26 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
27 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
28 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
29 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
30 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
31 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
33 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
34 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
35 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
36 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
37 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
38 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
39 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
40 | ERROR | [x] Expected 1 newline at end of file; 3 found
42 | ERROR | [x] Additional whitespace found at end of file
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 39 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...rupal10/web/modules/contrib/gravitas_countdown/gravitas_countdown.info.yml
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
7 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...tml/contribution/drupal10/web/modules/contrib/gravitas_countdown/README.md
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 12 WARNINGS AFFECTING 13 LINES
--------------------------------------------------------------------------------
3 | WARNING | [ ] Line exceeds 80 characters; contains 283 characters
6 | WARNING | [ ] Line exceeds 80 characters; contains 195 characters
8 | WARNING | [ ] Line exceeds 80 characters; contains 218 characters
10 | WARNING | [ ] Line exceeds 80 characters; contains 250 characters
12 | WARNING | [ ] Line exceeds 80 characters; contains 238 characters
14 | WARNING | [ ] Line exceeds 80 characters; contains 180 characters
16 | WARNING | [ ] Line exceeds 80 characters; contains 239 characters
18 | WARNING | [ ] Line exceeds 80 characters; contains 241 characters
20 | WARNING | [ ] Line exceeds 80 characters; contains 287 characters
23 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
25 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
26 | WARNING | [ ] Line exceeds 80 characters; contains 99 characters
27 | ERROR | [x] Expected 1 newline at end of file; 3 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...les/contrib/gravitas_countdown/src/Plugin/Block/GravitasCountdownBlock.php
--------------------------------------------------------------------------------
FOUND 64 ERRORS AND 32 WARNINGS AFFECTING 78 LINES
--------------------------------------------------------------------------------
19 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
25 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
37 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
50 | ERROR | [x] Expected 1 space before "??"; 0 found
50 | ERROR | [x] Expected 1 space after "??"; 0 found
56 | ERROR | [x] Expected 1 space before "??"; 0 found
64 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
70 | ERROR | [x] Short array syntax must be used to define arrays
72 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
73 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
76 | ERROR | [x] Short array syntax must be used to define arrays
77 | ERROR | [x] Short array syntax must be used to define arrays
83 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
84 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
85 | ERROR | [x] Short array syntax must be used to define arrays
86 | WARNING | [ ] #options values usually have to run through t() for
| | translation
87 | WARNING | [ ] #options values usually have to run through t() for
| | translation
88 | WARNING | [ ] #options values usually have to run through t() for
| | translation
89 | WARNING | [ ] #options values usually have to run through t() for
| | translation
90 | WARNING | [ ] #options values usually have to run through t() for
| | translation
91 | WARNING | [ ] #options values usually have to run through t() for
| | translation
92 | WARNING | [ ] #options values usually have to run through t() for
| | translation
93 | WARNING | [ ] #options values usually have to run through t() for
| | translation
94 | WARNING | [ ] #options values usually have to run through t() for
| | translation
95 | WARNING | [ ] #options values usually have to run through t() for
| | translation
102 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
103 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
104 | ERROR | [x] Short array syntax must be used to define arrays
105 | WARNING | [ ] #options values usually have to run through t() for
| | translation
106 | WARNING | [ ] #options values usually have to run through t() for
| | translation
107 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: 'Light'
119 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
128 | WARNING | [ ] Unused variable $description.
129 | WARNING | [ ] Unused variable $old_countdown_image_ids.
129 | ERROR | [x] Short array syntax must be used to define arrays
130 | WARNING | [ ] Unused variable $current_countdown_image_ids.
130 | ERROR | [x] Short array syntax must be used to define arrays
133 | ERROR | [x] Expected 1 space after IF keyword; 0 found
148 | ERROR | [x] Inline comments must start with a capital letter
148 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
152 | WARNING | [ ] Unused variable $key.
153 | WARNING | [ ] File::load calls should be avoided in classes, use
| | dependency injection instead
157 | ERROR | [x] Expected newline after closing brace
158 | WARNING | [ ] Unused variable $key.
159 | WARNING | [ ] File::load calls should be avoided in classes, use
| | dependency injection instead
167 | ERROR | [x] Functions must not contain multiple empty lines in a row;
| | found 2 empty lines
169 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE"
| | but found "false"
174 | ERROR | [x] Expected 1 space after IF keyword; 0 found
175 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 7
175 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
176 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
176 | ERROR | [x] Closing brace indented incorrectly; expected 6 spaces,
| | found 5
178 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
179 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
179 | WARNING | [ ] File::load calls should be avoided in classes, use
| | dependency injection instead
180 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
181 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
182 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
184 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
185 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
185 | ERROR | [x] Closing brace indented incorrectly; expected 5 spaces,
| | found 4
186 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
186 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces,
| | found 2
186 | ERROR | [x] Expected newline after closing brace
187 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
187 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
188 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
190 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
190 | ERROR | [x] Expected 1 space after IF keyword; 0 found
191 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
191 | ERROR | [x] Expected 1 space after IF keyword; 0 found
192 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 5
193 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 5
193 | WARNING | [ ] File::load calls should be avoided in classes, use
| | dependency injection instead
194 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 5
195 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 6
196 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 8
197 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 6
198 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4
198 | ERROR | [x] Closing brace indented incorrectly; expected 5 spaces,
| | found 4
199 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 2
199 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces,
| | found 2
200 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
200 | ERROR | [x] Closing brace indented incorrectly; expected 2 spaces,
| | found 0
201 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
201 | ERROR | [x] Closing brace indented incorrectly; expected 2 spaces,
| | found 0
207 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
208 | WARNING | [ ] Unused variable $config.
218 | ERROR | [x] Expected 1 space after IF keyword; 0 found
222 | ERROR | [x] Expected 1 space after IF keyword; 0 found
223 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
226 | ERROR | [x] Expected 1 space after IF keyword; 0 found
228 | WARNING | [ ] File::load calls should be avoided in classes, use
| | dependency injection instead
229 | ERROR | [x] Expected 1 space after IF keyword; 0 found
243 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: $banner_url
249 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 66 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: .../drupal10/web/modules/contrib/gravitas_countdown/gravitas_countdown.module
--------------------------------------------------------------------------------
FOUND 74 ERRORS AND 12 WARNINGS AFFECTING 49 LINES
--------------------------------------------------------------------------------
18 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
19 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
19 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
20 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 2
21 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
21 | ERROR | [x] Case breaking statement 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
26 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
27 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
27 | ERROR | [x] There must be no blank lines after the function comment
30 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
38 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: NULL
39 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
40 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
42 | ERROR | [x] Expected 1 blank line after function; 2 found
46 | ERROR | [x] Doc comment short description must end with a full stop
47 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
47 | ERROR | [ ] Missing parameter comment
47 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found
| | 2
48 | ERROR | [x] Separate the @param and @return sections by a blank line.
48 | ERROR | [ ] Description for the @return value is missing
50 | ERROR | [ ] Type hint "[type]" missing for $countdown_data_config
51 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
52 | ERROR | [x] Short array syntax must be used to define arrays
55 | WARNING | [ ] Unused variable $key.
67 | ERROR | [x] Doc comment short description must start with a capital
| | letter
68 | ERROR | [ ] Doc comment short description must end with a full stop
68 | ERROR | [ ] Doc comment short description must be on a single line,
| | further text should be a separate paragraph
69 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
69 | ERROR | [ ] Missing parameter comment
69 | ERROR | [x] Expected 1 spaces after parameter type; 13 found
69 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found
| | 2
70 | ERROR | [ ] Missing parameter comment
70 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found
| | 2
70 | ERROR | [x] Data types in @param tags need to be fully namespaced
71 | ERROR | [x] Separate the @param and @return sections by a blank line.
71 | ERROR | [ ] @return doc comment specified, but function has no return
| | statement
71 | ERROR | [ ] Description for the @return value is missing
73 | ERROR | [ ] Type hint "[type]" missing for &$form
74 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
79 | ERROR | [x] Inline comments must start with a capital letter
79 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
84 | ERROR | [x] Inline comments must start with a capital letter
84 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
111 | ERROR | [x] Doc comment short description must start with a capital
| | letter
112 | ERROR | [ ] Doc comment short description must end with a full stop
112 | ERROR | [ ] Doc comment short description must be on a single line,
| | further text should be a separate paragraph
113 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
113 | ERROR | [ ] Missing parameter comment
113 | ERROR | [x] Expected 1 spaces after parameter type; 13 found
113 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found
| | 2
114 | ERROR | [ ] Missing parameter comment
114 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found
| | 2
114 | ERROR | [x] Data types in @param tags need to be fully namespaced
115 | ERROR | [x] Separate the @param and @return sections by a blank line.
115 | ERROR | [ ] @return doc comment specified, but function has no return
| | statement
115 | ERROR | [ ] Description for the @return value is missing
117 | ERROR | [ ] Type hint "[type]" missing for $form
118 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
123 | WARNING | [ ] Unused variable $key.
132 | ERROR | [ ] Missing short description in doc comment
133 | ERROR | [ ] Missing parameter comment
133 | ERROR | [ ] Missing parameter type
137 | ERROR | [x] Opening brace should be on the same line as the
| | declaration
149 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
150 | ERROR | [x] Expected 1 space(s) before asterisk; 0 found
157 | ERROR | [x] No space found before comment text; expected "// if
| | (isset($element['preview'])) {" but found "//if
| | (isset($element['preview'])) {"
161 | WARNING | [x] There must be no blank line following an inline comment
161 | WARNING | [ ] There must be no blank line following an inline comment
161 | ERROR | [x] No space found before comment text; expected "// }" but
| | found "//}"
161 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
163 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
167 | WARNING | [ ] Line exceeds 80 characters; contains 143 characters
168 | WARNING | [ ] Line exceeds 80 characters; contains 147 characters
168 | WARNING | [x] There must be no blank line following an inline comment
168 | WARNING | [ ] There must be no blank line following an inline comment
168 | ERROR | [x] No space found before comment text; expected "// $output
| | .= theme('image_style', array('style_name' => 'thumbnail',
| | 'path' => file_load($element['fid']['#value'])->uri,
| | 'getsize' => FALSE));" but found "//$output .=
| | theme('image_style', array('style_name' => 'thumbnail',
| | 'path' => file_load($element['fid']['#value'])->uri,
| | 'getsize' => FALSE));"
168 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
170 | ERROR | [x] Short array syntax must be used to define arrays
170 | ERROR | [ ] The array declaration extends to column 141 (the limit is
| | 80). The array content should be split up over multiple
| | lines
170 | ERROR | [x] Concat operator must be surrounded by a single space
180 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
187 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 58 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: .../modules/contrib/gravitas_countdown/templates/gravitas-countdown.html.twig
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
39 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 514ms; Memory: 10MB

Steps to reproduce

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

Proposed resolution

Fix all the issues for Drupal and DrupalPractice standards.

Remaining tasks

Provide a Patch.

For Dependency injections, follow issue:

📌 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

Comments & Activities

  • Issue created by @urvashi_vora
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Assigned to myself, will provide a patch ASAP.

    Thanks

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Please review this patch. Thanks.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
     /**
      * @file
    - * Contains gravitas_countdown.module.
    + * Hook implementations for gravitas_countdown module.
      */

    The usual module description is Hook implementations for the [module name] module. where [module name] is replaced by the module name shown in the .info.yml file.

    + * Get previous image ids of the countdown.
    + *
    + * @param string $countdown_data_config
    + *   The configuration data for the countdown.
    + *
    + * @return array
    + *   An array of previous image IDs.
      */
    -function get_countdown_description_images($countdown_data_config)
    -{
    -  $image_ids = array();
    +function get_countdown_description_images($countdown_data_config) {

    Since that documentation comment is edited:

    • The verb used in the description must use the third person singular
    • ids is misspelled and it must be corrected
    • Assuming that the description is about countdown images, a better description would be Gets the previous countdown image IDs.
     /**
    - * form alter block_delete_form to delete the images used
    - * on the block
    - * @param  [type]             &$form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Implements Form alter block_delete_form.
    + *
    + * To delete the images used on the block.
    + *
    + * @param array &$form
    + *   The form being altered.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   The current state of the form.
      */
    -function gravitas_countdown_form_alter(&$form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_alter(array &$form, FormStateInterface $form_state) {

    Since that is a hook implementation, the documentation comment is shorter.
    The description is not correct.

    -    // get block entity
    +    // Get block entity.
         if ($block_entity) {

    A definite article is missing in the comment.

    -      // check if the plugin id is gravitas_countdown
    +      // Check if the plugin id is gravitas_countdown.
           if ($block_plugin_id == 'gravitas_countdown') {

    That comment is not necessary, since it describes something that is clear from the code.

     /**
    - * submit form callback to remove the images used
    - * on the countdown block
    - * @param  [type]             $form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Submit form callback.
    + *
    + * To remove the images used on the countdown block.
    + *
    + * @param array $form
    + *   The form being submitted.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   The current state of the form.
      */
    -function gravitas_countdown_form_submit($form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_submit(array $form, FormStateInterface $form_state) {

    Since that is a form submission handler, its documentation comment is different.
    The hook description must make clear to which form the submission handler is added, which is usually done by using the form ID.

    + * @return array
    + *   An array of file IDs used in the countdown editor.
      */
    -function get_countdown_editor_files($content)

    It is not necessary to repeat the return value type, in the return value description.

     /**
    -* Implements theme_mymodule_thumb_upload theme callback.
    -*/
    + * Implements theme_mymodule_thumb_upload theme callback.
    + */
     function theme_mymodule_thumb_upload($variables) {
     /**
    -* Implements theme_mymodule_thumb_upload theme callback.
    -*/
    + * Implements theme_mymodule_thumb_upload theme callback.
    + */
     function theme_mymodule_thumb_upload($variables) {

    Not considering that Drupal 8/9/10 do not have anymore theme implementations, the documentation comment for theme implementations is different. It is like the following one, for example.

    /**
     * Returns HTML for a select form element.
     *
     * It is possible to group options together; to do this, change the format of
     * $options to an associative array in which the keys are group labels, and the
     * values are associative arrays in the normal $options format.
     *
     * @param $variables
     *   An associative array containing:
     *   - element: An associative array containing the properties of the element.
     *     Properties used: #title, #value, #options, #description, #extra,
     *     #multiple, #required, #name, #attributes, #size.
     *
     * @ingroup themeable
     */
    function theme_select($variables) {
      $element = $variables['element'];
      element_set_attributes($element, array('id', 'name', 'size'));
      _form_set_class($element, array('form-select'));
      return '<select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select>';
    }
    
    -  // The remove button is already taken care of by rendering the rest of the form. No need to hack up some HTML!
    +  // The remove button is already taken care of
    +  // by rendering the rest of the form.
    +  // No need to hack up some HTML!
    

    Avoiding that lines exceed 80 characters does not mean making them too short.

    +            var counter = setInterval(function () {
    +                var now = new Date().getTime();
    +                var daysInnerText, hoursInnerText, minutesInnerText, secondsInnerText;
    +                var distance = countDown - now;
    +                if(distance < 0) {
    

    The lines after the first are not correctly indented.
    There must be a space between if and the next parenthesis.

  • Assigned to urvashi_vora
  • 🇮🇳India urvashi_vora Madhya Pradesh, India
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Hi,

    I modified the patch accordingly, please review.

    Also, @apaderno, for the point where you gave feedback for:

    +            var counter = setInterval(function () <strong>{</strong>
    +                var now = new Date().getTime();
    +                var daysInnerText, hoursInnerText, minutesInnerText, secondsInnerText;
    +                var distance = countDown - now;
    +                if(distance < 0) {
    
    The lines after the first are not correctly indented.
    There must be a space between if and the next parenthesis.

    It is important to note that all the lines in the code are properly indented. There might have been some confusion due to the initial lines starting with "var" and the curly brace not being clearly visible. Such confusions can happen, and I appreciate your understanding. Nevertheless, I have made the necessary changes as requested in the rest of the code. Thank you for bringing the rest of the issues to my attention.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Indentation in JavaScript files is two spaces. That means that each time the indentation is increased, it is increased of two spaces, not four.
    The fact the previous line starts a function does not change that. Otherwise, Drupal core will not format the following code as it does.

          $row.find('.js-real-checkbox').each(function () {
            this.style.display = authCheckbox.checked ? 'none' : '';
          });
          $row.find('.js-dummy-checkbox').each(function () {
            this.style.display = authCheckbox.checked ? '' : 'none';
          });
    
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Formatted the file with two space indentation.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
     /**
      * @file
    - * Contains gravitas_countdown.module.
    + * Hook implementations for Gravitas Countdown module.
      */
    

    The description is missing a definite article after for.

     /**
    - * form alter block_delete_form to delete the images used
    - * on the block
    - * @param  [type]             &$form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Implements hook_form_alter().
    + *
    + * Hook used to delete the images used on the block.
      */
    -function gravitas_countdown_form_alter(&$form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_alter(array &$form, FormStateInterface $form_state) {

    For hook implementations, the description starts with Implements followed by the hook name.

    + * Removes the images used on the countdown block
    + * after the block_delete_form form submission.
    + * This submission handler, gravitas_countdown_form_submit,
    + * is added to the block_delete_form form
    + * when the block entity's plugin ID is 'gravitas_countdown'.
    + *
    + * @param array $form
    + *   The form being submitted.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   The current state of the form.
      */
    -function gravitas_countdown_form_submit($form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_submit(array $form, FormStateInterface $form_state) {

    The documentation comment for form submission handlers is different from the documentation comments for other functions. API documentation and comment standards / Form-generating functions → shows an example of documentation comment for a form validation handler and a forum submission handler.

     /**
    - * @param $content
    + * Retrieves the file IDs associated with the countdown editor content.
    + *
    + * @param string $content
    + *   The content of the countdown editor.
    + *
      * @throws \Drupal\Core\Entity\EntityStorageException
    + *   If there is an error loading the file entities.
    + *
    + * @return array
    + *   An array of file IDs used in the countdown editor.
      */
    

    As per Drupal API documentation standards for order of documentation sections → , the @throws line must be after the @return line.
    @throws: Thrown exceptions → says:

    Drupal standards notes: The name of an exception class should appear on the same line as the @throws tag. Put explanations in starting on the next line, but only if they tell you something useful that is not conveyed by the name of the class. If you include an explanation, like other documentation use complete sentences that stand alone, without assuming that "Throws [exception name]" is part of the sentence automatically, since Throws will be a heading when it's displayed on api.drupal.org.

    -* Implements theme_mymodule_thumb_upload theme callback.
    -*/
    + * Theme function for rendering the thumbnail upload element.
    + *
    + * Renders the HTML output for the thumbnail upload element,
    + * including the image preview and additional widget data.
    + */
     function theme_mymodule_thumb_upload($variables) {

    The (short) description must be a single line and not exceed 80 characters (with the usual exceptions).
    As shown in Themeable functions → , the parameter must be described.

    /**
     * Returns HTML for a foo.
     *
     * @param array $variables
     *   An associative array containing:
     *   - foo: The foo object that is being formatted.
     *   - show_bar: TRUE to show the bar component, FALSE to omit it.
     *
     * @ingroup themeable
     */
    function theme_foo($variables) {
    
       // My uploaded element didn't have a preview array item, so this didn't work
    -  //if (isset($element['preview'])) {
    -  //  $output .= '<div class="image-preview">';
    -  //  $output .= drupal_render($element['preview']);
    -  //  $output .= '</div>';
    -  //}
    -
    -  // If image is uploaded show its thumbnail to the output HTML
    +  // if (isset($element['preview'])) {
    +  // $output .= '<div class="image-preview">';
    +  // $output .= drupal_render($element['preview']);
    +  // $output .= '</div>';
    +  // }
    

    Even for commented out code, the indentation must be preserved. The existing code is the following one.

      // My uploaded element didn't have a preview array item, so this didn't work
      //if (isset($element['preview'])) {
      //  $output .= '<div class="image-preview">';
      //  $output .= drupal_render($element['preview']);
      //  $output .= '</div>';
      //}
    

    It is correct to add a space after the comment delimiter, but the lines inside the if control statement must be indented two spaces more compared to if.

      // My uploaded element didn't have a preview array item, so this didn't work
      // if (isset($element['preview'])) {
      //   $output .= '<div class="image-preview">';
      //   $output .= drupal_render($element['preview']);
      //   $output .= '</div>';
      // }
    

    There must be a space between if and the parenthesis.

    +        } else {
    +          daysInnerText = Math.floor(distance / (day));
    +          hoursInnerText = Math.floor((distance % (day)) / (hour));
    +          minutesInnerText = Math.floor((distance % (hour)) / (minute)); secondsInnerText = Math.floor((distance % (minute)) / second);
    +        }

    As shown in Control Structures → else is put on its own line.
    secondsInnerText = Math.floor((distance % (minute)) / second); must be on a new line.

    -    $description = $values['description_settings']['description'] ?? '';
    -    $old_countdown_image_ids = array();
    -    $current_countdown_image_ids = array();
    -
    +    // $description = $values['description_settings']['description'] ?? '';
    +    // $old_countdown_image_ids = [];
    +    // $current_countdown_image_ids = [];
    

    Code lines that must be deleted, are not commented out.

    -      $file->setPermanent();
    +      /* Load the object of the file by it's fid */
    +      $file = File::load($image_fid);
    

    Inside methods or functions, the used comment delimiter is //. it's is a misspelling for its, the possessive pronoun for it. the object of the file should be the file object.
    I would rather remove that comment, as it is not necessary for $file = File::load($image_fid); which is already clear by itself.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Updated the patch.

    As per #9:

    The description is missing a definite article after for.

    The word "for" is added.

    /**
    - * form alter block_delete_form to delete the images used
    - * on the block
    - * @param  [type]             &$form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Implements hook_form_alter().
    + *
    + * Hook used to delete the images used on the block.
      */
    -function gravitas_countdown_form_alter(&$form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_alter(array &$form, FormStateInterface $form_state) {
    For hook implementations, the description starts with Implements followed by the hook name.

    The description is appropriate and starts with "Implements" followed by hook name i.e. hook_form_alter.

    + * Removes the images used on the countdown block
    + * after the block_delete_form form submission.
    + * This submission handler, gravitas_countdown_form_submit,
    + * is added to the block_delete_form form
    + * when the block entity's plugin ID is 'gravitas_countdown'.
    + *
    + * @param array $form
    + *   The form being submitted.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   The current state of the form.
      */
    -function gravitas_countdown_form_submit($form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_submit(array $form, FormStateInterface $form_state) {
    The documentation comment for form submission handlers is different from the documentation comments for other functions. API documentation and comment standards / Form-generating functions shows an example of documentation comment for a form validation handler and a forum submission handler.

    Standard first line comment is added, the rest is general description of the submission handler

     /**
    - * @param $content
    + * Retrieves the file IDs associated with the countdown editor content.
    + *
    + * @param string $content
    + *   The content of the countdown editor.
    + *
      * @throws \Drupal\Core\Entity\EntityStorageException
    + *   If there is an error loading the file entities.
    + *
    + * @return array
    + *   An array of file IDs used in the countdown editor.
      */
    As per Drupal API documentation standards for order of documentation sections, the @throws line must be after the @return line.
    @throws: Thrown exceptions says:

    Drupal standards notes: The name of an exception class should appear on the same line as the @throws tag. Put explanations in starting on the next line, but only if they tell you something useful that is not conveyed by the name of the class. If you include an explanation, like other documentation use complete sentences that stand alone, without assuming that "Throws [exception name]" is part of the sentence automatically, since Throws will be a heading when it's displayed on api.drupal.org.

    Repositioned @throws tag after @return.

    -* Implements theme_mymodule_thumb_upload theme callback.
    -*/
    + * Theme function for rendering the thumbnail upload element.
    + *
    + * Renders the HTML output for the thumbnail upload element,
    + * including the image preview and additional widget data.
    + */
     function theme_mymodule_thumb_upload($variables) {
    The (short) description must be a single line and not exceed 80 characters (with the usual exceptions).
    As shown in Themeable functions, the parameter must be described.

    Reverted the original description added by maintainer, the rest information explains the functionality.

       // My uploaded element didn't have a preview array item, so this didn't work
    -  //if (isset($element['preview'])) {
    -  //  $output .= '<div class="image-preview">';
    -  //  $output .= drupal_render($element['preview']);
    -  //  $output .= '</div>';
    -  //}
    -
    -  // If image is uploaded show its thumbnail to the output HTML
    +  // if (isset($element['preview'])) {
    +  // $output .= '<div class="image-preview">';
    +  // $output .= drupal_render($element['preview']);
    +  // $output .= '</div>';
    +  // }
    Even for commented out code, the indentation must be preserved.
    It is correct to add a space after the comment delimiter, but the lines inside the if control statement must be indented two spaces more compared to if.

    Space is added for the lines under "if".

    // My uploaded element didn't have a preview array item, so this didn't work
      // if (isset($element['preview'])) {
      //   $output .= '<div class="image-preview">';
      //   $output .= drupal_render($element['preview']);
      //   $output .= '</div>';
      // }
    There must be a space between if and the parenthesis.

    Unsure of this, as I can see space between "if" and parenthesis. Can you please elaborate this?

    +        } else {
    +          daysInnerText = Math.floor(distance / (day));
    +          hoursInnerText = Math.floor((distance % (day)) / (hour));
    +          minutesInnerText = Math.floor((distance % (hour)) / (minute)); secondsInnerText = Math.floor((distance % (minute)) / second);
    +        }
    As shown in Control Structures else is put on its own line.
    secondsInnerText = Math.floor((distance % (minute)) / second); must be on a new line.

    Moved "else" to a new line and also the "secondsInnerText = Math.floor((distance % (minute)) / second);".

    -    $description = $values['description_settings']['description'] ?? '';
    -    $old_countdown_image_ids = array();
    -    $current_countdown_image_ids = array();
    -
    +    // $description = $values['description_settings']['description'] ?? '';
    +    // $old_countdown_image_ids = [];
    +    // $current_countdown_image_ids = [];
    Code lines that must be deleted, are not commented out.

    No, I can't delete these lines as the module is under active development and these variables are unused variables as of now, but the maintainer might need it, thus commented them to meet the coding standards requirement. However, before removing them, we should ask for the maintainer's permission.

    -      $file->setPermanent();
    +      /* Load the object of the file by it's fid */
    +      $file = File::load($image_fid);
    Inside methods or functions, the used comment delimiter is //. it's is a misspelling for its, the possessive pronoun for it. the object of the file should be the file object.
    I would rather remove that comment, as it is not necessary for $file = File::load($image_fid); which is already clear by itself.

    Removed the comment.

    Do let me know, if you have any more suggestions. Thanks

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
     /**
    - * form alter block_delete_form to delete the images used
    - * on the block
    - * @param  [type]             &$form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Implements hook_form_alter().
    + *
    + * Hook used to delete the images used on the block.
      */
    -function gravitas_countdown_form_alter(&$form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_alter(array &$form, FormStateInterface $form_state) {
       if ($form['#form_id'] == 'block_delete_form') {
    

    Only the short description is used for hook implementations. In the case of hook_form_alter() implementation, the short description must say which form is altered. (That is shown in the last line I quoted.)

    - * submit form callback to remove the images used
    - * on the countdown block
    - * @param  [type]             $form
    - * @param  FormStateInterface $form_state
    - * @return [type]
    + * Form submission handler for block_delete_form().
    + *
    + * Removes the images used on the countdown block
    + * after the block_delete_form form submission.
    + * This submission handler, gravitas_countdown_form_submit,
    + * is added to the block_delete_form form
    + * when the block entity's plugin ID is 'gravitas_countdown'.
    + *
    + * @param array $form
    + *   The form being submitted.
    + * @param \Drupal\Core\Form\FormStateInterface $form_state
    + *   The current state of the form.
      */
    -function gravitas_countdown_form_submit($form, FormStateInterface $form_state)
    -{
    +function gravitas_countdown_form_submit(array $form, FormStateInterface $form_state) {
    

    The short description is correct, except Drupal 8 and higher versions do not implement block_delete_form(). It is better to use the form ID, block_delete_form, already used from the module code.
    The longer description is not used for form submission handlers.
    Parameter descriptions are not given for form submission handlers.

     /**
    -* Implements theme_mymodule_thumb_upload theme callback.
    -*/
    -function theme_mymodule_thumb_upload($variables) {
    + * Implements theme_mymodule_thumb_upload theme callback.
    + *
    + * Renders the HTML output for the thumbnail upload element,
    + * including the image preview and additional widget data.
    + * 
    + * @param array $variables
    + *   An associative array
    + */
    +function theme_mymodule_thumb_upload(array $variables) {

    The correct documentation comment for a theme function is similar to the following one.

    /**
     * Returns HTML for a foo.
     *
     * @param array $variables
     *   An associative array containing:
     *   - foo: The foo object that is being formatted.
     *   - show_bar: TRUE to show the bar component, FALSE to omit it.
     *
     * @ingroup themeable
     */
    function theme_foo($variables) {
    

    The @ingroup line is optional.

    +    // $output .= theme('image_style',
    +    // array(
    +    //   'style_name' => 'thumbnail',
    +    //   'path' => file_load($element['fid']['#value'])->uri,
    +    //   'getsize' => FALSE
    +    // ));.

    Periods are not added to commented out code. phpcs does not parse comments to understand it is commented out code.

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

    coding-standard-fixes-10.patch. This patch was applied cleanly on 1.1.0. But, there were few dependency injection issues which were not handled.
    Please find updated patch with all changes.

  • Status changed to Needs work about 1 year ago
  • 🇮🇳India arpitk

    HI @bharath-kondeti the patch #13 it applied cleanly. No more phpcs errors/warnings are produced.
    I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,js . to test.

    Thanks!

  • Status changed to Needs review about 1 year ago
Production build 0.69.0 2024