Sort 'use' statements alphabetically and t() calls should be avoided in classes.

Created on 6 July 2023, almost 2 years ago
Updated 31 July 2024, 8 months ago

Problem/Motivation

FILE: /home/lenovo/druapl7to9/web/modules/contrib/link_class/src/Plugin/Field/FieldWidget/LinkClassFieldWidget.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------
  87 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
  88 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
  89 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
  90 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
 198 | ERROR   | [x] list(...) is forbidden, use [...] instead.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------


FILE: /home/lenovo/druapl7to9/web/modules/contrib/link_class/tests/src/Functional/LinkClassWidgetTest.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is
     |         |     Drupal\field\Entity\FieldStorageConfig.
  83 | ERROR   | [ ] Do not disable strict config schema checking in tests. Instead ensure your module properly declares its
     |         |     schema for configurations.
 217 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
 218 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
     |         |     $this->t() instead
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------

Time: 105ms; Memory: 12MB

Steps to reproduce

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

2.1

Component

Code

Created by

šŸ‡®šŸ‡³India roshni27

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 @roshni27
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update almost 2 years ago
    2 fail
  • @roshni27 opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • šŸ‡®šŸ‡³India roshni27

    I have solved all errors, Please review MR

  • Status changed to Needs work 8 months ago
  • Hi roshni27,

    I have reviewed the MR, it was applied successfully but it still threw 1 error. Please see below:

    link_class git:(master) āœ— curl https://git.drupalcode.org/project/link_class/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3773    0  3773    0     0  11377      0 --:--:-- --:--:-- --:--:-- 11902
    patching file src/Plugin/Field/FieldWidget/LinkClassFieldWidget.php
    patching file tests/src/Functional/LinkClassWidgetTest.php
    āžœ  link_class git:(master) āœ— cd ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig link_class
    
    FILE: ...eb/modules/contrib/link_class/tests/src/Functional/LinkClassWidgetTest.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     83 | ERROR | Do not disable strict config schema checking in tests. Instead
        |       | ensure your module properly declares its schema for
        |       | configurations.
    --------------------------------------------------------------------------------
    
    Time: 297ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

Production build 0.71.5 2024