In the case where inline comments are used to comment out code, I do not agree with this rule:

ERROR | No space before comment text; expected "//

One reason I don't agree with it is that if I use a modern IDE like NetBeans or Eclipse to comment out code (the inline "comment out" function) it fails the above test.

Example: imagine this is some code I am working on:

  $a = $b + 1;
  //$a = $b + 2;

The 2nd line triggers the above ERROR.

There is another slight problem if one does have it formatted to meet the current Coder rule, with a space. Let's say I had it so it passes the test.

  $a = $b + 1;
  // $a = $b + 2;

Now if I say delete the 1st line and uncomment the 2nd line there is a space before the 2nd ' $a'. One has to remember to remove that space, otherwise Coder complains about the alignment. Again, if one uses say NetBeans uncomment, it does not remove that space.

Perhaps relatively trivial, but nevertheless I think this should be relaxed.

Basically, as far as inline comments are concerned, I am finding Coder far too "bossy". In general, feel that inline comments are a space/zone where developers should be free to use their own habits and practices.

Comments

yukare’s picture

I too do not like this, but still it is in coding standards.

webel’s picture

@yukare wrote:

I too do not like this, but still it is in coding standards.

Then let's have it removed from the coding standards (which are not written in stone) and then from the Coder rules.

klausi’s picture

Component: Review/Rules » Coder Sniffer
Status: Active » Closed (won't fix)

I don't think this will be removed from the coding standard, since the comment is easier to read with the leading space. Commented out code might be a special case, but I'm not sure if it is worth the effort to try to detect it. Feel free to reopen if you have an idea.

Again, changing coding standards should be discussed in the Drupal core queue.

webel’s picture

Category: Feature request » Task
Status: Closed (won't fix) » Active

@klausi again with sincere appreciation for your contributions:

Commented out code might be a special case, but I'm not sure if it is worth the effort to try to detect it.

It's not a special case, it's one of the Java, C++, and PHP developers' worlds most common cases.

Feel free to reopen if you have an idea.

My idea is: get rid of the rule entirely (not just for code), or figure out how to not apply it to commented out code. The same goes especially also for Inline comments before code (as opposed to text) should not enforce: Inline comments must start with a capital letter

I have been working through a large perfectly well working and clear code set and it is taking days because of trivial rules like this that just plain annoy any experienced developer.

PS: Please stop just closing my tickets. You may be busy, but consider than I am currently busy trying to get decent code past Coder because of such rules at my own expense.

klausi’s picture

Status: Active » Closed (won't fix)

Coder 7.x is frozen now and will not receive updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.