Fix the issues reported by phpcs

Created on 28 June 2022, over 2 years ago
Updated 28 May 2024, 6 months ago

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml shows the following warnings/errors which should be fixed.


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\Deploy\DeployPluginBase.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 60 | ERROR | The trigger_error message 'The method \Drupal\preview_site\Deploy\DeployPluginInterface::deployFilePath is deprecated in Deploy plugins. It should be
    |       | implemented.' does not match the relaxed standard format: %thing% is deprecated in %deprecation-version% any free text %removal-version%. %extra-info%. See
    |       | %cr-link%
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\Generate\TomeStaticExtension.php
----------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------
 102 | WARNING | Possible useless method overriding detected
----------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\PreviewSiteBuilder.php
------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 76 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\tests\src\Kernel\TomeGeneratorEntityEmbedTest.php
-------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------------
 30 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
-------------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.76 secs; Memory: 14MB
๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Rakhi Soni

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 nayana_mvr

    Have tried to fix th Drupal coding standard issue except the following

    FILE: ../contrib/preview_site/src/PreviewSiteCache.php
    ---------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------
     22 | ERROR | Missing member variable doc comment
     23 | ERROR | Missing member variable doc comment
    ---------------------------------------------------------------------------------------------------------
    
    Time: 1.14 secs; Memory: 14MB

    I don't know how to fix the above error. If someone can guide me on this, I'll fix that also.

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

    Hi @nayana_mvr you can just give the one line comment to the variables, i'll just be fine then.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Ignore those, the properties are private and type hinted - docs are not needed

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia hardikpandya

    I have fixed a few more phpcs issues. Attached is the interdiff.

    I still see the below issue reported which I am not sure of how to fix.

    FILE: tests/src/Kernel/TomeGeneratorEntityEmbedTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     30 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mstrelan

    Now that ๐Ÿ“Œ Use Gitlab CI Fixed can we get an MR instead of patches and ensure the phpcs job comes back green?

  • First commit to issue fork.
  • bindu r โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India
  • Status changed to Needs work 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    If I run PHP_CodeSniffer for the 1.x branch, I get more warnings/errors than the issue summary.

  • First commit to issue fork.
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankithashetty Karnataka, India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    MR #23 applied cleanly.

    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/preview_site (1.x)
    $ curl https://git.drupalcode.org/project/preview_site/-/merge_requests/15.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11497    0 11497    0     0   3447      0 --:--:--  0:00:03 --:--:--  3449
    patching file modules/preview_site_s3/tests/src/Kernel/S3DeployPluginTest.php
    patching file preview_site.module
    patching file preview_site.post_update.php
    patching file src/Deploy/DeployPluginBase.php
    patching file src/EventSubscribers/AdditionalPathsEvent.php
    patching file src/EventSubscribers/TomeStaticListener.php
    patching file src/Generate/FileCollection.php
    patching file src/Generate/TomeStaticExtension.php
    patching file src/Plugin/views/field/ItemLinks.php
    patching file src/PreviewSiteBuilder.php
    patching file src/PreviewSiteCache.php
    patching file tests/src/Functional/PreviewStrategyAdministrationTest.php
    patching file tests/src/Kernel/PreviewSiteBuildEntityTest.php
    patching file tests/src/Kernel/PreviewSiteBuilderTest.php
    patching file tests/src/Traits/PreviewSiteTestTrait.php
    patching file tests/src/Unit/FileHelperTest.php
    

    Remaining errors

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml preview_site/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\preview_site\src\PreviewSiteBuilder.php
    --------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------
     77 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\preview_site\tests\src\Kernel\TomeGeneratorEntityEmbedTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     30 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 2.13 secs; Memory: 14MB
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shreyas gowda

    fixed all the phpcs issues one error and warning is left

    FILE: C:\wamp64\www\contribution\preview_site\src\Deploy\DeployPluginBase.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
    60 | ERROR | The trigger_error message 'The method
    | | \Drupal\preview_site\Deploy\DeployPluginInterface::deployFilePath
    | | is deprecated in Deploy plugins. It should be implemented.' does
    | | not match the relaxed standard format: %thing% is deprecated in
    | | %deprecation-version% any free text %removal-version%.
    | | %extra-info%. See %cr-link%
    --------------------------------------------------------------------------------

    FILE: ...\wamp64\www\contribution\preview_site\src\Generate\TomeStaticExtension.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
    102 | WARNING | Possible useless method overriding detected
    --------------------------------------------------------------------------------

  • Hi,
    Applied #26 patch, the patch does not apply cleanly and throws error.

    $ git apply -v phpcs_fix.patch
    Checking patch preview_site.post_update.php...
    error: while searching for:
    
    /**
     * @file
    <<<<<<< ours
     * Post update hooks for preview_site.
     */
    
    
    error: patch failed: preview_site.post_update.php:2
    error: preview_site.post_update.php: patch does not apply
    Checking patch src/Deploy/DeployPluginBase.php...
    error: while searching for:
        // We provide an implementation here to prevent breaking BC under the 1:1
        // rule. But in reality any plugin that doesn't implement this is probably
        // not going to work.
        @trigger_error('Deploy plugins are expected to implement \Drupal\preview_site\Deploy\DeployPluginInterface::deployFilePath', E_USER_DEPRECATED);
      }
    
    }
    
    error: patch failed: src/Deploy/DeployPluginBase.php:56
    error: src/Deploy/DeployPluginBase.php: patch does not apply
    Checking patch src/EventSubscribers/AdditionalPathsEvent.php...
    error: while searching for:
      public function __construct(
        protected PreviewSiteBuildInterface $build,
        protected array $paths = [],
      ) { }
    
      /**
       * Gets additional paths.
    
    error: patch failed: src/EventSubscribers/AdditionalPathsEvent.php:18
    error: src/EventSubscribers/AdditionalPathsEvent.php: patch does not apply
    Checking patch src/Generate/FileCollection.php...
    error: while searching for:
    class FileCollection implements \IteratorAggregate {
    
      /**
       * @var \Drupal\file\FileInterface[]
       */
      private $files = [];
    
    error: patch failed: src/Generate/FileCollection.php:10
    error: src/Generate/FileCollection.php: patch does not apply
    Checking patch src/Plugin/views/field/ItemLinks.php...
    error: while searching for:
    
      public const PLUGIN_ID = 'preview_site_item_links';
    
    
      /**
       * {@inheritdoc}
       */
    
    error: patch failed: src/Plugin/views/field/ItemLinks.php:20
    error: src/Plugin/views/field/ItemLinks.php: patch does not apply
    Checking patch src/PreviewSiteCache.php...
    error: while searching for:
     */
    final class PreviewSiteCache extends StaticCache {
    
      private StaticCacheInterface $inner;
      private RequestStack $requestStack;
    
      /**
    
    error: patch failed: src/PreviewSiteCache.php:19
    error: src/PreviewSiteCache.php: patch does not apply
    Checking patch tests/src/Kernel/PreviewSiteBuilderTest.php...
    error: while searching for:
          ],
          [[PreviewSiteBuilder::class, 'operationQueueGenerate'], [$build->id()]],
          [[PreviewSiteBuilder::class, 'operationProcessGenerate'], [$build->id()]],
          [[PreviewSiteBuilder::class, 'operationQueueAdditionalPaths'], [$build->id()]],
          [[PreviewSiteBuilder::class, 'operationProcessAssets'], [$build->id()]],
          [[PreviewSiteBuilder::class, 'operationQueueDeploy'], [$build->id()]],
          [[PreviewSiteBuilder::class, 'operationProcessDeploy'], [$build->id()]],
    
    error: patch failed: tests/src/Kernel/PreviewSiteBuilderTest.php:202
    error: tests/src/Kernel/PreviewSiteBuilderTest.php: patch does not apply
    Checking patch tests/src/Traits/PreviewSiteTestTrait.php...
    error: while searching for:
        ];
        $clean_batch = function (array $context) {
          return [
              'finished' => 1,
              'sandbox' => [],
            ] + $context;
        };
        PreviewSiteBuilder::operationMarkDeploymentStarted($build->id(), $context);
        PreviewSiteBuilder::operationQueueGenerate($build->id());
    
    error: patch failed: tests/src/Traits/PreviewSiteTestTrait.php:156
    error: tests/src/Traits/PreviewSiteTestTrait.php: patch does not apply
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    Patch #26 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/preview_site (1.x)
    $ curl https://www.drupal.org/files/issues/2024-02-15/phpcs_fix.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4975  100  4975    0     0  13096      0 --:--:-- --:--:-- --:--:-- 13161
    patching file preview_site.post_update.php
    patching file src/Deploy/DeployPluginBase.php
    patching file src/EventSubscribers/AdditionalPathsEvent.php
    patching file src/Generate/FileCollection.php
    patching file src/Plugin/views/field/ItemLinks.php
    patching file src/PreviewSiteCache.php
    patching file tests/src/Kernel/PreviewSiteBuilderTest.php
    patching file tests/src/Traits/PreviewSiteTestTrait.php
    

    Still issue remaining.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml preview_site/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\Deploy\DeployPluginBase.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     60 | ERROR | The trigger_error message 'The method \Drupal\preview_site\Deploy\DeployPluginInterface::deployFilePath is deprecated in Deploy plugins. It should be
        |       | implemented.' does not match the relaxed standard format: %thing% is deprecated in %deprecation-version% any free text %removal-version%. %extra-info%. See
        |       | %cr-link%
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\Generate\TomeStaticExtension.php
    ----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------
     102 | WARNING | Possible useless method overriding detected
    ----------------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\src\PreviewSiteBuilder.php
    ------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------
     76 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\preview_site\tests\src\Kernel\TomeGeneratorEntityEmbedTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     30 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 1.76 secs; Memory: 14MB
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Issue summary updated.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chaitanyadessai Goa

    Fixed remaining issues.

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines roberttabigue

    Hi guys!

    I have reviewed the changes and confirmed that Patch #30 was applied cleanly to the Preview Site module against 1.x-dev on Drupal 10.

    And all PHPCS errors have been fixed.

    I ran this command on the module:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml preview_site

    Please see the attached file for reference.

    I'm moving this now to โ€˜RTBCโ€™.

    Thank you!

Production build 0.71.5 2024