mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
Tweaked code standards for ternaries and return statements (#3082)
* Tweaked code standards for ternaries and return statements * Tweaked language slightly Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
This commit is contained in:
parent
b5aba7ce8f
commit
d9fafd2956
@ -178,7 +178,7 @@ The following guidelines are provided for anyone contributing source code to the
|
||||
code, and present these in the following order:
|
||||
* First, variable declarations and initialization.
|
||||
* Secondly, imperative statements.
|
||||
* Finally, the returned value. Functions should only have a single return statement.
|
||||
* Finally, the returned value. A single return statement at the end of the function should be used, except where an early return would improve code clarity.
|
||||
1. Avoid the use of "magic" values.
|
||||
eg.
|
||||
```JavaScript
|
||||
@ -189,7 +189,7 @@ The following guidelines are provided for anyone contributing source code to the
|
||||
```JavaScript
|
||||
if (responseCode === 401)
|
||||
```
|
||||
1. Don’t use the ternary operator. Yes it's terse, but there's probably a clearer way of writing it.
|
||||
1. Use the ternary operator only for simple cases such as variable assignment. Nested ternaries should be avoided in all cases.
|
||||
1. Test specs should reside alongside the source code they test, not in a separate directory.
|
||||
1. Organize code by feature, not by type.
|
||||
eg.
|
||||
|
Loading…
Reference in New Issue
Block a user