Function extractJsDocTags
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function extractJsDocTags(ast: doctrine.Annotation): ExtractedJsDoc {
const extractedTags: ExtractedJsDoc = {
params: null,
returns: null,
ignore: false,
- 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 extractTypeName
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
function extractTypeName(type: doctrine.Type): string {
if (type.type === 'NameExpression') {
return type.name;
}
- 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 extractTypeName
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractTypeName(type: doctrine.Type): string {
if (type.type === 'NameExpression') {
return type.name;
}
Function extractJsDocTags
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractJsDocTags(ast: doctrine.Annotation): ExtractedJsDoc {
const extractedTags: ExtractedJsDoc = {
params: null,
returns: null,
ignore: false,
Avoid deeply nested control flow statements. Open
if (extractedTags.params == null) {
extractedTags.params = [];
}
Function extractParam
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function extractParam(tag: doctrine.Tag): ExtractedJsDocParam {
const paramName = tag.name;
// When the @param doesn't have a name but have a type and a description, "null-null" is returned.
if (paramName != null && paramName !== 'null-null') {
- 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
Avoid too many return
statements within this function. Open
return extractTypeName(type.expression);
Avoid too many return
statements within this function. Open
return null;
Avoid too many return
statements within this function. Open
return 'any';
Avoid too many return
statements within this function. Open
return `${arrayType}[]`;
Expected a 'for-of' loop instead of a 'for' loop with this simple iteration Open
for (let i = 0; i < ast.tags.length; i += 1) {
- Read upRead up
- Exclude checks
Rule: prefer-for-of
Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.
Rationale
A for(... of ...) loop is easier to implement and read when the index is not needed.
Config
Not configurable.
Examples
"prefer-for-of": true
For more information see this page.