Fix PHPCS (code standard) erros

Created on 11 April 2018, over 6 years ago
Updated 11 January 2024, 11 months ago
FILE: ...modules/contrib/crop/tests/src/Functional/CropFunctionalTest.php
----------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------
  73 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
  86 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
 102 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
 111 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
 138 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...core/D8/modules/contrib/crop/tests/src/Kernel/CropEffectTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 91 | ERROR | Inline doc block comments are not allowed; use "/*
    |       | Comment */" or "// Comment" instead
----------------------------------------------------------------------


FILE: ...CIT/emartoni/Projetos/DCO/core/D8/modules/contrib/crop/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 1 | WARNING | Line exceeds 80 characters; contains 91 characters
 3 | WARNING | Line exceeds 80 characters; contains 112 characters
----------------------------------------------------------------------


FILE: ...ni/Projetos/DCO/core/D8/modules/contrib/crop/src/Entity/Crop.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 157 | ERROR | [x] Object operator not indented correctly; expected 6
     |       |     spaces but found 8
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...re/D8/modules/contrib/crop/src/Annotation/CropEntityProvider.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 21 | ERROR | Class property $entity_type should use lowerCamel
    |       | naming without underscores
----------------------------------------------------------------------


FILE: ...T/emartoni/Projetos/DCO/core/D8/modules/contrib/crop/crop.module
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 12 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
๐Ÿ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ทBrazil emartoni

Live updates comments and jobs are added and updated live.
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.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

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

  • Issue was unassigned.
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    I create MR.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • Pipeline finished with Failed
    11 months ago
    Total: 171s
    #75453
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Hide patch files.

  • Pipeline finished with Success
    11 months ago
    Total: 149s
    #75463
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • Pipeline finished with Success
    11 months ago
    Total: 202s
    #75525
  • Pipeline finished with Success
    11 months ago
    Total: 142s
    #75531
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    Re-roll the patch according to the latest code changes.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    Tried to apply the patch #16 on Drupal version 10.4.x and Crop AP module version 8.x-2.x but getting the following error:-

    Checking patch crop.module...
    error: while searching for:
     *
     * Provides storage and API for image crops.
     */
    use Drupal\Component\Utility\UrlHelper;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\crop\Entity\Crop;
    use Drupal\image\Entity\ImageStyle;
    use Drupal\media\Entity\MediaType;
    use Drupal\media\MediaTypeInterface;
    use Drupal\media_entity\MediaBundleInterface;
    use Drupal\file\FileInterface;
    use Drupal\Core\Routing\RouteMatchInterface;
    
    /**
     * Implements hook_theme().
    
    error: patch failed: crop.module:6
    error: crop.module: patch does not apply
    Checking patch src/CropTypeListBuilder.php...
    error: while searching for:
    
    namespace Drupal\crop;
    
    use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
    use Drupal\Core\Entity\Query\QueryFactory;
    use Drupal\Core\Entity\EntityTypeInterface;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Drupal\Core\Entity\EntityStorageInterface;
    use Drupal\Core\Routing\UrlGeneratorInterface;
    use Drupal\Core\Entity\EntityInterface;
    use Drupal\Component\Utility\Xss;
    use Drupal\image\Entity\ImageStyle;
    
    /**
     * Defines a class to build a listing of crop type entities.
    
    error: patch failed: src/CropTypeListBuilder.php:2
    error: src/CropTypeListBuilder.php: patch does not apply
    Checking patch src/Entity/Crop.php...
    Hunk #1 succeeded at 121 (offset 8 lines).
    error: while searching for:
        }
    
        if (isset($effects['crop_crop']) && $image_style->getEffects()
            ->has($effects['crop_crop']['uuid'])) {
          $type = $image_style->getEffect($effects['crop_crop']['uuid'])
            ->getConfiguration()['data']['crop_type'];
          $crop = self::findCrop($uri, $type);
    
    error: patch failed: src/Entity/Crop.php:154
    error: src/Entity/Crop.php: patch does not apply
    Checking patch src/Form/CropTypeDeleteForm.php...
    error: while searching for:
    use Drupal\Core\Entity\EntityConfirmFormBase;
    use Drupal\Core\Entity\Query\QueryFactory;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\StringTranslation\TranslationInterface;
    use Drupal\Core\Url;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    
    error: patch failed: src/Form/CropTypeDeleteForm.php:5
    error: src/Form/CropTypeDeleteForm.php: patch does not apply
    Checking patch src/Plugin/ImageEffect/CropEffect.php...
    Hunk #2 succeeded at 30 (offset 4 lines).
    error: while searching for:
    
        $form['crop_type'] = [
          '#type' => 'select',
          '#title' => t('Crop type'),
          '#default_value' => $this->configuration['crop_type'],
          '#options' => $options,
          '#description' => t('Crop type to be used for the image style.'),
        ];
    
        return $form;
    
    error: patch failed: src/Plugin/ImageEffect/CropEffect.php:140
    error: src/Plugin/ImageEffect/CropEffect.php: patch does not apply
    Checking patch tests/src/Functional/CropFunctionalTest.php...
    error: while searching for:
      protected function setUp() {
        parent::setUp();
    
        $this->adminUser = $this->drupalCreateUser(['administer crop types', 'administer image styles']);
    
        // Create test image style.
        $this->testStyle = $this->container->get('entity_type.manager')->getStorage('image_style')->create([
    
    error: patch failed: tests/src/Functional/CropFunctionalTest.php:49
    error: tests/src/Functional/CropFunctionalTest.php: patch does not apply
    Checking patch tests/src/Functional/UpdatePathTest.php...
    error: tests/src/Functional/UpdatePathTest.php: No such file or directory
    Checking patch tests/src/Kernel/CropCRUDTest.php...
    Checking patch tests/src/Kernel/CropEffectTest.php...
    error: while searching for:
        $crop = $this->container->get('entity_type.manager')->getStorage('crop')->create($values);
        $crop->save();
    
        /** @var $effect \Drupal\crop\Plugin\ImageEffect\CropEffect */
        $effect = $this->imageEffectManager->createInstance('crop_crop', ['data' => ['crop_type' => $this->cropType->id()]]);
        $effect->transformDimensions($dimensions, $file_uri);
    
        $this->assertEquals($crop->size(), $dimensions, t('CropEffect::transformDimensions() transform image dimensions correctly.'));
      }
    
    }
    
    error: patch failed: tests/src/Kernel/CropEffectTest.php:88
    error: tests/src/Kernel/CropEffectTest.php: patch does not apply
  • Merge request !13#2960098: Fix phpcs errors. โ†’ (Open) created by Unnamed author
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    apaderno โ†’ changed the visibility of the branch 2960098-fix-phpcs-code to hidden.

  • Pipeline finished with Failed
    4 months ago
    Total: 142s
    #222595
  • Pipeline finished with Success
    4 months ago
    Total: 222s
    #222602
  • Status changed to Needs work 4 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines roberttabigue

    Hi,

    I am moving this to 'Needs work', please check the PHPCS issues below after applying the 'MR !14' to the CROP API module against 8.x-2.x-dev on my D10 local.

    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/tests/src/Functional/CropFunctionalTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      84 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      85 | 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
     101 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     109 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     110 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     122 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     123 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     142 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     147 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     148 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     152 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     153 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/tests/src/Kernel/CropCRUDTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 16 WARNINGS AFFECTING 16 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      68 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      69 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      70 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      75 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      76 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      77 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     103 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     104 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     105 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     106 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     109 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     110 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     111 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     112 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     113 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     114 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/tests/src/Kernel/CropEffectTest.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
     95 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/src/Form/CropTypeDeleteForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------
     46 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     60 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/src/CropTypeListBuilder.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      71 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     112 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     131 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/crop/src/Entity/Crop.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------
     124 | WARNING | Exceptions should not be translated
     124 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 365ms; Memory: 12MB

    Please check.
    Thank you!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev2.addweb

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

  • Pipeline finished with Failed
    4 months ago
    Total: 137s
    #227578
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev2.addweb

    @roberttabigue,
    There is two MR, MR !13 for phpcs and MR !14 for gitlab pipe line,
    Please test now I have merge this two MR code in MR !13.

  • Pipeline finished with Success
    4 months ago
    Total: 138s
    #227699
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev2.addweb

    Hi,
    I have fixed the PHPStan issues, and now the PHPStan job, along with all other jobs, has passed successfully. Please review the changes.

    before --> https://git.drupalcode.org/issue/crop-2960098/-/pipelines/227578
    after --> https://git.drupalcode.org/issue/crop-2960098/-/pipelines/227699

  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia riddhi.addweb

    I have applied the MR !13 and it resolves all the errors and tested module functionality with the image crop widget and focal point crop.
    Please check the Screenshot for the same.

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

    apaderno โ†’ changed the visibility of the branch 2960098-gitlab-ci-reports to hidden.

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

    This issue is only for fixing PHP_CodeSniffer reports, not all the GitLab CI reports.

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines ambot112

    The Merge request !13 is great, it solves all the phpcs and phstan errors.

  • Pipeline finished with Failed
    1 day ago
    Total: 147s
    #344525
  • Pipeline finished with Success
    1 day ago
    Total: 262s
    #344532
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Actually, it seems the PHP_CodeSniffer errors/warnings have been already fixed.

    Yes @avpaderno, you are right. Right now there are no issues found by CI.

    I found that a lot of changes that were implement at MR #6 were merged at ๐Ÿ› a Drupal 11 dev line is needed for CROP API. RTBC .
    CI checks code using only Drupal rules set and DrupalPractice is ignored.
    My suggestion to add DrupalPractice as well, using custom phpcs.xml.dist.

    I update IS using check on latest 8.x-2.x-dev.
    MR #6 is ready for review.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    nikolay shapovalov โ†’ changed the visibility of the branch 2960098-fix-phpcs-code to active.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    nikolay shapovalov โ†’ changed the visibility of the branch 2960098-fix-phpcs-errors to hidden.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • Pipeline finished with Success
    1 day ago
    Total: 149s
    #344544
Production build 0.71.5 2024