Fix the issues reported by phpcs

Created on 13 April 2023, over 1 year ago
Updated 14 August 2024, 4 months ago
📌 Task
Status

RTBC

Version

1.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
  • 🇵🇭Philippines kenyoOwen

    Hi urvashi_vora

    I applied the patch coding-standard-fixes.patch to the “Scaleflex Cloudimage” module against Version 1.0.x-dev and there is still remaining issue. I will transition this to needs work so others can fix the remaining issue. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sakthi_dev

    Resolved the issue. Please review.

  • Status changed to RTBC over 1 year ago
  • 🇵🇭Philippines kenyoOwen

    Hi sakthi_dev

    I applied the patch #3 to the “Scaleflex Cloudimage” module against Version 1.0.x-dev and confirmed that it fixed the remaining issue. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * @file
    + * Module File.
    + */

    The usual short description is Hook implementations for the [module name] module.

    +/**
    + * Cloud Image Service.
    + */
     class CloudimageService {
    

    An article is missing from the short description.
    Image and Service are misspelled, since they are not at the beginning of the sentence.

    +  /**
    +   * Router for get the base url.
    +   *
    +   * @var \Drupal\Core\Routing\RequestContext

    url is misspelled.
    That class is not a router.

    -      $message = "{ \n" . "status".":"."success".",\n"."count_added".":". count($images) ."\n }";
    +      $message = "{ \n" . "status" . ":" . "success" . ",\n" . "count_added" . ":" . count($images) . "\n }";
           $this->logger->notice($message);

    Strings passed as first argument to logger methods must use placeholders, not be a concatenation of strings.

     /**
    - * Class CloudimageForm.
    + * Cloud image Form.
      *
      * @package Drupal\scaleflex_cloudimage\Form
      */
     class CloudimageForm extends ConfigFormBase {

    The short description must not contain the class name.
    Form is misspelled.

    +  /**
    +   * {@inheritdoc}
    +   */
       private $cloudimageConfig;

    {@inheritdoc} is not used for properties that are not inherited from the parent class or defined from an interface.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function __construct(ConfigFactoryInterface $config_factory) {

    It is not even used for class constructors.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India pray_12

    Fixed the issues reported by phpcs.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * @file
    + * Adds CloudImage source to image variables if the route is not node edit form.
    + */

    The usual description for a .module file is Hook implementations for the [module name] module. where [module name] is the name of the module given in its .info.yml file.

     /**
      * Implements hook_page_attachments().
      */
    +
    +/**
    + * Adds CloudImage-related attachments to the page.
    + */
     function scaleflex_cloudimage_page_attachments(array &$attachments) {

    Each function/method must have only a single documentation comment. The existing one is already correct.

    -function scaleflex_cloudimage_preprocess_html(array &$variables){
    +
    +/**
    + * Adds CloudImage attributes to HTML variables for specific pages.
    + */
    +function scaleflex_cloudimage_preprocess_html(array &$variables) {

    That is not the correct documentation comment for a preprocess hook. It should be similar to Implements hook_preprocess_HOOK() for image.html.twig.

    +/**
    + * Provides methods to interact with the Cloudimage service.
    + *
    + * This class encapsulates functionality related to Cloudimage services,
    + * allowing interaction with Cloudimage APIs and related operations.
    + */

    The long description is not necessary.

    + /**
    + * Constructs a new CloudimageService object.
    + *
    + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    + * The configuration factory service.
    + * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger
    + * The logger channel factory service.
    + * @param \Drupal\Core\File\FileSystemInterface $file_system
    + * The file system service.
    + * @param \GuzzleHttp\ClientInterface $http_client
    + * The Guzzle HTTP client.
    + * @param \Drupal\Core\Routing\RouterInterface $router
    + * The router service.
    + */

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.

    -      $response = $client->post('https://warmup.api.cloudimage.com/warmup/urls', [
    +      // $response = new Response();
    +      // $client = new Client();
    +      $response = $this->httpClient->post('https://warmup.api.cloudimage.com/warmup/urls', [
             'headers' => [
               'X-Client-Key' => $config->get('client_key'),

    Code that is not necessary is removed, not commented out.

    +  /**
    +   * Represents the Cloudimage configuration.
    +   *
    +   * @var \Drupal\Core\Config\ImmutableConfig
    +   */
       private $cloudimageConfig;

    The config object. is sufficient.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India sakthi_dev

    Addressed the comment #8. Please review.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +/**
    + * @file
    + * Hook implementations for the Scaleflex Cloudimage.
    + */
    Hook implementations for the Scaleflex Cloudimage module.
     /**
      * Implements hook_page_attachments().
    + *
    + * Adds CloudImage-related attachments to the page.
      */
     function scaleflex_cloudimage_page_attachments(array &$attachments) {

    The longer description essentially says what the short description already says; it is not necessary.

    +/**
    + * Implements hook_preprocess_html().
    + */
    +function scaleflex_cloudimage_preprocess_html(array &$variables) {

    The short description must be Implements hook_preprocess_HOOK() for [template filename].

     /**
      * Implements hook_cron().
      */
    +
    +/**
    + * Perform CloudImage-related tasks during cron runs.
    + */
     function scaleflex_cloudimage_cron() {

    Each function/method must have a single documentation comment. This patch is adding a new documentation comment to a function which has already a documentation comment.

    +  /**
    +   * The Cloudimage settings.
    +   *
    +   * @var \Drupal\Core\Config\ImmutableConfig
    +   */
    +  protected $cloudimageSettings;

    The config object. is sufficient.

    +  /**
    +   * Constructs a new class instance.
    +   *
    +   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    +   *   The configuration factory service.
    +   */
    

    The documentation comment for constructors is not mandatory anymore, If it is given, the description must be Constructs a new [class name] object. where [class name] includes the class namespace.
    That holds true for every class constructors.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Addressing comment #10. Providing updated patch.

  • Merge request !1#3353886: MR for the changes. → (Open) created by nitin_lama
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India nitin_lama India

    Please review.

  • Issue was unassigned.
  • Hi, Reviewed the patch #12, applied cleanly and fixes all errors. And addresses the comments #10.
    Thank you!

  • Status changed to RTBC 4 months ago
  • Hi @nitin_lama,

    Applied the partch you provided, confirmed it fixed the reported issues and confirmed it addresses the comment #10.

    scaleflex_cloudimage git:(1.0.x) curl https://www.drupal.org/files/issues/2023-12-14/phpcs-fix-3353886-12.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11689  100 11689    0     0  36282      0 --:--:-- --:--:-- --:--:-- 38074
    patching file css/cloudimage.css
    patching file js/cloudimage.js
    patching file scaleflex_cloudimage.info.yml
    patching file scaleflex_cloudimage.libraries.yml
    patching file scaleflex_cloudimage.links.menu.yml
    patching file scaleflex_cloudimage.module
    patching file scaleflex_cloudimage.services.yml
    patching file src/CloudimageService.php
    patching file src/Form/CloudimageForm.php
    ➜  scaleflex_cloudimage git:(1.0.x) ✗ ..
    ➜  contrib git:(main) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig scaleflex_cloudimage
    ➜  contrib git:(main) ✗

    Will now move this to RTBC

    Thanks,
    Jake

  • Pipeline finished with Success
    4 months ago
    Total: 139s
    #254189
  • Pipeline finished with Success
    4 months ago
    Total: 242s
    #254190
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    avpaderno changed the visibility of the branch 3353886-gitlab-ci-reports to hidden.

Production build 0.71.5 2024