Don't add dot with inline comments containing code with semicolon

Created on 3 November 2015, over 9 years ago
Updated 22 June 2023, almost 2 years ago

This code:

    //$transaction->payload['vps_status'] = 'TIMEOUT';

is converted into:

    // $transaction->payload['vps_status'] = 'TIMEOUT';.

with dot at the end.

Tested with command: phpcbf --standard=Drupal .

Other example:

  //dsm($vars['day_items']);

into:

  // dsm($vars['day_items']);.

So my suggestion is to not add the dot, when there is already some punctuation at the end (such as semicolon, or comma, etc.), so at the same time it'll solve the problem with adding dot at the end of the PHP code.

🐛 Bug report
Status

Active

Version

2.0

Component

Review/Rules

Created by

🇬🇧United Kingdom kenorb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    Just noting that the related issue in the Coding Standards project has been closed as won't fix. It seems that will support closing this long standing issue.

  • 🇬🇧United Kingdom jonathan1055

    OK. So #2742881: Can inline comments end with semicolons is now closed as 'wont fix', meaning that inline comments cannot end with a semicolon. That's fine.

    Therefore, is the proposition that Coder should flag these as errors, but not automatically fix it by adding a dot. It is up to the developer to correct the inline code manually, in what ever way they want to.

  • 🇳🇿New Zealand quietone

    Add a full stop to a line of code seems a bit error prone. I think most of use would expect to uncomment a line of code and have that code 'work' and not fail straight away. So, promoting adding an ignore line seems better. And it might have the benefit of making it easier to find commented out code.

    And, if I had to choose I would want the automatic fix to be to add the ignore the line(s).

Production build 0.71.5 2024