Function generate_cms_list
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
pagelist_generator.prototype.generate_cms_list = function () {
return new Promise(function (resolve, reject) {
glob(enduro.project_path + '/cms/**/*.js', function (err, files) {
if (err) { console.log('failed to generate cms list', err) }
- 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
Function generate_cms_list
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
pagelist_generator.prototype.generate_cms_list = function () {
return new Promise(function (resolve, reject) {
glob(enduro.project_path + '/cms/**/*.js', function (err, files) {
if (err) { console.log('failed to generate cms list', err) }
Function build
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function build (pagepath, partial_pages, fullpath) {
// decides if pagepath is folder or file
if (pagepath.length == 1) {
More than 1 blank line not allowed. Open
- Read upRead up
- Exclude checks
Disallows multiple blank lines (no-multiple-empty-lines)
Some developers prefer to have multiple blank lines removed, while others feel that it helps improve readability. Whitespace is useful for separating logical sections of code, but excess whitespace takes up more of the screen.
Rule Details
This rule aims to reduce the scrolling required when reading through your code. It will warn when the maximum amount of empty lines has been exceeded.
Options
The second argument can be used to configure this rule:
-
max
sets the maximum number of consecutive blank lines. -
maxEOF
can be used to set a different number for the end of file. The last blank lines will then be treated differently. If omitted, themax
option is applied at the end of the file. -
maxBOF
can be used to set a different number for the beginning of the file. If omitted, the 'max' option is applied at the beginning of the file.
max
In the following example, the error
is the severity of the rule, and the
max
property is the maximum number of empty lines (2 in this example).
"no-multiple-empty-lines": ["error", {"max": 2}]
The following patterns are considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2}]*/
var foo = 5;
var bar = 3;
The following patterns are not considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2}]*/
var foo = 5;
var bar = 3;
maxEOF
"no-multiple-empty-lines": ["error", {"max": 2, "maxEOF": 1}]
The following patterns are considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2, maxEOF: 1}]*/
var foo = 5;
var bar = 3;
The following patterns are not considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2, maxEOF: 1}]*/
var foo = 5;
var bar = 3;
maxBOF
"no-multiple-empty-lines": ["error", {"max": 2, "maxBOF": 0}]
The following patterns are considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/
var foo = 5;
var bar = 3;
The following patterns are not considered problems:
/*eslint no-multiple-empty-lines: ["error", {max: 2, maxBOF: 0}]*/
var foo = 5;
var bar = 3;
When Not To Use It
If you do not care about extra blank lines, turn this off. Source: http://eslint.org/docs/rules/