Problem/Motivation

PHPCS Drupal coding standard issue

Steps to reproduce

Run the command and you can see the coding standard errors and warnings:
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml

FILE: ...odules/contrib/media_fotoweb/src/Plugin/media/Source/Fotoweb.php
----------------------------------------------------------------------
FOUND 16 ERRORS AND 1 WARNING AFFECTING 17 LINES
----------------------------------------------------------------------
167 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
216 | ERROR | [x] Object operator not indented correctly; expected
| | 8 spaces but found 10
262 | WARNING | [x] 'TODO: Find out if it is an updated version.'
| | should match the format '@todo Fix problem X
| | here.'
341 | ERROR | [x] Inline control structures are not allowed
343 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 10
344 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 10
345 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 10
346 | ERROR | [x] Line indented incorrectly; expected 10 spaces,
| | found 12
347 | ERROR | [x] Line indented incorrectly; expected 12 spaces,
| | found 14
348 | ERROR | [x] Case breaking statements must be followed by a
| | single blank line
349 | ERROR | [x] Line indented incorrectly; expected 10 spaces,
| | found 12
350 | ERROR | [x] Line indented incorrectly; expected 12 spaces,
| | found 14
351 | ERROR | [x] Case breaking statements must be followed by a
| | single blank line
352 | ERROR | [x] Line indented incorrectly; expected 10 spaces,
| | found 12
353 | ERROR | [x] Line indented incorrectly; expected 12 spaces,
| | found 14
355 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 10
356 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 10
----------------------------------------------------------------------
PHPCBF CAN FIX THE 17 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...dia_fotoweb/src/Plugin/EntityBrowser/Widget/FotowebSelection.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...contrib/media_fotoweb/src/Plugin/ImageFetcher/RenditionImage.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
43 | ERROR | [x] There must not be a newline before the closing
| | parenthesis of a single-line function declaration
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: /app/web/modules/contrib/media_fotoweb/src/FotowebClient.php
----------------------------------------------------------------------
FOUND 4 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------
12 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
60 | ERROR | [x] Newline required after opening brace
60 | ERROR | [x] There should be no white space after an opening
| | "{"
60 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
67 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
95 | ERROR | [ ] Parameter $configuration is not described in
| | comment
98 | ERROR | [ ] Doc comment for parameter $configuratiton does
| | not match actual variable name $configuration
172 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: .../web/modules/contrib/media_fotoweb/src/ImageFetcherInterface.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
15 | ERROR | Description for the @return value is missing
----------------------------------------------------------------------

FILE: ...ontrib/media_fotoweb/src/Controller/AuthenticationController.php
----------------------------------------------------------------------
FOUND 6 ERRORS AND 5 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------
9 | WARNING | [x] Unused use statement
13 | ERROR | [x] Missing class doc comment
27 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
32 | ERROR | [x] Expected 1 space after closing parenthesis;
| | found 2
40 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
76 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
92 | ERROR | [ ] The array declaration extends to column 108 (the
| | limit is 80). The array content should be split
| | up over multiple lines
101 | ERROR | [x] Separate the @return and @throws sections by a
| | blank line.
114 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
135 | ERROR | [x] Separate the @return and @throws sections by a
| | blank line.
153 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
| | "TRUE" but found "true"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...dules/contrib/media_fotoweb/src/FotowebLoginManagerInterface.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
9 | WARNING | The class short comment should describe what the class
| | does and not simply repeat the class name
----------------------------------------------------------------------

FILE: ...app/web/modules/contrib/media_fotoweb/src/FotowebWidgetTrait.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
107 | ERROR | [x] Expected 1 space between type hint and argument
| | "$form_state"; 3 found
116 | WARNING | [ ] Unused variable $plugin.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...ib/media_fotoweb/src/OAuth2/Persistence/UserTokenPersistence.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
51 | ERROR | [x] Expected 1 blank line after function; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...b/modules/contrib/media_fotoweb/src/Form/FotowebSettingsForm.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
14 | WARNING | [x] Unused use statement
144 | ERROR | [ ] The array declaration extends to column 427 (the
| | limit is 80). The array content should be split
| | up over multiple lines
336 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
363 | ERROR | [ ] If there is no return value for a function,
| | there must not be a @return tag.
363 | ERROR | [ ] Description for the @return value is missing
367 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...eb/modules/contrib/media_fotoweb/src/Form/FotowebBrowserForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
153 | WARNING | [x] A comma should follow the last multiline array
| | item. Found: ]
157 | ERROR | [x] Expected 1 blank line after function; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...dules/contrib/media_fotoweb/src/MediaFotowebLibraryUiBuilder.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
32 | ERROR | [x] Expected
| | "\Drupal\media_library\OpenerResolverInterface|null"
| | but found
| | "\Drupal\media_library\OpenerResolverInterface|NULL"
| | for parameter type
35 | WARNING | [ ] Possible useless method overriding detected
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...pp/web/modules/contrib/media_fotoweb/src/FotowebLoginManager.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
13 | WARNING | The class short comment should describe what the
| | class does and not simply repeat the class name
----------------------------------------------------------------------

FILE: /app/web/modules/contrib/media_fotoweb/media_fotoweb.install
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
28 | ERROR | [x] Expected 1 blank line after function; 3 found
31 | ERROR | [ ] More than 2 empty lines are not allowed
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...contrib/media_fotoweb/tests/src/Unit/FotowebLoginManagerTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
10 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 428ms; Memory: 12MB

Proposed resolution

To solve the phpcs coding standard errors and warnings.

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

akshaydalvi212 created an issue. See original summary.

akshaydalvi212’s picture

Assigned: Unassigned » akshaydalvi212

Hello,

I will provide a patch to solve these coding standard errors and warnings.

Thanks and regards.

akshaydalvi212’s picture

Assigned: akshaydalvi212 » Unassigned
Status: Active » Needs review
StatusFileSize
new25.52 KB

Hello,

providing the patch to eliminated the above mentioned drupal coding standard errors and warnings.
kindly review it and provide your feedback.

Thanks and regards.

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

dipesh_goswami’s picture

Assigned: Unassigned » dipesh_goswami

Hi @akshaydalvi212,
I am reviewing your patch.

dipesh_goswami’s picture

Assigned: dipesh_goswami » Unassigned
Status: Needs review » Needs work

Hi @akshaydalvi212,

Your patch applied cleanly.
Most of the errors are resolved.

Some errors left(shown below):

$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig media_fotoweb-3295808/

FILE: ...rupal\web\modules\contrib\media_fotoweb-3295808\src\FotowebWidgetTrait.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 116 | WARNING | Unused variable $plugin.
--------------------------------------------------------------------------------


FILE: ...modules\contrib\media_fotoweb-3295808\src\MediaFotowebLibraryUiBuilder.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
 35 | WARNING | Possible useless method overriding detected
--------------------------------------------------------------------------------

Time: 652ms; Memory: 12MB

So, moving it to needs work.

akshaydalvi212’s picture

Status: Needs work » Needs review

Hey @dipesh_goswami,

Thanks for the review.
as you had mentioned some of the errors above, these warnings are managed by the module maintainers.
if we make changes in the code for these warnings can affect the functionality and working of the module.

I guess we need another review for this issue and then confirm whether to shift the issue to Reviewed and tested by the community.
Hence right now shifting the issue status to needs review at the moment.

Thanks and regards.

szeidler’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch and review. I looks good. For #6 only the first one is relevant. The second change would create a bug. I integrated the first suggestion into the commit.

szeidler’s picture

Status: Reviewed & tested by the community » Fixed

  • szeidler committed 9c507d5 on 2.0.x
    Issue #3295808 by szeidler: Fix bugs introduced in coding standard fixes
    

  • szeidler committed 92d799e on 2.0.x
    Issue #3295808 by szeidler: Fix bugs introduced in coding standard fixes
    

Status: Fixed » Closed (fixed)

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