Redundant newlines after /* * * */ style comments

irstudio - June 11, 2008 - 03:14
Project:Coder
Version:5.x-2.x-dev
Component:Coder Format
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

/*
 * if some condition
 * do something
 */
if (some condition) {
}

well right now there is a bug with this style of comments
coding standards say they are fine, and i don't mind them
but a new line is added after the comments each and every time coder_format runs
so you end up with umpteen empty lines between the comment and the code it's describing

/*
 * if some condition
 * do something
 */

... many new lines ...

if (some condition) {
}

#1

sun - August 11, 2008 - 14:45
Status:active» won't fix

Well, the cause is elsewhere: you are using block comments instead of inline comments. Block/multi-line comments are preserved for function declarations and PHPdoc comments in general, such as

<?php
/**
* @file
* Foo bar module; does baz to your site.
*/

/**
* Implementation of hook_menu().
*/
?>

...while inline comments are the proper way to remark logic, such as:
<?php
/**
* Implementation of hook_menu().
*/
function foobar_menu() {
 
// Check whether bar is foo-lish.
 
if ($bar == $foo) {
   
// Do something.
 
}
}
?>

I'm afraid that we cannot find a universally working solution here, because coder_format needs to add this newline to prevent multiple multi-line comments from being squished together without any newline between them.

 
 

Drupal is a registered trademark of Dries Buytaert.