Fix the issues reported by phpcs

Created on 25 April 2023, about 1 year ago
Updated 8 February 2024, 5 months ago

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/export_content_xml_writer/

FILE: /var/www/html/contribution/web/modules/contrib/export_content_xml_writer/src/ExportXml.php
--------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 78 ERRORS AND 4 WARNINGS AFFECTING 50 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------
3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
4 | ERROR | [x] Doc comment short description must be on the first line
4 | ERROR | [x] Doc comment short description must start with a capital letter
6 | ERROR | [x] Additional blank lines found at end of doc comment
8 | ERROR | [x] There must be one blank line after the namespace declaration
8 | ERROR | [x] There must be exactly one space after the namepace keyword
11 | ERROR | [x] Missing class doc comment
13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
13 | ERROR | [ ] Missing member variable doc comment
15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
15 | ERROR | [x] Missing function doc comment
16 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
17 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
19 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
19 | ERROR | [x] Missing function doc comment
19 | ERROR | [x] Expected 1 space after FUNCTION keyword; 2 found
19 | ERROR | [x] Expected 1 space before opening brace; found 0
20 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
21 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
21 | ERROR | [x] Expected 1 space after "="; 2 found
22 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
23 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
24 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 11
25 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
26 | WARNING | [x] There must be no blank line following an inline comment
26 | WARNING | [ ] There must be no blank line following an inline comment
26 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
26 | ERROR | [x] No space found before comment text; expected "// return "Hello " . $type . "!";" but found "//return "Hello " . $type . "!";"
26 | ERROR | [x] Inline comments must start with a capital letter
26 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
28 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
28 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
29 | ERROR | [x] Object operator not indented correctly; expected 10 spaces but found 12
33 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
34 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
34 | WARNING | [ ] Node::loadMultiple calls should be avoided in classes, use dependency injection instead
36 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
37 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
37 | ERROR | [x] Inline comments must start with a capital letter
38 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
38 | ERROR | [x] Concat operator must be surrounded by a single space
38 | ERROR | [x] Concat operator must be surrounded by a single space
39 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
40 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
42 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
42 | ERROR | [x] No space found before comment text; expected "// Tag Articles" but found "//Tag Articles"
42 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
43 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
44 | ERROR | [x] Whitespace found at end of line
45 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
46 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
46 | ERROR | [x] No space found before comment text; expected "// Tag Article" but found "//Tag Article"
46 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
47 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
49 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
49 | ERROR | [x] No space found before comment text; expected "// tag ID" but found "//tag ID"
49 | ERROR | [x] Inline comments must start with a capital letter
49 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
50 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
51 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
52 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
54 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
54 | ERROR | [x] No space found before comment text; expected "// Tag Title" but found "//Tag Title"
54 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
55 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
56 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
57 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
59 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
60 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
61 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
63 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
65 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
66 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
66 | ERROR | [x] No space found before comment text; expected "// return 'test';" but found "//return 'test';"
66 | ERROR | [x] Inline comments must start with a capital letter
66 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
67 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
68 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
68 | ERROR | [x] Expected 1 blank line after function; 3 found
71 | ERROR | [ ] More than 2 empty lines are not allowed
72 | ERROR | [x] Expected 1 newline at end of file; 0 found
72 | ERROR | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 77 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/contribution/web/modules/contrib/export_content_xml_writer/export_content_xml_writer.info.yml
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-----------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/contribution/web/modules/contrib/export_content_xml_writer/export_content_xml_writer.services.yml
---------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
3 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India himanshu_jhaloya Mandsaur

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
  • Merge request !1fixed the phpcs issue → (Open) created by himanshu_jhaloya
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi himanshu_jhaloya

    I applied your MR !1 in my local with Drupal 9.5.8 to the "Export content xml writer" against version 1.0.x-dev, and PHPCS flagged the issue below

    FILE: /Users/studenttrainees/Projects/drupalorgissues/docroot/modules/contrib/export_content_xml_writer/export_content_xml_writer.info.yml
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------
    1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
    1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    ------------------------------------------------------------------------------------------------------------------------------------------

    Time: 182ms; Memory: 10MB

    Please look at the screenshot attached for your reference.

    Thanks

  • 🇮🇳India himanshu_jhaloya Mandsaur

    @clarkssquared add also the PHPCS flagged command.

  • 🇵🇭Philippines clarkssquared

    Hi himanshu_jhaloya

    The PHPCS command I used is:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml export_content_xml_writer

  • 🇮🇳India himanshu_jhaloya Mandsaur

    checkout the branch phpcs @clarkssquared

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    We do not use issue tags that are also the issue title. That is explained in the field description: Do NOT use tags for adding random keywords or duplicating any other fields.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * {@inheritDoc}
    + */

    {@inheritDoc} is not used for a class documentation comment.

    +  /**
    +   * Entity type manager service.
    +   *
    +   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
    +   */
    +  protected $entityTypeManager;
    +
    +  /**
    +   * Content of node.
    +   *
    +   * @var string
    +   */
    +  protected $content;

    The short descriptions are missing an article.

    +  /**
    +   * Constructs media integration plugin.
    +   *
    +   * @param array $configuration
    +   *   A configuration array containing information about the plugin instance.
    +   * @param string $plugin_id

    The short description needs to include class name and its namespace, not a description of the created object.

    +  /**
    +   * {@inheritdoc}
    +   */
    +  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    +    return new static(
    +      $configuration,
    +      $plugin_id,
    +      $plugin_definition,
    +      $container->get('entity_type.manager')
    +    );
    +  }

    A class without parent classes nor implementing interfaces cannot use {@inheritdoc}. That method is useless, if the plugin does not implement a specific interface.
    I would rather leave that out for a different issue, since that is a bug, not a matter of following the coding standards, though. A plugin class must at least implement an interface (in the simpler cases). This class does not implement any interface.

  • First commit to issue fork.
  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
Production build 0.69.0 2024