Function loadDApp
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
loadDApp (key) {
const readManifest = function (file_path) {
const tryReadFile = (path) => {
try {
let dapp_config = JSON.parse(fs.readFileSync(path))
- Read upRead up
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
Trailing spaces not allowed. Open
if (typeof d_conf !== 'object' || d_conf.disable || d_conf.disabled || d_conf.enable === false) return
- Read upRead up
- Exclude checks
disallow trailing whitespace at the end of lines (no-trailing-spaces)
Sometimes in the course of editing files, you can end up with extra whitespace at the end of lines. These whitespace differences can be picked up by source control systems and flagged as diffs, causing frustration for developers. While this extra whitespace causes no functional issues, many code conventions require that trailing spaces be removed before check-in.
Rule Details
This rule disallows trailing whitespace (spaces, tabs, and other Unicode whitespace characters) at the end of lines.
Examples of incorrect code for this rule:
/*eslint no-trailing-spaces: "error"*/
var foo = 0;//•••••
var baz = 5;//••
//•••••
Examples of correct code for this rule:
/*eslint no-trailing-spaces: "error"*/
var foo = 0;
var baz = 5;
Options
This rule has an object option:
-
"skipBlankLines": false
(default) disallows trailing whitespace on empty lines -
"skipBlankLines": true
allows trailing whitespace on empty lines
skipBlankLines
Examples of correct code for this rule with the { "skipBlankLines": true }
option:
/*eslint no-trailing-spaces: ["error", { "skipBlankLines": true }]*/
var foo = 0;
var baz = 5;
//•••••
Source: http://eslint.org/docs/rules/
Do not use 'new' for side effects. Open
new DCLib.DApp({
- Read upRead up
- Exclude checks
Disallow new For Side Effects (no-new)
The goal of using new
with a constructor is typically to create an object of a particular type and store that object in a variable, such as:
var person = new Person();
It's less common to use new
and not store the result, such as:
new Person();
In this case, the created object is thrown away because its reference isn't stored anywhere, and in many cases, this means that the constructor should be replaced with a function that doesn't require new
to be used.
Rule Details
This rule is aimed at maintaining consistency and convention by disallowing constructor calls using the new
keyword that do not assign the resulting object to a variable.
Examples of incorrect code for this rule:
/*eslint no-new: "error"*/
new Thing();
Examples of correct code for this rule:
/*eslint no-new: "error"*/
var thing = new Thing();
Thing();
Source: http://eslint.org/docs/rules/