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

Bug 507558

Summary: Formatting error when applying the 'unnecessary else' quickfix
Product: [ECD] Orion Reporter: Eric Moffatt <emoffatt>
Component: JS ToolsAssignee: Casey Flynn <caseyflynn>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie, steve_northover
Version: unspecified   
Target Milestone: 13.0   
Hardware: PC   
OS: Mac OS X   
See Also: https://git.eclipse.org/r/85182
https://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=4137de4edc959a02421571b3450d57883ca49d4a
Whiteboard:

Description Eric Moffatt CLA 2016-11-15 11:13:38 EST
If you start with this code:

    if(body.cod === 200) {
    	var weath = 10;
    	var resp = {city: body.name, weather: weath}
    	return res.status(200).send(resp);
    } else {
         return res.status(400).send({msg:'Failed'});
    }

you'll get a warning about the 'else' being after a 'return' but executing the quickfix gives this:

    if(body.cod === 200) {
    	var weath = 10;
    	var resp = {city: body.name, weather: weath}
    	return res.status(200).send(resp);
    } return res.status(400).send({msg:'Failed'});
Comment 1 Steve Northover CLA 2016-11-16 08:48:10 EST
Casey, feel free to ask questions in this bug report, on the mailing list or in Mattermost.
Comment 2 Casey Flynn CLA 2016-11-16 11:55:28 EST
Thanks Steve! 

I have updated source on my local machine \ github and verified it, however I am running into issues with the unit tests. I reviewed the testing guidelines under http://wiki.eclipse.org/Orion/Running_the_tests however I am still trying to understand how the code under test is tested. I have the unit tests in a state where they are passing, however I don't think they should be. 

Are there more resources I can review to understand the testing suite better?

I have a PR ready at: https://github.com/caseyflynn-google/orion.client/pull/1 however I would like to understand the testing more before I push upstream.
Comment 3 Michael Rennie CLA 2016-11-16 12:47:08 EST
(In reply to Casey Flynn from comment #2)
> Thanks Steve! 
> 
> I have updated source on my local machine \ github and verified it, however
> I am running into issues with the unit tests. I reviewed the testing
> guidelines under http://wiki.eclipse.org/Orion/Running_the_tests however I
> am still trying to understand how the code under test is tested. I have the
> unit tests in a state where they are passing, however I don't think they
> should be. 
> 

The easiest way to run the tests (the tooling tests anyways) is to do the following (assuming you are working in orionhub.org):

1. go to the sites page (click the sites icon on the left menu) and create a new site. Next, click the new sites name so you can see its content. On that page, there is a button at the top to convert the new site to self-hosting. Click that and select the root folder for orion.client and hit ok. 
2. Now go back to the navigator and select the file JsMochaSuite.html, then open the context menu, select Open Related, then View on Site
3. on the next page, select the new site you created in step 1. Then click add, and then click view.
4. The tests should start running. If you open the developer tools, you can debug tests as well.

It seems we need to update some wikis with these additional instructions.

> Are there more resources I can review to understand the testing suite better?
> 

There are not really any additional resources other than the wiki page you noted (which needs some updating).

> I have a PR ready at:
> https://github.com/caseyflynn-google/orion.client/pull/1 however I would
> like to understand the testing more before I push upstream.

The github mirror for our code is not used for development. Can you push your changes to gerrit and close your pull request?

Have a look at http://wiki.eclipse.org/Orion/Contributing_Code#Submit_your_changes_to_Gerrit
Comment 4 Steve Northover CLA 2016-11-16 13:02:58 EST
Mike, can you fix the wiki please.  Thanks.
Comment 5 Michael Rennie CLA 2016-11-16 14:15:32 EST
(In reply to Steve Northover from comment #4)
> Mike, can you fix the wiki please.  Thanks.

Already done: https://wiki.eclipse.org/Orion/Running_the_tests#Running_self-hosted_tests
Comment 6 Eclipse Genie CLA 2016-11-16 19:05:27 EST
New Gerrit change created: https://git.eclipse.org/r/85182
Comment 8 Michael Rennie CLA 2016-11-17 11:18:35 EST
Merged, thanks Casey!