Gottwik/Enduro

View on GitHub
libs/remote_tools/remote_handler.js

Summary

Maintainability
A
1 hr
Test Coverage

Function request_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

remote_handler.prototype.request_file = function (url) {
    return new Promise(function (resolve, reject) {
        if (flat_helpers.is_local(url)) {
            fs.readFile(url, 'utf8', function (err, data) {
                if (err) {
Severity: Minor
Found in libs/remote_tools/remote_handler.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Unexpected control character in regular expression.
Open

    filename = filename.replace(/[^\x00-\x7F]|\ /ig, '')
Severity: Minor
Found in libs/remote_tools/remote_handler.js by eslint

disallow control characters in regular expressions (no-control-regex)

Control characters are special, invisible characters in the ASCII range 0-31. These characters are rarely used in JavaScript strings so a regular expression containing these characters is most likely a mistake.

Rule Details

This rule disallows control characters in regular expressions.

Examples of incorrect code for this rule:

/*eslint no-control-regex: "error"*/

var pattern1 = /\x1f/;
var pattern2 = new RegExp("\x1f");

Examples of correct code for this rule:

/*eslint no-control-regex: "error"*/

var pattern1 = /\x20/;
var pattern2 = new RegExp("\x20");

When Not To Use It

If you need to use control character pattern matching, then you should turn this rule off.

Related Rules

Unnecessary escape character: \
Open

    filename = filename.replace(/[^\x00-\x7F]|\ /ig, '')
Severity: Minor
Found in libs/remote_tools/remote_handler.js by eslint

Disallow unnecessary escape usage (no-useless-escape)

Escaping non-special characters in strings and regular expressions doesn't have any effects on results, as in the following example:

let foo = "hol\a"; // > foo = "hola"
let bar = /\:/ // same functionality with /:/

Rule Details

This rule flags escapes that can be safely removed without changing behavior.

The following patterns are considered problems:

/*eslint no-useless-escape: "error"*/

"\'";
'\"';
"\#";
"\e";
/\!/;
/\@/;

The following patterns are not considered problems:

/*eslint no-useless-escape: "error"*/

"\"";
'\'';
"\x12";
"\u00a9";
"\371";
"xs\u2111";
/\\/g;
/\t/g;
/\\w\\$\\*\\^\\./;

When Not To Use It

If you don't want to be notified about unnecessary escapes, you can safely disable this rule. Source: http://eslint.org/docs/rules/

There are no issues that match your filters.

Category
Status