Fix the issues reported by phpcs

Created on 10 January 2023, almost 2 years ago
Updated 30 May 2024, 6 months ago

GitLab CI reports PHP_codeSniffer errors/warnings. The ones still to be fixed are the following ones.

FILE: .../custom/entity_usage-3332136/tests/src/Kernel/EntityUsageTrackFileTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is
   |       |     Drupal\Tests\file\Functional\FileFieldCreationTrait.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...b/modules/custom/entity_usage-3332136/tests/src/Kernel/EntityUsageTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Entity\EntityInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ntity_usage-3332136/tests/src/FunctionalJavascript/EmbeddedContentTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\file\Entity\File.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...32136/web/modules/custom/entity_usage-3332136/src/EntityUsageTrackBase.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first
    |         |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    |         |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
 17 | WARNING | [x] Unused use statement
    |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...b/modules/custom/entity_usage-3332136/src/EntityUsageQueueBatchManager.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...32136/web/modules/custom/entity_usage-3332136/src/EntityUsageInterface.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 197 | ERROR | The text '@deprecated in branch 2.x. Use
     |       | \Drupal\entity_usage\EntityUsageInterface::listSources()
     |       | instead.' does not match the standard format: @deprecated in
     |       | %deprecation-version% and is removed from %removal-version%.
     |       | %extra-info%. (Drupal.Commenting.Deprecated.IncorrectTextLayout)
 197 | ERROR | Each @deprecated tag must have a @see tag immediately following
     |       | it (Drupal.Commenting.Deprecated.DeprecatedMissingSeeTag)
 219 | ERROR | The text '@deprecated in branch 2.x. Use
     |       | \Drupal\entity_usage\EntityUsageInterface::listTargets()
     |       | instead.' does not match the standard format: @deprecated in
     |       | %deprecation-version% and is removed from %removal-version%.
     |       | %extra-info%. (Drupal.Commenting.Deprecated.IncorrectTextLayout)
 219 | ERROR | Each @deprecated tag must have a @see tag immediately following
     |       | it (Drupal.Commenting.Deprecated.DeprecatedMissingSeeTag)
--------------------------------------------------------------------------------
FILE: ...36/web/modules/custom/entity_usage-3332136/src/EntityUsageBatchManager.php
--------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 8 LINES
--------------------------------------------------------------------------------
   7 | ERROR | [x] Use statements should be sorted alphabetically. The first
     |       |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
     |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
  73 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1
     |       |     spaces
     |       |     (Drupal.Commenting.FunctionComment.ParamCommentIndentation)
  74 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1
     |       |     spaces
     |       |     (Drupal.Commenting.FunctionComment.ParamCommentIndentation)
  75 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1
     |       |     spaces
     |       |     (Drupal.Commenting.FunctionComment.ParamCommentIndentation)
  76 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1
     |       |     spaces
     |       |     (Drupal.Commenting.FunctionComment.ParamCommentIndentation)
  77 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1
     |       |     spaces
     |       |     (Drupal.Commenting.FunctionComment.ParamCommentIndentation)
 111 | ERROR | [ ] The array declaration extends to column 141 (the limit is
     |       |     120). The array content should be split up over multiple
     |       |     lines (Drupal.Arrays.Array.LongLineDeclaration)
 111 | ERROR | [ ] The array declaration extends to column 140 (the limit is
     |       |     120). The array content should be split up over multiple
     |       |     lines (Drupal.Arrays.Array.LongLineDeclaration)
 151 | ERROR | [x] Expected 1 space before "==="; 2 found
     |       |     (Squiz.WhiteSpace.OperatorSpacing.SpacingBefore)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ..._usage-3332136/web/modules/custom/entity_usage-3332136/src/EntityUsage.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\entity_usage\Events\EntityUsageEvent.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...custom/entity_usage-3332136/src/Plugin/EntityUsage/Track/LayoutBuilder.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 16 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Core\Path\PathValidatorInterface.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...32136/web/modules/custom/entity_usage-3332136/src/Form/BatchUpdateForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Form\FormBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...modules/custom/entity_usage-3332136/src/Controller/ListUsageController.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 16 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Core\Pager\PagerManagerInterface.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...b/modules/custom/entity_usage-3332136/src/Commands/EntityUsageCommands.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\entity_usage\EntityUsageBatchManager.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...32136/web/modules/custom/entity_usage-3332136/entity_usage.post_update.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Site\Settings.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 1.05 secs; Memory: 10MB

 
 

๐Ÿ“Œ Task
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sahil.goyal

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rishu_kumar

    When I try to apply #4 patch but not apply cleanly.
    See the attached screenshot.
    So, Need to work.

    Thanks

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Charchil Khandelwal โ†’ made their first commit to this issueโ€™s fork.

  • Assigned to Charchil Khandelwal
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Some of the warnings and errors are fixed now.
    Please review.

    Thank You.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
     /**
      * @file
    - * hook_post_update_NAME functions for entity_usage module.
    + * Hook_post_update_NAME functions for entity_usage module.
      */

    The short description for that file is Post update functions for the [module name] module.

     /**
    - * Implements hook_post_update_NAME().
    - * Re-generate entity_usage statistics.
    + * Implements hook_post_update_NAME() for Re-generate entity_usage statistics.
      */

    The correct comment for a hook_post_update_NAME() implementation is the line describing what that hook does. In this case, that is the Re-generate entity_usage statistics. comment.

        * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    -   * The config factory service.
    +   *   The config factory service.

    service is not necessary.

    -   * @return array<string, string>
    +   * @return arraystringstring
        *   An array of all embedded entities found, where keys are the uuids and the
        *   values are the entity types.

    arraystringstring is not a type listed in the Drupal coding standards.

    /**
    - * Class EntityUpdateManager.
    + * Entity Manager to update Entity.

    Actually, that class is an entity update manager.

    -   * @return array<string, \Drupal\entity_usage\EntityUsageTrackInterface>
    +   * @return arraystring\Drupal\entity_usage\EntityUsageTrackInterface
        *   The enabled plugin instances keyed by plugin ID.

    That is another type the Drupal coding standards do not list.

     /**
    - * Class EntityUpdateManagerInterface.
    + * The EntityUpdateManagerInterface class.
      *
      * @package Drupal\entity_usage

    A class short description must not repeat the class name.
    Also, either it is an interface or it is a class. It cannot be both.

    -   * @param 'revision'|'translation'|'default' $type
    +   * @param revision|translation|default $type

    The existing type-hinting says $type is a string.

    -        $operations[] = ['\Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker', [$entity_type_id]];
    +        $operations[] = ['\Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker', [
    +          $entity_type_id,
    +        ],
    +        ];

    Lines are allowed to be longer than 80 characters, if they are more readable. In this case, the existing code is more readable.

    -    $storage = $this->entityTypeManager->getStorage('entity_test_mulrevpub');
    +    // $storage = $this->entityTypeManager->getStorage('entity_test_mulrevpub');

    If a line needs to be removed, it is not commented-out.
    Anyway, why is that line commented out?

    +   * @param string $field_name
    +   *   The name of the field.

    The field name. is shorter.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12

    Preethy_ray โ†’ made their first commit to this issueโ€™s fork.

  • First commit to issue fork.
  • First commit to issue fork.
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    Attached patch to fix all the issues of phpcs.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    apaderno โ†’ changed the visibility of the branch 3332136-drupal-coding-standards to hidden.

  • Status changed to Needs work 7 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi silvi

    I applied your patch #17 and I can still see some PHPCS errors

    โžœ  entity_usage git:(642974e) curl https://www.drupal.org/files/issues/2024-04-24/3332136-entity-usage-17.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 36980  100 36980    0     0  65083      0 --:--:-- --:--:-- --:--:-- 66035
    patching file entity_usage.install
    patching file entity_usage.module
    patching file entity_usage.post_update.php
    patching file 'src/Commands/EntityUsageCommands.php'
    patching file 'src/Controller/ListUsageController.php'
    patching file 'src/EntityUpdateManager.php'
    patching file 'src/EntityUpdateManagerInterface.php'
    patching file 'src/EntityUsage.php'
    patching file 'src/EntityUsageBatchManager.php'
    patching file 'src/EntityUsageInterface.php'
    patching file 'src/EntityUsageQueueBatchManager.php'
    patching file 'src/EntityUsageTrackBase.php'
    patching file 'src/Form/BatchUpdateForm.php'
    patching file 'src/Form/EntityUsageSettingsForm.php'
    patching file 'src/Plugin/EntityUsage/Track/BlockField.php'
    patching file 'src/Plugin/EntityUsage/Track/CkeditorImage.php'
    patching file 'src/Plugin/EntityUsage/Track/EntityEmbed.php'
    patching file 'src/Plugin/EntityUsage/Track/LayoutBuilder.php'
    patching file 'src/Plugin/EntityUsage/Track/LinkIt.php'
    patching file 'src/Plugin/EntityUsage/Track/MediaEmbed.php'
    patching file 'src/Plugin/QueueWorker/EntityUsageRegenerateTrackingInfoWorker.php'
    patching file 'tests/modules/entity_usage_test/config/install/field.storage.node.field_eu_test_related_nodes.yml'
    patching file 'tests/modules/entity_usage_test/src/Plugin/Block/DependenciesBlock.php'
    patching file 'tests/src/FunctionalJavascript/EmbeddedContentTest.php'
    patching file 'tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php'
    patching file 'tests/src/FunctionalJavascript/IntegrationTest.php'
    patching file 'tests/src/Kernel/EntityUsageTest.php'
    patching file 'tests/src/Kernel/EntityUsageTrackFileTest.php'
    โžœ  entity_usage git:(642974e) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml entity_usage     
    
    FILE: ...bing/Projects/d9/d9-local/web/modules/contrib/entity_usage/tests/src/FunctionalJavascript/EmbeddedContentTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     431 | ERROR | The array declaration extends to column 111 (the limit is 80). The array content should be split up
         |       | over multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...ubing/Projects/d9/d9-local/web/modules/contrib/entity_usage/tests/src/Functional/EntityUsageLayoutBuilderTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------
     65 | ERROR | The array declaration extends to column 81 (the limit is 80). The array content should be split up over
        |       | multiple lines
     66 | ERROR | The array declaration extends to column 81 (the limit is 80). The array content should be split up over
        |       | multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...ers/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/entity_usage/src/Commands/EntityUsageCommands.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     80 | ERROR | The array declaration extends to column 113 (the limit is 80). The array content should be split up over
        |       | multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 2.35 secs; Memory: 16MB
    
    โžœ  contrib git:(master) โœ— 
    

    If possible, add your fixes in the existing Merge Request so that maintainers can test it conveniently.

  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    Hello,
    I looked into it and resolved the issue you brought up. kindly check this one if it is possible.

  • Pipeline finished with Failed
    6 months ago
    Total: 470s
    #185932
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
Production build 0.71.5 2024