Passed
Branch test (085f39)
by Eric
59s
created

toES6Module.js (5 issues)

1
var fs = require('fs');
2
3
fs.readFile('./src/utilities.js', 'utf8', function(err, data) {
4
  if (err) {
5
    return console.log(err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6
  }
7
8
  data = data.replace(
9
    'module.exports = utilities;',
10
    'export default utilities;'
11
  );
12
13
  fs.writeFile('./utilities.es.js', data, 'utf8', function(err) {
14
    if (err) return console.log(err);
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if err is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
15
  });
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
16
});
17