Fix the issues reported by phpcs

Created on 22 February 2023, almost 2 years ago
Updated 31 May 2024, 7 months ago
šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India samit.310@gmail.com

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 @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • šŸ‡®šŸ‡³India samit.310@gmail.com

    Above error/warnings are fixed.

  • šŸ‡®šŸ‡³India Ranjit1032002

    I had Reviewed the patch and it's working as expected mentioned in comment #2

  • Status changed to RTBC almost 2 years ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs work almost 2 years ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +/**
    + * The AdvancedTitleBlockForm Class.
    + */
     class AdvancedTitleBlockForm extends ConfigFormBase {
    

    A documentation comment for a class should not just repeat the class name. (Class is not correct, since it is not a the beginning of a sentence.)

    -    // @toDo validate and clean up submissions
    +    // @todo validate and clean up submissions
       }

    What follows @todo is a sentence.

  • Assigned to vishaljd
  • @vishaljd opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    -    // @toDo validate and clean up submissions
    +    // '@toDo validate and clean up submissions'

    Putting that part in quote characters is wrong.

    +   * @param \Drupal\Core\File\FileUrlGenerator $url_generator
    +   *   File url generator.

    The article is missing and url is not spelled correctly.

    -      '#title' => t('Default background image'),
    -      '#open' => TRUE, // Controls the HTML5 'open' attribute. Defaults to FALSE.
    +      '#title' => $this->t('Default background image'),
    +      '#open' => TRUE, /* Controls the HTML5 'open' attribute. Defaults to FALSE. */

    The comment delimiters are already correct. I am not sure that comment is necessary, though.

    +  /**
    +   * Get field from field_storage_config.
    +   */
    

    Parameters and return value are still not documented.

  • First commit to issue fork.
  • @kkalashnikov opened merge request.
  • Status changed to Needs review almost 2 years ago
  • šŸ‡®šŸ‡³India kkalashnikov Ghaziabad, India
  • Status changed to Needs work almost 2 years ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +  /**
    +   * File url generator object.

    Acronyms are written all uppercase. object is not used in the description of properties. The article is missing.

    +  /**
    +   * The Messenger service.
    +   *
    +   * @var Drupal\Core\Logger\LoggerChannelFactory
    +   */
    +  protected $loggerFactory;

    It is not the messenger service.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function getFields($type, $entity = 'node') {

    For a method that is not inherited nor defined in an interface, that comment cannot be used.

  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India kkalashnikov Ghaziabad, India
  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +/**
    + * Provides a advanced title block form.
    + */

    The used article is wrong.

       public function validateForm(array &$form, FormStateInterface $form_state) {
    -    // @toDo validate and clean up submissions
    +
       }

    Since that is a @todo tag for an empty method, it is correct to leave it, but it needs to be fixed: It is @todo, not @toDo; what follows @todo is a sentence.

    +  /**
    +   * The File URL generator service.
    +   *
    +   * @var \Drupal\Core\File\FileUrlGenerator
    +   */
    +  protected $fileUrlGenerator;

    File is not spelled correctly, since it is not the first word of a sentence.

    +  /**
    +   * The Logger service.
    +   *
    +   * @var Drupal\Core\Logger\LoggerChannelFactory
    +   */
    +  protected $loggerFactory;
    +

    The same is true for Logger. Then, that is the logger factory service.

       /**
        * Constructs a new AdvancedTitleBlock.
        *
    @@ -82,14 +104,23 @@ class AdvancedTitleBlock extends BlockBase implements ContainerFactoryPluginInte
        *   The route match.
        * @param \Drupal\Core\Config\ImmutableConfig $config
        *   The configuration object.
    +   * @param \Drupal\Core\File\FileUrlGenerator $fileUrlGenerator
    +   *   File url generator object.
    +   * @param \Drupal\Core\File\FileSystem $fileSystem
    +   *   The fileSystem service.
    +   * @param \Drupal\Core\Logger\LoggerChannelFactory $logger_factory
    +   *   The Messenger service.
        */

    There is a missing article.
    Then, since that documentation comment is changed, the class name must include its namespace.

    -      \Drupal::logger('Advanced Title Block')->error('Failed uploading background image');
    +      $this->loggerFactory->get('Advanced Title Block')->error('Failed uploading background image');

    It is correct to avoid \Drupal, but instead of calling $this->loggerFactory->get('Advanced Title Block') every time the logger is necessary, it is sufficient to store the logger into a class property, instead of storing the logger factory.

    +  /**
    +   * Get field names.
    +   *
    +   * @param array|string $type
    +   *   The field type.
    +   * @param string $entity
    +   *   The entity type.
    +   */

    The return value is not documented.
    The short description can be made better.

  • Status changed to Needs review over 1 year ago
  • šŸ‡ŖšŸ‡ŖEstonia rang501 Viljandi

    Took some time and made multiple fixes. Should address last comment and additionally adds cache tags (block didn't update when entity was updated).

    There were also issues like file upload validators were in wrong format, LoggerChannelFactory in construct was throwing fatals errors (due to redirect module, should use interface instead).

  • šŸ‡ŖšŸ‡ŖEstonia rang501 Viljandi

    Updated patch with latest release

  • Status changed to Needs work 7 months ago
  • Hi @rang501,

    I applied your patch #19, some files of the patch did not apply successfully which may be the reason it still threw the errors below.

    advanced_title_block git:(1.0.x) curl https://www.drupal.org/files/issues/2023-09-19/3343584-fixes-19.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 14299  100 14299    0     0  42087      0 --:--:-- --:--:-- --:--:-- 43330
    patching file README.md
    patching file advanced_title_block.menu.yml
    patching file advanced_title_block.routing.yml
    patching file config/schema/advanced_title_block.schema.yml
    patching file css/advanced-title-block.css
    patching file src/Form/AdvancedTitleBlockForm.php
    patching file src/Plugin/Block/AdvancedTitleBlock.php
    Hunk #6 FAILED at 196.
    Hunk #9 FAILED at 259.
    2 out of 16 hunks FAILED -- saving rejects to file src/Plugin/Block/AdvancedTitleBlock.php.rej
    āžœ  advanced_title_block git:(1.0.x) āœ— cd ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig advanced_title_block
    
    FILE: /Users/PrometInterns/Demo-site/drupal-orgissue/web/modules/contrib/advanced_title_block/src/Plugin/Block/AdvancedTitleBlock.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AND 4 WARNINGS AFFECTING 8 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
       7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Block\BlockBase.
     199 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     200 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
     200 | ERROR   | [x] Comments may not appear after statements
     204 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
     211 | ERROR   | [x] Comma not allowed after last value in single-line array declaration
     211 | ERROR   | [x] Expected one space after the comma, 0 found
     261 | ERROR   | [x] Whitespace found at end of line
     268 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
     364 | ERROR   | [x] Data types in @var tags need to be fully namespaced
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 243ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

  • Pipeline finished with Success
    7 months ago
    Total: 173s
    #187155
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch phpcs-3343584 to hidden.

  • Status changed to Needs review 7 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch coding_standard to hidden.

  • Pipeline finished with Success
    7 months ago
    Total: 149s
    #187423
Production build 0.71.5 2024