Fix the errors/warnings reported by PHP_CodeSniffer

Created on 7 February 2023, almost 2 years ago
Updated 23 January 2024, 10 months ago

Running shows the following errors/warnings, which should be fixed.

FILE: ./README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | WARNING | Line exceeds 80 characters; contains 88 characters
----------------------------------------------------------------------

FILE: ./src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
  72 | 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
 151 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 152 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: .src/Plugin/Field/FieldWidget/BootstrapHorizontalTabs.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------
 30 | ERROR   | [x] Use null coalesce operator instead of ternary
    |         |     operator.
 38 | ERROR   | [x] Use null coalesce operator instead of ternary
    |         |     operator.
 64 | WARNING | [ ] t() calls should be avoided in classes, use
    |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
    |         |     and $this->t() instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ./tests/src/Functional/FieldTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Drupal\Tests\BrowserTestBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 153ms; Memory: 6MB
📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India himanshu_jhaloya Indore

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

  • Issue created by @himanshu_jhaloya
  • @himanshu_jhaloya opened merge request.
  • Status changed to Needs review almost 2 years ago
  • @himanshu_jhaloya opened merge request.
  • 🇺🇸United States mmarler

    Thanks for testing this @himanshu_jhaloya! Can you please check against the 2.x branch instead 2.0? Some of these issues have been fixed in the 2.x branch.

  • Assigned to paraderojether
  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines paraderojether

    Hi @mmarler,

    I checked 2.x branch and here are the issues reported by phpcs shown below:

    FILE: /Users/studenttrainees/Drupal.org/drupalorg-site/docroot/modules/contrib/bootstrap_horizontal_tabs/README.md
    ------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------
     8 | WARNING | Line exceeds 80 characters; contains 88 characters
    ------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal.org/drupalorg-site/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldWidget/BootstrapHorizontalTabs.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
     30 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     38 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
     64 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal.org/drupalorg-site/docroot/modules/contrib/bootstrap_horizontal_tabs/src/Plugin/Field/FieldFormatter/BootstrapHorizontalTabs.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
      72 | 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
     148 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
     149 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 362ms; Memory: 10MB

    I will work this on this.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    2 fail
  • 🇵🇭Philippines paraderojether

    Created a patch to fix the issues reported by phpcs.

    Please review.
    Thank You.

  • Status changed to Needs work 11 months ago
  • 🇮🇳India zkhan.aamir

    Hi,

    The patch #7 applied cleanly.
    All the errors are resolved.
    Please check screenshot.

  • Status changed to Needs review 10 months ago
  • Status changed to Needs work 10 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

    The report must also be updated for the 2.x branch. In fact, the bootstrap_horizontal_tabs.info.yml file cannot those warnings.

    name: 'Bootstrap Horizontal Tabs'
    description: 'Provides a custom field type displayed as horizontal tabs'
    type: module
    core_version_requirement: ^8 || ^9 || ^10
    dependencies:
      - drupal:field
      - drupal:text
    package: Field
    core_incompatible: false
    
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The patch changes less files than it should.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    apaderno → changed the visibility of the branch 3339850-14 to hidden.

  • Merge request !11Resolve #3339850 → (Merged) created by apaderno
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    1 pass
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    apaderno → changed the visibility of the branch 3339850-phpcs to hidden.

  • Status changed to Needs review 10 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    apaderno → changed the visibility of the branch 3339850-drupal-coding-standards to hidden.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    1 pass
  • Status changed to Fixed 10 months ago
  • 🇺🇸United States mark_fullmer Tucson
  • 🇺🇸United States mark_fullmer Tucson

    Thanks for the code cleanup, folks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024