Problem/Motivation

Update the code so that it follows Drupal coding standards.

Proposed resolution

See what the testbot has to say about the most recent patch. Most of the problems are use of the long array syntax.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Assigned: benjifisher » Unassigned
Status: Active » Needs review
StatusFileSize
new0 bytes

Let's see what the testbot thinks of this patch.

The testbot only reports on files that have changed. Luckily, this patch touches several files. This patch just fixes array syntax:

  • Use short array syntax.
  • Add commas to the last entry of multi-line arrays.
benjifisher’s picture

StatusFileSize
new24.92 KB

Here is a second try at the patch. The previous one was 0 bytes, which means I am more tired than I realized.

benjifisher’s picture

StatusFileSize
new4.86 KB
new28.32 KB

The testbot noticed several problems. The following patch addresses two:

  • Remove an unused use statement.
  • Use a single space before =, ==, and =>.

The interdiff shows just these changes.

benjifisher’s picture

StatusFileSize
new8.51 KB
new36.86 KB

The attached patch fixes a few more problems:

  • Add missing @param, @return comments.
  • Add missing type hints.
benjifisher’s picture

StatusFileSize
new3.03 KB
new39.67 KB

This patch standardizes line indentation. It means that some of the comments no longer line up nicely, but for now I care more about making the testbot happy.

benjifisher’s picture

StatusFileSize
new4.33 KB
new43.07 KB

This patch fixes a few more problems in the doc blocks. I missed these in #5.

benjifisher’s picture

StatusFileSize
new4.43 KB
new45.5 KB

This patch fixes a few more indentation errors, doc blocks, and other comments.

benjifisher’s picture

Status: Needs review » Needs work

I set the status to NR because I wanted to trigger tests. In fact, there is more work to do here, so I am setting the status back to NW.

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new340 bytes
new45.76 KB

Here is another patch that fixes one more line. I hope this fixes the failing test with PHP 7.4.

There is still more to do, but I am setting the status to NR to see whether it does fix the test.

benjifisher’s picture

Status: Needs review » Needs work

So far, so good. Back to NW.

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new8.68 KB
new53.24 KB

This patch includes several fixes:

  1. Do not concatenate literal strings.
  2. Use all caps for constants: TRUE and FALSE.
  3. Use lowerCamelCase for method names.
  4. Avoid gendered language in comments.
  5. Remove a report left over from the initial automated port to D8.

IMO the only reason for some of these (such as (1)) is to keep CodeSniffer happy.

I will not fix the remaining indentation errors in src/SmartyPants.php since that is someone else's copyright/license notice. I think this fixes all the other problems the testbot reported on this issue. There are still some files, not touched in this issue, that have problems.

Status: Needs review » Needs work

The last submitted patch, 12: 3124616-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new407 bytes
new53.5 KB

This patch should fix the failing test. I am setting the status to NR to confirm.

There are still several files mentioned on the branch test that need some fixes.

benjifisher’s picture

StatusFileSize
new5.09 KB
new58.94 KB

Follow Drupal coding standards in the remaining files:

  • Wrap lines to 80 characters in README.md and INSTALL.txt. (Also add some backticks to README.md.)
  • Add use statement so that we do not need fully qualified class names later.
  • Follow whitespace standards.
  • Add missing variable, function, and class doc blocks.
  • Add types and comments to @param comments.
  • Add ending punctuation to comment lines.
  • Add type hints.
  • Remove unneeded typogrify.install.
  • Ignore indentation errors in the copyright/licanse lines.

With luck, this will be the final patch on this issue.

benjifisher’s picture

StatusFileSize
new1.34 KB
new58.98 KB

Add use statement so that we do not need fully qualified class names later.

Do it right this time: avoid a name collision.

After all, there is a reason that the original code had a use statement for SmartyPants but not for Typogrify.

benjifisher’s picture

StatusFileSize
new354 bytes
new59.15 KB

I installed Upgrade Status and checked the Typogrify module. It reported that one of the automated tests had the wrong namespace. I am calling it in scope for this issue, and this patch should fix it.

The other warnings will be handled in #3126073: Drupal 9 compatibility.

benjifisher’s picture

Assigned: Unassigned » benjifisher

I am reviewing this myself. This is not the best practice, but

  1. It seems likely that no one else will take the trouble to review this issue.
  2. The fix from #17 effectively increases test coverage for this module, so I want to commit it before other pending issues.
  3. I will do my best to review the patch with "fresh eyes", just as I would review someone else's patch.
benjifisher’s picture

Note that the patch in #17 changes the name of the method to lowerCamelCase:

+++ b/src/Typogrify.php
@@ -128,14 +132,23 @@ class Typogrify {
...
-  public static function initial_quotes($text, $do_guillemets = false) {
+  public static function initialQuotes($text, $do_guillemets = FALSE) {

but not the option for the Twig filter:

+++ b/src/TwigExtension/Typogrify.php
@@ -16,24 +25,26 @@ class Typogrify extends \Twig_Extension {
...
-   *   Possible values: amp, widont, smartypants, caps, initial_quotes, dash
+   *   Possible values: amp, widont, smartypants, caps, initial_quotes, dash.
@@ -41,17 +52,18 @@ class Typogrify extends \Twig_Extension {
...
     if (in_array('initial_quotes', $options)) {
-      $text = \Drupal\typogrify\Typogrify::initial_quotes($text);
+      $text = TypogrifyBase::initialQuotes($text);
     }
benjifisher’s picture

Assigned: benjifisher » Unassigned
Status: Needs review » Reviewed & tested by the community

The patch in #17 looks good to me.

  • benjifisher committed 247fa10 on 8.x-1.x
    Issue #3124616 by benjifisher: Fix coding standards in Typogrify
    
benjifisher’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Lovely! 😍

Status: Fixed » Closed (fixed)

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