Fix the issues reported by phpcs

Created on 23 May 2023, about 1 year ago
Updated 11 February 2024, 5 months ago

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

FILE: tests/src/FunctionalJavascript/ComplexWidgetTest.php
-----------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-------------------------------
 680 | ERROR | [x] Data types in @var tags need to be fully namespaced
 680 | ERROR | [x] Data types in @var tags need to be fully namespaced
-------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------


FILE: inline_entity_form.module
---------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------
 18 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\inline_entity_form\Form\EntityInlineForm.
---------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------


FILE: src/Form/EntityInlineForm.php
-------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityFieldManagerInterface.
-------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------


FILE: src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
-----------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
-----------------------
  309 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
  312 | ERROR   | [x] Array indentation error, expected 6 spaces but found 8
  313 | ERROR   | [x] Array indentation error, expected 6 spaces but found 8
  314 | ERROR   | [x] Array closing indentation error, expected 4 spaces but found 6
  328 | ERROR   | [x] Expected newline after closing brace
  495 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 1005 | WARNING | [ ] Line exceeds 80 characters; contains 86 characters
-----------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------


FILE: src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
--------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------
 471 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 472 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------


FILE: src/MigrationHelper.php
--------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------
  93 | ERROR   | [ ] unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
 155 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 167 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
--------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------

Time: 3.58 secs; Memory: 16MB


PHP CODE SNIFFER REPORT SUMMARY
-----------------------------------
FILE                                                      ERRORS  WARNINGS
-----------------------------------
inline_entity_form.module                                    1       0
src/MigrationHelper.php                                      2       1
src/Form/EntityInlineForm.php                                1       0
src/Plugin/Field/FieldWidget/InlineEntityFormBase.php        0       2
src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php     5       2
tests/src/FunctionalJavascript/ComplexWidgetTest.php         2       0
-----------------------------------
A TOTAL OF 11 ERRORS AND 5 WARNINGS WERE FOUND IN 6 FILES
-----------------------------------
PHPCBF CAN FIX 10 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------
๐Ÿ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
        * @param \Drupal\Core\Form\FormStateInterface $form_state
        *   The current state of the form.
    -   * 
    +   *
        * @return Drupal\Core\Entity\EntityInterface\null
    +   *   The entity handler.

    Since that comment is changed, also @return Drupal\Core\Entity\EntityInterface\null. I take that should be @return Drupal\Core\Entity\EntityInterface|null.
    The description is not correct: What reported is an entity, not an entity handler. It should also describe when NULL is returned.

       /**
    +   * Retrieves the labels for the entity type.
    +   *
        * @return array|\Drupal\Core\Entity\EntityTypeInterface
    +   *   Array containing the singular and plural labels
        */

    What returned is not just an array. The description does not say when a \Drupal\Core\Entity\EntityTypeInterface instance is returned.

    -          \Drupal::moduleHandler()->invokeAll('inline_entity_form_entity_save', [&$form_state, $entity, $is_new]);
    +          \Drupal::moduleHandler()->invokeAll('inline_entity_form_entity_save',
    +          [&$form_state, $entity, $is_new]);

    The last line must be indented.
    I would rather leave the code as it is, since code lines are allowed to exceed 80 characters.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

    Will update the patch soon.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

    Updated the patch with suggested changes, please review.

  • Status changed to Fixed about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine podarok Ukraine

    #4 is in
    tnx

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

  • Status changed to Active 7 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

    Bulk reopen.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Prem Suthar gujrat

    Solved the all Phpcs error coming from 3.x version.
    i use the cmd to show the error is : - ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/inline_entity_form
    attached the patch file plz review ..

  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Prem Suthar gujrat
  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    I was able to apply patch.

    +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
    @@ -73,13 +80,16 @@ abstract class InlineEntityFormBase extends WidgetBase implements ContainerFacto
    +  public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, ContentTranslationManagerInterface $content_translation_manager) {
    

    Module hasn't dependency on content_translation module.
    I think it's impossible to use it in method params if module is disabled.

    +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
    @@ -19,6 +20,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
    +  protected $contentTranslationManager;
    

    Please add empty line below.

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

    Since the branch has been changed, the issue summary probably needs to be updated. It is probable PHP_CodeSniffer's report will have different warnings/errors.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • Merge request !101Resolve #3362087 "Fix the issues" โ†’ (Merged) created by zniki.ru
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    https://www.drupal.org/project/inline_entity_form/issues/3135178#comment... โ†’

    I think we are not going to fix \Drupal call with DI in InlineEntityFormBase.php
    Reasons is the same as it was at comment โ†’ .
    I mute phpcs for this violation.

    I create MR from patch #9 with small changes.
    Please make a review.

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    @apaderno thanks a lot for your feedback.
    I provide my response, can you please provide more arguments?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Anjali Mehta

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

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

    Unresolved review notes, so NW.

  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Fix all violations, revert back to sprintf(). Ready for review.

  • Pipeline finished with Success
    6 months ago
    #73628
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dcam

    Just a heads-up: This patch and the PHPStan issue are modifying the same lines in InlineEntityFormBase. One of the MRs will have to be rebased manually after the other gets committed.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

    > Ready for review.
    I have no time currently. But there are unresolved notes still.

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

    But there are unresolved notes still.

    I double checked issue and MR, and I was not able to find unresolved notes.
    I was not able to rebase MR with giltab UI, I made rebase manually.

  • Pipeline finished with Success
    6 months ago
    Total: 529s
    #75179
  • Pipeline finished with Success
    6 months ago
    #75180
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    I made change to MR, because module migration_plus is not obligatory.

  • Pipeline finished with Success
    6 months ago
    Total: 457s
    #75185
  • Status changed to RTBC 5 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States dww

    I've reviewed the changes in the MR. They all look good to me. I agree that silencing the one "violation" about migrate_plus and using the fully namespaced class is a good choice (the only unresolved MR thread). The phpcs job is passing in the MR pipeline, e.g.: https://git.drupalcode.org/issue/inline_entity_form-3362087/-/jobs/608770

    It'd be nice to merge this ASAP so that we can start relying on the GitLab CI pipelines to ensure that new changes don't introduce phpcs regressions.

    RTBC!

    Thanks,
    -Derek

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany

    Thx Derek for the review!

  • Pipeline finished with Skipped
    5 months ago
    #83798
  • Status changed to Fixed 5 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany geek-merlin Freiburg, Germany
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024