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
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

Rakhi Soni created an issue. See original summary.

rakhi soni’s picture

Assigned: rakhi soni » Unassigned
Status: Active » Needs review
StatusFileSize
new8.13 KB

I have created a patch to fix the issue of "Drupal Coding Standard",, please review.
Thanks & Regards
Rakhi Soni,,

Status: Needs review » Needs work

The last submitted patch, 2: drupal_coding_standard_fixes-3293092-2.patch, failed testing. View results

urvashi_vora’s picture

Assigned: Unassigned » urvashi_vora

Hi, I am working on this.

urvashi_vora’s picture

Assigned: urvashi_vora » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.85 KB

Hi,

Please review this patch.

Thanks

Status: Needs review » Needs work

The last submitted patch, 5: coding-standard-fix-3293092-5.patch, failed testing. View results

larowlan’s picture

Couple of test fails here, thanks

rakhi soni’s picture

Status: Needs work » Needs review
StatusFileSize
new9.08 KB

I have tried to fix this drupal coding standard issue once again ,, kindly review patch.

nayana_mvr’s picture

Issue tags: -
StatusFileSize
new9.24 KB

I have fixed the 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.

sahil.goyal’s picture

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

larowlan’s picture

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

hardikpandya’s picture

StatusFileSize
new11.9 KB
new2.66 KB

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.
-------------------------------------------------------------------------------------------------------------------------------------------------
avpaderno’s picture

Title: Drupal Coding Standard Fixes As per 'phpcs --standard=Drupal' » Fix the issues reported by phpcs
Issue tags: +Coding standards
mstrelan’s picture

Status: Needs review » Needs work

Now that #3391807: Use Gitlab CI is in can we get an MR instead of patches and ensure the phpcs job comes back green?

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

bindu r made their first commit to this issue’s fork.

urvashi_vora’s picture

Status: Needs work » Needs review
avpaderno’s picture

Priority: Normal » Minor
Status: Needs review » Needs work
avpaderno’s picture

Issue summary: View changes
Issue tags: +Needs reroll

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

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

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

ankithashetty’s picture

Issue tags: -Needs reroll
zkhan.aamir’s picture

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
Shreyas gowda’s picture

StatusFileSize
new4.86 KB

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
--------------------------------------------------------------------------------

shruu_rao’s picture

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
zkhan.aamir’s picture

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
zkhan.aamir’s picture

Issue summary: View changes

Issue summary updated.

chaitanyadessai’s picture

Status: Needs work » Needs review
StatusFileSize
new11.86 KB

Fixed remaining issues.

roberttabigue’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new42.95 KB

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!