Problem/Motivation

Fix the coding standard issues for 2.0.x branch

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 addtoany/

Remaining tasks

Fix all the issues:
FILE: ...tml/contribution/drupal8/web/modules/contrib/addtoany/js/addtoany.admin.js
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
5 | ERROR | [x] Functions must not contain multiple empty lines in a row;
| | found 2 empty lines
14 | ERROR | [x] Functions must not contain multiple empty lines in a row;
| | found 2 empty lines
28 | ERROR | [x] Functions must not contain multiple empty lines in a row;
| | found 2 empty lines
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...www/html/contribution/drupal8/web/modules/contrib/addtoany/addtoany.module
--------------------------------------------------------------------------------
FOUND 22 ERRORS AND 3 WARNINGS AFFECTING 19 LINES
--------------------------------------------------------------------------------
18 | ERROR | [x] Function comment short description must start with exactly
| | one space
20 | ERROR | [x] Expected 1 space before opening brace; found 0
21 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
22 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
23 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
24 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
25 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
27 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
28 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
29 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
29 | WARNING | [ ] Avoid backslash escaping in translatable strings when
| | possible, use "" quotes instead
30 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
31 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
32 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
32 | WARNING | [ ] Translatable strings must not begin or end with white
| | spaces, use placeholders with t() for variables
32 | WARNING | [ ] Avoid backslash escaping in translatable strings when
| | possible, use "" quotes instead
32 | ERROR | [x] Concat operator must be surrounded by a single space
33 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
34 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
35 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
38 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
38 | ERROR | [x] Closing brace indented incorrectly; expected 0 spaces,
| | found 1
38 | ERROR | [x] Expected 1 blank line after function; 2 found
193 | ERROR | [ ] String concat is not required here; use a single string
| | instead
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 21 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...on/drupal8/web/modules/contrib/addtoany/src/Plugin/Block/AddToAnyBlock.php
--------------------------------------------------------------------------------
FOUND 6 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
--------------------------------------------------------------------------------
22 | ERROR | [ ] Missing @var tag in member variable comment
23 | ERROR | [ ] Class property $addtoany_option_keys should use lowerCamel
| | naming without underscores
35 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
37 | WARNING | [ ] Node::load calls should be avoided in classes, use
| | dependency injection instead
40 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but
| | found "true"
40 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE"
| | but found "false"
63 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
88 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 9
89 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 9
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: .../web/modules/contrib/addtoany/src/Plugin/views/field/NodeAddToAnyShare.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
17 | ERROR | Missing short description in doc comment
24 | ERROR | Missing short description in doc comment
--------------------------------------------------------------------------------

FILE: ...ion/drupal8/web/modules/contrib/addtoany/src/Form/AddToAnySettingsForm.php
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 7 WARNINGS AFFECTING 12 LINES
--------------------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
52 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2
| | spaces
238 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
251 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
261 | WARNING | [ ] Line exceeds 80 characters; contains 98 characters
263 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
263 | WARNING | [ ] Only string literals should be passed to t() where
| | possible
277 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
304 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
317 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
317 | ERROR | [ ] Description for the @return value is missing
322 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
330 | ERROR | [x] Expected 1 blank line after function; 0 found
331 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...ww/html/contribution/drupal8/web/modules/contrib/addtoany/addtoany.api.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
14 | ERROR | Type hint "array" missing for $types
--------------------------------------------------------------------------------

Time: 1.19 secs; Memory: 12MB

Issue fork addtoany-3350785

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

urvashi_vora created an issue. See original summary.

urvashi_vora’s picture

Assigned: urvashi_vora » Unassigned
Status: Needs work » Needs review
avpaderno’s picture

Title: Fix issues reported by PHPCS » Fix the issues reported by phpcs
Issue tags: -Phpcs Drupal coding standard issue +Coding standards
avpaderno’s picture

Priority: Normal » Minor
Status: Needs review » Needs work

The short description for a class constructor needs to include the class name and its namespace.

The storage handler class for nodes. can be shortened to The node storage handler class.

urvashi_vora’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Needs work
    * @return array
+   *   Returns array

It should describe what is returned, not the value's type, since that is already clear from the previous line.

+  /**
+   * Constructs a AddToAnyBlock object.
+   *

The class namespace is missing.

-    $is_node = isset($node) && $node instanceof NodeInterface ? true : false;
+    $is_node = isset($node) && $node instanceof NodeInterface ? TRUE : FALSE;

Since that line is changed, then it should be also shortened. isset($node) && $node instanceof NodeInterface already returns a Boolean value.

kkalashnikov made their first commit to this issue’s fork.

kunalgautam’s picture

Status: Needs work » Needs review

  • VladimirAus committed 42477a11 on 8.x-1.x
    Issue #3350785 by urvashi_vora, kkalashnikov, apaderno, VladimirAus: Fix...
vladimiraus’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!
Applying to the latest branches.

  • VladimirAus committed 85ad0748 on 2.0.x
    Issue #3350785 by urvashi_vora, kkalashnikov, apaderno, VladimirAus: Fix...
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

All committed. Cheers 🍻

  • micropat committed 224213ea on 8.x-1.x
    Revert commits back to stable 72de926c
    
    Revert 42477a11 Issue #3350785....

  • micropat committed 49b63afa on 2.0.x
    Revert commits back to stable c0d33537
    
    Revert 85ad0748 Issue #3350785....

  • micropat committed 8aca6cff on 8.x-1.x
    Issue #3350785: Fix code style issues via phpcs
    Remove unused...

  • micropat committed 3f44067f on 2.0.x
    Issue #3350785: Fix code style issues via phpcs
    Remove unused...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.