To replicate goto module directory and run
phpcs --standard=DrupalPractice .

Output
FILE: ..../domain_301_redirect/src/Form/Domain301RedirectConfigForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
40 | WARNING | t() calls should be avoided in classes, use
| | dependency injection and $this->t() instead
88 | WARNING | Unused variable $config.
----------------------------------------------------------------------

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

surbz created an issue. See original summary.

surbz’s picture

Title: Running coder gives DrupalPractice issues » Running coder gives DrupalPractice warnings
surbz’s picture

StatusFileSize
new1.07 KB

Here is the patch to fix this

surbz’s picture

Status: Active » Needs review
msankhala’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that patch #3 applies cleanly on 8.x-1.x branch and it fixes this coding standard issue.

th_tushar’s picture

Status: Reviewed & tested by the community » Needs work

I also face below issues, when coder is executed on a module,

$ phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md --ignore=node_modules,bower_components,vendor .

FILE: ..._repos\drupal.org\domain_301_redirect\domain_301_redirect.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...1_redirect\src\EventSubscriber\DomainRedirectEventSubscriber.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...org\domain_301_redirect\src\Form\Domain301RedirectConfigForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 287ms; Memory: 4.75Mb
msankhala’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +Needs reroll

@th_tushar Have you run coder after applying the provided patch? Looks like you are using Window system and your editor is not configured correctly and that editor converted line ending character from "\n" to "\r\n" which is default line ending characters for Window OR you hit the Ctrl+s on the files you reported the issue and your editor replaced the line ending character from "\n" to "\r\n".

Patch applies cleanly. This is still RTBC.

msankhala’s picture

Issue tags: -Needs reroll
th_tushar’s picture

Status: Reviewed & tested by the community » Needs work

FYI, I haven't opened any of the module files in my editor. Just cloned the module and ran coder on the module, and this errors.

msankhala’s picture

In this case, the patch is much appreciated.

msankhala’s picture

@th_tushar I run the PHP code sniffer on fresh clone but I don't see any such error or warnings.

❯ Desktop git clone --branch 8.x-1.x https://git.drupal.org/project/domain_301_redirect.git
Cloning into 'domain_301_redirect'...
remote: Counting objects: 80, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 80 (delta 33), reused 0 (delta 0)
Unpacking objects: 100% (80/80), done.

❯ Desktop cd domain_301_redirect

❯ domain_301_redirect 8.x-1.x phpcs --standard=DrupalPractice .

FILE: ...top/domain_301_redirect/src/Form/Domain301RedirectConfigForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 40 | WARNING | t() calls should be avoided in classes, use
    |         | dependency injection and $this->t() instead
 88 | WARNING | Unused variable $config.
----------------------------------------------------------------------

Time: 58ms; Memory: 4Mb

❯ domain_301_redirect 8.x-1.x phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md --ignore=node_modules,bower_components,vendor .

No output on last command.

msankhala’s picture

Status: Needs work » Needs review
naveenvalecha’s picture

Title: Running coder gives DrupalPractice warnings » Drupal 9 ready
Category: Bug report » Task
Status: Needs review » Needs work
Issue tags: -coder, -best practices

Retitling the issue to cover the removal of deprecated code as well as part of same issue.

sheshsharma’s picture

StatusFileSize
new2.55 KB
new2.61 KB

Adding patch to make the module D9 compatible.
Tested it on D8.9.0 as well as D9, installs successfully after applying the attached patch.

devdesagar’s picture

Hi Team,

Patch#14 is working fine for me

devdesagar’s picture

Status: Needs work » Reviewed & tested by the community

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

pookmish’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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