This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 454641 - [quickfix] Provide a fix for 'curly' linting problems
Summary: [quickfix] Provide a fix for 'curly' linting problems
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 11.0   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-09 14:48 EST by Michael Rennie CLA
Modified: 2016-01-25 14:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 
}