Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 454641

Summary: [quickfix] Provide a fix for 'curly' linting problems
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 8.0   
Target Milestone: 11.0   
Hardware: All   
OS: All   
Whiteboard:

Description Michael Rennie CLA 2014-12-09 14:48:33 EST
We should offer a quickfix to enclose the reported statement in curly braces.
Comment 1 Michael Rennie CLA 2016-01-25 14:28:36 EST
Fix + tests:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=65665fc09537a905454182ce2d165fd154a0ea6a

In cases where we can't figure out the intention of the code, we err on the side of caution and only surround the immediate statement in braces.

For example say you had this:

if(true)
  foo();
  bar();

we will only surround 'foo();' and not bar. Just due to spacing we can't know if you wanted 'bar()' to be part of the if or not, and if we did enclose it, we would change the behaviour of the code.

The fix code is smart enough to not decouple comments though. For example:

if(true)
  foo('hello');  //$NON-NLS-1

will be fixed as:

if(true) {
  foo('hello');  //$NON-NLS-1 
}