Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Munavijayalakshmi created an issue. See original summary.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned
Status: Active » Needs review
FileSize
7.56 KB
Matroskeen’s picture

Title: Convert module to use short array syntax (new coding standard) » Coding standards and deprecated usages
FileSize
36.88 KB

I think that all coding standards can be fixed at once. There are no reasons to create issues for each error type.

Here is a patch. Tests were passed locally.

vdenis’s picture

Tested provided patch from @Matroskeen and looks good.

vdenis’s picture

Status: Needs review » Reviewed & tested by the community
Manuel Garcia’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#3042635: Drupal 9 Deprecated Code Report, +#3029285: Use short array syntax

Thanks for the patch!

There's already a patch for short array syntax (see related issues), let's omit that from this patch.
Let's tackle deprecated code usage on the other related issue.

Let's only tackle coding standards here so it's easier to review / commit :)

+++ b/html_to_text.inc
@@ -47,16 +50,16 @@ function mailsystem_wrap_mail($text, array $options = array()) {
-  $options['wrap'] = $options['max'] - drupal_strlen($options['indent']);
+  $options['wrap'] = $options['max'] - Unicode::strlen($options['indent']);
...
-    $options['pad_repeat'] = drupal_substr($options['pad'], -1, 1);
+    $options['pad_repeat'] = Unicode::substr($options['pad'], -1, 1);

@@ -409,33 +414,34 @@ function _mailsystem_html_to_text(DOMNode $node, array $allowed_tags, array &$no
-      $child_text .= _mailsystem_html_to_text($child, $allowed_tags, $notes, $line_length - drupal_strlen($indent), $parents, $child_count);    }
+      $child_text .= _mailsystem_html_to_text($child, $allowed_tags, $notes, $line_length - Unicode::strlen($indent), $parents, $child_count);
...
-      $child_text = drupal_strtoupper($child_text);
+      $child_text = Unicode::strtoupper($child_text);
...
-    if ($suffix === $eol && drupal_substr($child_text, - drupal_strlen($eol)) === $eol) {
+    if ($suffix === $eol && Unicode::str($child_text, -Unicode::strlen($eol)) === $eol) {

@@ -718,7 +726,7 @@ function _mailsystem_indent_mail_line(&$line, $key, $values) {
-    $count = $values['max'] - drupal_strlen($line) - drupal_strlen($values['pad']);
+    $count = $values['max'] - Unicode::strlen($line) - Unicode::strlen($values['pad']);

Unicode methods are deprecated. See https://www.drupal.org/node/2850048

Manuel Garcia’s picture

Just a heads up that #3029285: Use short array syntax got committed so that part is now fixed.

Manuel Garcia’s picture

Title: Coding standards and deprecated usages » Fix coding standards violations

Deprecated code should be dealt with on #3042635: Drupal 9 Deprecated Code Report

Let's focus here on just coding standards.

purvitagupta’s picture

Hi,
Here is the updated patch as per the coding standard.

purvitagupta’s picture

Status: Needs work » Needs review
Manuel Garcia’s picture

Status: Needs review » Needs work

Thank you @purvitagupta for the patch, here's my review:

  1. +++ b/src/Adapter.php
    @@ -10,11 +10,15 @@ use Drupal\Core\Mail\MailInterface;
    +   * MailInterface.
    +   *
    ...
    +   * MailInterface.
    +   *
    
    +++ b/src/Form/AdminForm.php
    @@ -18,16 +18,22 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
    +   * MailManagerInterface.
    +   *
    ...
    +   * ModuleHandlerInterface.
    +   *
    ...
    +   * ThemeHandlerInterface.
    +   *
    
    +++ b/src/MailsystemManager.php
    @@ -22,6 +22,8 @@ class MailsystemManager extends MailManager {
    +   * ThemeManagerInterface.
    +   *
    

    These should describe what these are rather than just the class name, I believe they are documented where they get set in the class, let's use the same phrases here so our IDEs give us something more helpful :)

  2. +++ b/tests/src/Unit/MailsystemManagerTest.php
    @@ -9,7 +9,7 @@ use Drupal\mailsystem\MailsystemManager;
    - * Test the MailsystemManager to return valid plugin instances based on the configuration.
    + * Test the MailsystemManager to return valid plugin.
    

    I think we are loosing part of the description here, is there a way we can rephrase this differently?

purvitagupta’s picture

Status: Needs work » Needs review
FileSize
6.99 KB

Hi,
Here is the updated patch.

Berdir’s picture

Status: Needs review » Needs work

This needs a reroll now, the test class is gone.

shubham.prakash’s picture

Status: Needs work » Needs review
FileSize
5.71 KB
Ankush_03’s picture

Status: Needs review » Needs work

Still some issues pending !

FILE: ...eview_temp/tests/modules/mailsystem_test/mailsystem_test.routing.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
9 | WARNING | Open page callback found, please add a comment before the
| | line why there is no access restriction
--------------------------------------------------------------------------

Time: 1.37 secs; Memory: 6Mb

FILE: ...w_temp/tests/modules/mailsystem_test/src/Plugin/Mail/DummySender.php
--------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------
20 | ERROR | [x] Expected 1 blank line before function; 0 found
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY

FILE: .../modules/mailsystem_test/src/Controller/MailsystemTestController.php
--------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------
3 | ERROR | [x] There must be one blank line after the namespace
| | declaration
14 | ERROR | [ ] Description for the @return value is missing
29 | ERROR | [x] Expected 1 blank line after function; 0 found
30 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

FILE: ...mp/tests/themes/mailsystem_test_theme/mailsystem_test_theme.info.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------

andreyjan’s picture

Status: Needs work » Needs review
FileSize
1.88 KB
7.58 KB

Fixed remaining issues.

Matroskeen’s picture

Matroskeen’s picture

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/src/Adapter.php
    @@ -10,11 +10,15 @@ use Drupal\Core\Mail\MailInterface;
     
       /**
    +   * Defines an interface for pluggable mail back-ends.
    +   *
        * @var \Drupal\Core\Mail\MailInterface
        */
       protected $instanceFormatter;
     
       /**
    
    +++ b/src/Form/AdminForm.php
    @@ -18,16 +18,22 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
       /**
    +   * Composes and optionally sends an email message..
    +   *
        * @var \Drupal\Core\Mail\MailManagerInterface
        */
       protected $mailManager;
    

    These descriptions aren't meant to describe what that interface/class does, that's already documented on the interface itself. There is usually very little to say on these, so if you look at core, you'll mostly find things like "The mail manager", "The module handler", "The XY service".

  2. +++ b/src/Form/AdminForm.php
    @@ -259,8 +265,8 @@ class AdminForm extends ConfigFormBase {
         //
         // The configuration entries can be:
    -    // modules.module.key.type -> Plugin for a special mail and send/format plugin
    -    // modules.module.none.type     -> Global plugin for the send/format plugin
    +    // modules.module.key.type->Plugin for a special mail and send/format plugin
    +    // modules.module.none.type-> Global plugin for the send/format plugin.
         $prefix = $this->getModuleKeyConfigPrefix($module, $key);
     
    

    not fond removing all whitespces so where below 80 characters, missing a . anyway too?

    Maybe restructure it to a list, with:
    * key
    the description?

Matroskeen’s picture

Status: Needs work » Needs review
FileSize
6.86 KB
3 KB
Berdir’s picture

Status: Needs review » Fixed

Committed.

  • Berdir committed c94ce75 on 8.x-4.x authored by Matroskeen
    Issue #2858676 by Matroskeen, purvitagupta, andreyjan, Munavijayalakshmi...

Status: Fixed » Closed (fixed)

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