Function render
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
render() {
const {
label,
connectDragSource,
isDragging,
- 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
Method 'render' has too many statements (13). Maximum allowed is 10. Open
render() {
- Read upRead up
- Exclude checks
title: max-statements ruletype: suggestion relatedrules: - complexity - max-depth - max-len - max-lines - max-lines-per-function - max-nested-callbacks
- max-params
The max-statements
rule allows you to specify the maximum number of statements allowed in a function.
function foo() {
var bar = 1; // one statement
var baz = 2; // two statements
var qux = 3; // three statements
}
Rule Details
This rule enforces a maximum number of statements allowed in function blocks.
Options
This rule has a number or object option:
-
"max"
(default10
) enforces a maximum number of statements allows in function blocks
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
This rule has an object option:
-
"ignoreTopLevelFunctions": true
ignores top-level functions
max
Examples of incorrect code for this rule with the default { "max": 10 }
option:
::: incorrect
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
};
:::
Examples of correct code for this rule with the default { "max": 10 }
option:
::: correct
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
:::
Note that this rule does not apply to class static blocks, and that statements in class static blocks do not count as statements in the enclosing function.
Examples of correct code for this rule with { "max": 2 }
option:
::: correct
/*eslint max-statements: ["error", 2]*/
function foo() {
let one;
let two = class {
static {
let three;
let four;
let five;
if (six) {
let seven;
let eight;
let nine;
}
}
};
}
:::
ignoreTopLevelFunctions
Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true }
options:
::: correct
/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11;
}
::: Source: http://eslint.org/docs/rules/
File has too many lines (326). Maximum allowed is 250. Wontfix
const item = monitor.getItem();
- Read upRead up
- Exclude checks
title: max-lines ruletype: suggestion relatedrules: - complexity - max-depth - max-lines-per-function - max-nested-callbacks - max-params - max-statements further_reading:
- https://web.archive.org/web/20160725154648/http://www.mind2b.com/component/content/article/24-software-module-size-and-file-size
Some people consider large files a code smell. Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines.
Rule Details
This rule enforces a maximum number of lines per file, in order to aid in maintainability and reduce complexity.
Please note that most editors show an additional empty line at the end if the file ends with a line break. This rule does not count that extra line.
Options
This rule has a number or object option:
"max"
(default300
) enforces a maximum number of lines in a file"skipBlankLines": true
ignore lines made up purely of whitespace."skipComments": true
ignore lines containing just comments
max
Examples of incorrect code for this rule with a max value of 2
:
::: incorrect
/*eslint max-lines: ["error", 2]*/
var a,
b,
c;
:::
::: incorrect
/*eslint max-lines: ["error", 2]*/
var a,
b,c;
:::
::: incorrect
/*eslint max-lines: ["error", 2]*/
// a comment
var a,
b,c;
:::
Examples of correct code for this rule with a max value of 2
:
::: correct
/*eslint max-lines: ["error", 2]*/
var a,
b, c;
:::
::: correct
/*eslint max-lines: ["error", 2]*/
var a, b, c;
:::
::: correct
/*eslint max-lines: ["error", 2]*/
// a comment
var a, b, c;
:::
skipBlankLines
Examples of incorrect code for this rule with the { "skipBlankLines": true }
option:
::: incorrect
/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
var a,
b,
c;
:::
Examples of correct code for this rule with the { "skipBlankLines": true }
option:
::: correct
/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
var a,
b, c;
:::
skipComments
Examples of incorrect code for this rule with the { "skipComments": true }
option:
::: incorrect
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
b,
c;
:::
Examples of correct code for this rule with the { "skipComments": true }
option:
::: correct
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
b, c;
:::
When Not To Use It
You can turn this rule off if you are not concerned with the number of lines in your files.
Compatibility
- JSCS: maximumNumberOfLines Source: http://eslint.org/docs/rules/
Method 'hover' has too many statements (18). Maximum allowed is 10. Open
hover(props, monitor) {
- Read upRead up
- Exclude checks
title: max-statements ruletype: suggestion relatedrules: - complexity - max-depth - max-len - max-lines - max-lines-per-function - max-nested-callbacks
- max-params
The max-statements
rule allows you to specify the maximum number of statements allowed in a function.
function foo() {
var bar = 1; // one statement
var baz = 2; // two statements
var qux = 3; // three statements
}
Rule Details
This rule enforces a maximum number of statements allowed in function blocks.
Options
This rule has a number or object option:
-
"max"
(default10
) enforces a maximum number of statements allows in function blocks
Deprecated: The object property maximum
is deprecated; please use the object property max
instead.
This rule has an object option:
-
"ignoreTopLevelFunctions": true
ignores top-level functions
max
Examples of incorrect code for this rule with the default { "max": 10 }
option:
::: incorrect
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11; // Too many.
};
:::
Examples of correct code for this rule with the default { "max": 10 }
option:
::: correct
/*eslint max-statements: ["error", 10]*/
/*eslint-env es6*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
let foo = () => {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
return function () {
// The number of statements in the inner function does not count toward the
// statement maximum.
return 42;
};
}
:::
Note that this rule does not apply to class static blocks, and that statements in class static blocks do not count as statements in the enclosing function.
Examples of correct code for this rule with { "max": 2 }
option:
::: correct
/*eslint max-statements: ["error", 2]*/
function foo() {
let one;
let two = class {
static {
let three;
let four;
let five;
if (six) {
let seven;
let eight;
let nine;
}
}
};
}
:::
ignoreTopLevelFunctions
Examples of additional correct code for this rule with the { "max": 10 }, { "ignoreTopLevelFunctions": true }
options:
::: correct
/*eslint max-statements: ["error", 10, { "ignoreTopLevelFunctions": true }]*/
function foo() {
var foo1 = 1;
var foo2 = 2;
var foo3 = 3;
var foo4 = 4;
var foo5 = 5;
var foo6 = 6;
var foo7 = 7;
var foo8 = 8;
var foo9 = 9;
var foo10 = 10;
var foo11 = 11;
}
::: Source: http://eslint.org/docs/rules/
propType "editProperty" is not required, but has no corresponding defaultProps declaration. Open
editProperty: PropTypes.func,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Prefer named exports. Open
export default connect(mapStateToProps, mapDispatchToProps)(dragSource);
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "type" is not required, but has no corresponding defaultProps declaration. Open
type: PropTypes.string,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Prop type "array" is forbidden Open
query: PropTypes.array,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Prop type "object" is forbidden Open
uiState: PropTypes.object,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "uiState" is not required, but has no corresponding defaultProps declaration. Open
uiState: PropTypes.object,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "query" is not required, but has no corresponding defaultProps declaration. Open
query: PropTypes.array,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
'denormalizedProperty' PropType is defined but prop is never used Open
denormalizedProperty: PropTypes.string,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "inserting" is not required, but has no corresponding defaultProps declaration. Open
inserting: PropTypes.bool,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "denormalizedProperty" is not required, but has no corresponding defaultProps declaration. Open
denormalizedProperty: PropTypes.string,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Definition for rule 'node/no-restricted-import' was not found. Open
import PropTypes from 'prop-types';
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Prop type "any" is forbidden Open
localID: PropTypes.any.isRequired,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "isCommonProperty" is not required, but has no corresponding defaultProps declaration. Open
isCommonProperty: PropTypes.bool,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
propType "removeProperty" is not required, but has no corresponding defaultProps declaration. Open
removeProperty: PropTypes.func,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
'query' PropType is defined but prop is never used Open
query: PropTypes.array,
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/