yoctore/yoctopus-generator

View on GitHub
app/templates/applications/node/_app.js

Summary

Maintainability
A
1 hr
Test Coverage

Don't use process.exit(); throw an error instead.
Open

  process.exit(0);

Disallow process.exit() (no-process-exit)

The process.exit() method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example:

if (somethingBadHappened) {
    console.error("Something bad happened!");
    process.exit(1);
}

This code could appear in any module and will stop the entire application when somethingBadHappened is truthy. This doesn't give the application any chance to respond to the error. It's usually better to throw an error and allow the application to handle it appropriately:

if (somethingBadHappened) {
    throw new Error("Something bad happened!");
}

By throwing an error in this way, other parts of the application have an opportunity to handle the error rather than stopping the application altogether. If the error bubbles all the way up to the process without being handled, then the process will exit and a non-zero exit code will returned, so the end result is the same.

Rule Details

This rule aims to prevent the use of process.exit() in Node.js JavaScript. As such, it warns whenever process.exit() is found in code.

Examples of incorrect code for this rule:

/*eslint no-process-exit: "error"*/

process.exit(1);
process.exit(0);

Examples of correct code for this rule:

/*eslint no-process-exit: "error"*/

Process.exit();
var exit = process.exit;

When Not To Use It

There may be a part of a Node.js application that is responsible for determining the correct exit code to return upon exiting. In that case, you should turn this rule off to allow proper handling of the exit code. Source: http://eslint.org/docs/rules/

Don't use process.exit(); throw an error instead.
Open

    process.exit(0);

Disallow process.exit() (no-process-exit)

The process.exit() method in Node.js is used to immediately stop the Node.js process and exit. This is a dangerous operation because it can occur in any method at any point in time, potentially stopping a Node.js application completely when an error occurs. For example:

if (somethingBadHappened) {
    console.error("Something bad happened!");
    process.exit(1);
}

This code could appear in any module and will stop the entire application when somethingBadHappened is truthy. This doesn't give the application any chance to respond to the error. It's usually better to throw an error and allow the application to handle it appropriately:

if (somethingBadHappened) {
    throw new Error("Something bad happened!");
}

By throwing an error in this way, other parts of the application have an opportunity to handle the error rather than stopping the application altogether. If the error bubbles all the way up to the process without being handled, then the process will exit and a non-zero exit code will returned, so the end result is the same.

Rule Details

This rule aims to prevent the use of process.exit() in Node.js JavaScript. As such, it warns whenever process.exit() is found in code.

Examples of incorrect code for this rule:

/*eslint no-process-exit: "error"*/

process.exit(1);
process.exit(0);

Examples of correct code for this rule:

/*eslint no-process-exit: "error"*/

Process.exit();
var exit = process.exit;

When Not To Use It

There may be a part of a Node.js application that is responsible for determining the correct exit code to return upon exiting. In that case, you should turn this rule off to allow proper handling of the exit code. Source: http://eslint.org/docs/rules/

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  core.start().then(function () {

  /********************************************
   *              YOUR CODE HERE              *
   *******************************************/
Severity: Minor
Found in app/templates/applications/node/_app.js and 1 other location - About 50 mins to fix
app/templates/applications/node/_app.js on lines 11..30

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

core.init().then(function () {
  // Init succeed start your app
  core.start().then(function () {

  /********************************************
Severity: Minor
Found in app/templates/applications/node/_app.js and 1 other location - About 50 mins to fix
app/templates/applications/node/_app.js on lines 13..24

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 51.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status