Fix the issues reported by phpcs

Created on 20 April 2023, about 1 year ago
Updated 3 August 2023, 11 months ago

Problem/Motivation

FILE: ...drupal10/web/modules/contrib/random_frontpage/random_frontpage.routing.yml
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
7 | WARNING | The administration page callback should probably use "administer
| | site configuration" - which implies the user can change
| | something - rather than "access administration pages" which is
| | about viewing but not changing configurations.
--------------------------------------------------------------------------------

FILE: ...les/contrib/random_frontpage/src/Controller/random_frontpageController.php
--------------------------------------------------------------------------------
FOUND 47 ERRORS AND 5 WARNINGS AFFECTING 40 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank
| | line
2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin
| | with a file doc comment
8 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
17 | WARNING | [x] Unused use statement
20 | ERROR | [x] Doc comment short description must end with a full stop
21 | ERROR | [x] There must be exactly one blank line before the tags in a
| | doc comment
23 | WARNING | [ ] The class short comment should describe what the class
| | does and not simply repeat the class name
23 | ERROR | [x] Additional blank lines found at end of doc comment
24 | ERROR | [ ] Class name must begin with a capital letter
24 | ERROR | [ ] Class name must use UpperCamel naming without underscores
29 | ERROR | [x] Data types in @var tags need to be fully namespaced
29 | ERROR | [x] Do not append variable name "$config" to the type
| | declaration in a member variable comment
33 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
36 | ERROR | [x] Data types in @var tags need to be fully namespaced
36 | ERROR | [x] Do not append variable name "$renderer" to the type
| | declaration in a member variable comment
43 | ERROR | [x] Data types in @var tags need to be fully namespaced
43 | ERROR | [x] Do not append variable name "$killSwitch" to the type
| | declaration in a member variable comment
50 | ERROR | [x] Data types in @var tags need to be fully namespaced
50 | ERROR | [x] Do not append variable name "$entityTypeManager" to the
| | type declaration in a member variable comment
52 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 3
54 | ERROR | [ ] Missing short description in doc comment
55 | ERROR | [ ] Missing parameter comment
55 | ERROR | [x] Data types in @param tags need to be fully namespaced
56 | ERROR | [ ] Missing parameter comment
56 | ERROR | [x] Data types in @param tags need to be fully namespaced
57 | ERROR | [ ] Missing parameter comment
57 | ERROR | [x] Data types in @param tags need to be fully namespaced
58 | ERROR | [ ] Missing parameter comment
58 | ERROR | [x] Data types in @param tags need to be fully namespaced
60 | ERROR | [x] Additional blank lines found at end of doc comment
72 | ERROR | [ ] Missing short description in doc comment
73 | ERROR | [ ] Missing parameter comment
73 | ERROR | [x] Data types in @param tags need to be fully namespaced
74 | ERROR | [ ] Description for the @return value is missing
75 | ERROR | [x] Data types in @throws tags need to be fully namespaced
76 | ERROR | [x] Data types in @throws tags need to be fully namespaced
78 | ERROR | [x] Additional blank lines found at end of doc comment
91 | ERROR | [ ] Description for the @return value is missing
92 | ERROR | [x] Separate the @return and @throws sections by a blank line.
92 | ERROR | [x] Data types in @throws tags need to be fully namespaced
93 | ERROR | [x] Data types in @throws tags need to be fully namespaced
95 | ERROR | [x] Additional blank lines found at end of doc comment
102 | ERROR | [x] Short array syntax must be used to define arrays
110 | ERROR | [x] Expected newline after closing brace
118 | ERROR | [x] Short array syntax must be used to define arrays
119 | ERROR | [x] Expected newline after closing brace
120 | ERROR | [ ] Concatenating translatable strings is not allowed, use
| | placeholders instead and only one string literal
121 | ERROR | [x] Short array syntax must be used to define arrays
125 | ERROR | [x] Expected 1 blank line after function; 0 found
126 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 39 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...web/modules/contrib/random_frontpage/src/Form/random_frontpageSettings.php
--------------------------------------------------------------------------------
FOUND 45 ERRORS AFFECTING 33 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin
| | with a file doc comment
12 | ERROR | [x] When importing a class with "use", do not include a leading
| | \
14 | ERROR | [x] Missing class doc comment
14 | ERROR | [ ] Class name must begin with a capital letter
14 | ERROR | [ ] Class name must use UpperCamel naming without underscores
26 | ERROR | [x] Data types in @var tags need to be fully namespaced
26 | ERROR | [x] Do not append variable name "$configFactory" to the type
| | declaration in a member variable comment
30 | ERROR | [ ] Missing short description in doc comment
31 | ERROR | [x] Data types in @var tags need to be fully namespaced
31 | ERROR | [x] Do not append variable name "$entityDisplayRepository" to
| | the type declaration in a member variable comment
33 | ERROR | [x] Additional blank lines found at end of doc comment
39 | ERROR | [ ] Missing parameter comment
39 | ERROR | [x] Data types in @param tags need to be fully namespaced
40 | ERROR | [ ] Missing parameter comment
40 | ERROR | [x] Data types in @param tags need to be fully namespaced
42 | ERROR | [x] Additional blank lines found at end of doc comment
53 | ERROR | [ ] Missing parameter comment
53 | ERROR | [x] Data types in @param tags need to be fully namespaced
54 | ERROR | [x] Separate the @param and @return sections by a blank line.
54 | ERROR | [ ] Description for the @return value is missing
54 | ERROR | [x] Data types in @return tags need to be fully namespaced
56 | ERROR | [x] Additional blank lines found at end of doc comment
67 | ERROR | [ ] Description for the @return value is missing
69 | ERROR | [x] Additional blank lines found at end of doc comment
74 | ERROR | [ ] Missing short description in doc comment
75 | ERROR | [ ] Description for the @return value is missing
77 | ERROR | [x] Additional blank lines found at end of doc comment
81 | ERROR | [x] Array closing indentation error, expected 4 spaces but found
| | 6
87 | ERROR | [ ] Description for the @return value is missing
89 | ERROR | [x] Additional blank lines found at end of doc comment
102 | ERROR | [ ] Missing parameter comment
103 | ERROR | [ ] Missing parameter comment
103 | ERROR | [x] Data types in @param tags need to be fully namespaced
104 | ERROR | [x] Separate the @param and @return sections by a blank line.
104 | ERROR | [ ] Description for the @return value is missing
106 | ERROR | [x] Additional blank lines found at end of doc comment
109 | ERROR | [x] Short array syntax must be used to define arrays
116 | ERROR | [x] Array closing indentation error, expected 4 spaces but found
| | 6
118 | ERROR | [x] Short array syntax must be used to define arrays
125 | ERROR | [x] Array closing indentation error, expected 4 spaces but found
| | 6
132 | ERROR | [ ] Missing parameter comment
133 | ERROR | [ ] Missing parameter comment
133 | ERROR | [x] Data types in @param tags need to be fully namespaced
135 | ERROR | [x] Additional blank lines found at end of doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 29 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...on/drupal10/web/modules/contrib/random_frontpage/random_frontpage.info.yml
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
1 | WARNING | [ ] Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
6 | ERROR | [x] Expected 1 newline at end of file; 2 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...tion/drupal10/web/modules/contrib/random_frontpage/random_frontpage.module
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
5 | ERROR | [x] Expected 1 newline at end of file; 2 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 373ms; 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 random_frontpage/

Proposed resolution

Fix all the issues reported for Drupal and DrupalPractice standards

Remaining tasks

Patch review.

📌 Task
Status

Closed: works as designed

Version

2.0

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
  • Status changed to Needs work about 1 year ago
  • 🇮🇳India Shiv_Sharma

    I have reviewed the patch seems you deleted some files you need to fix it

  • 🇺🇸United States earlyburg

    I think it is resolved now. Thank you for helping, I appreciate it.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Yes, the patch removed files instead of renaming them. Also, the files, even when renamed, should still be changed to fix the coding standards.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇺🇸United States earlyburg

    Hi thank you for helping out. Feel free to submit a merge request once you have fixed the issues you feel exist.
    Thanks!

  • 🇮🇳India Shiv_Sharma

    @earlybug please apply the latest patch.

  • 🇺🇸United States earlyburg

    There is a discrepancy on line 24 of the patch were it says -
    - _permission: 'administer site configuration'
    + _permission: 'access administration pages'

    I'm keeping the access checks as-is to keep it more fine grained in a scenario where there are admins with various permission levels on a system. For instance an admin should have access to all admin pages but not settings that can affect specific settings.

    I think it would be easy to just create a custom permission setting for this module like "access random frontpage settings" and this would be the best route.

    Also it looks like although in this patch we remove the old controller under the old nomenclature, we don't replace it with a new file. :)

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    A custom permission is fine too, as long as the route does not use the access administration pages, which is only for accessing administration pages, not change any setting.

    Yes, it is quite confusing that Drupal uses that permission, which should not be used to allow changing settings. I guess it should only be used on routes like /admin/reports/dblog (but that route uses a custom permission, access site reports).

  • 🇺🇸United States earlyburg

    @apaderno
    The permissions issue has been resolved with the latest release found here:
    https://www.drupal.org/project/random_frontpage/releases/2.0.0-beta7

  • 🇮🇳India Shiv_Sharma

    We have to change the filename as per Drupal stranded.
    below as some issue on PHPCS.

    FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/random_frontpage/src/Controller/random_frontpageController.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 5 LINES
    ----------------------------------------------------------------------------------------------------------------------------------
     17 | ERROR | Class name must begin with a capital letter
     17 | ERROR | Class name must use UpperCamel naming without underscores
     70 | ERROR | Missing short description in doc comment
     71 | ERROR | Missing parameter comment
     72 | ERROR | Description for the @return value is missing
     88 | ERROR | Description for the @return value is missing
    
    FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/random_frontpage/src/Form/random_frontpageSettings.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------------------------------------
      11 | ERROR | Doc comment is empty
      14 | ERROR | Class name must begin with a capital letter
      14 | ERROR | Class name must use UpperCamel naming without underscores
      30 | ERROR | Missing short description in doc comment
     111 | ERROR | Description for the @return value is missing
    
    FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/random_frontpage/random_frontpage.module
    ------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------
     3 | ERROR | Missing short description in doc comment
    ------------------------------------------------------------------------------------------------------------
    
  • 🇺🇸United States earlyburg

    @Shiv_Sharma - patch file does not contain updates from the latest release, so I can't use them.
    Naming conventions do not affect performance.
    I will perform more updates soon.
    I appreciate it.

  • 🇺🇸United States earlyburg

    These issues are addressed in the latest release found here:
    https://www.drupal.org/project/random_frontpage/releases/2.0.0-beta8
    Please verify and thank you for your help, I appreciate it.

  • Status changed to RTBC about 1 year ago
  • 🇮🇳India Shiv_Sharma

    No new issue reported by PHPCS, we are good with this version.(attached screenshot)
    also tested the module functionality working as expected.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Closed: works as designed 11 months ago
Production build 0.69.0 2024