Bug 114767 - [DCR] warn on single statement blocks within control structures
Summary: [DCR] warn on single statement blocks within control structures
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 128780
  Show dependency tree
 
Reported: 2005-11-02 10:28 EST by Maxime Daniel CLA
Modified: 2006-03-08 02:38 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2005-11-02 10:28:17 EST
Some developers consider the following as bad practice:

while (goAhead)
  doSomething();

Rationale: it is much easier then to mistakenly add further statements out of
the loop, like into:

while (goAhead)
  doSomething();
  doMore(); // indented, but NOT into the loop

than if braces are systematically added, like into:
while (goAhead) {
  doSomething();
}
  doMore(); // clearly out of the loop

A warning could be issued to help enforce coding policies that demand the use of
explicit braces for all applicable control structures. This would at least
include if (and else), while, do and for. The cases of a switch should probably
be left out of this, given the typical fall through pattern.