Function getConditionalAnnotation
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function getConditionalAnnotation(binding, path, name) {
const ifStatement = getParentConditionalPath(binding, path, name);
if (!ifStatement) return;
const test = ifStatement.get("test");
- 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 inferAnnotationFromBinaryExpression
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function inferAnnotationFromBinaryExpression(name, path) {
const operator = path.node.operator;
const right = path.get("right").resolve();
const left = path.get("left").resolve();
- 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 getConditionalAnnotation
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getConditionalAnnotation(binding, path, name) {
const ifStatement = getParentConditionalPath(binding, path, name);
if (!ifStatement) return;
const test = ifStatement.get("test");
Function getParentConditionalPath
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getParentConditionalPath(binding, path, name) {
let parentPath;
while ((parentPath = path.parentPath)) {
if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {
if (path.key === "test") {
- 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 inferAnnotationFromBinaryExpression
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function inferAnnotationFromBinaryExpression(name, path) {
const operator = path.node.operator;
const right = path.get("right").resolve();
const left = path.get("left").resolve();
Function getTypeAnnotationBindingConstantViolations
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getTypeAnnotationBindingConstantViolations(binding, path, name) {
const types = [];
const functionConstantViolations = [];
let constantViolations = getConstantViolationsBefore(
Function default
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default function (node: Object) {
if (!this.isReferenced()) return;
// check if a binding exists of this value and if so then return a union type of all
// possible types that the binding could be
- 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 getTypeAnnotationBindingConstantViolations
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getTypeAnnotationBindingConstantViolations(binding, path, name) {
const types = [];
const functionConstantViolations = [];
let constantViolations = getConstantViolationsBefore(
- 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
if (!typeofPath.get("argument").isIdentifier({ name })) return;
Avoid too many return
statements within this function. Open
return t.numberTypeAnnotation();
Avoid too many return
statements within this function. Open
if (!typePath.isLiteral()) return;
Avoid too many return
statements within this function. Open
return t.createTypeAnnotationBasedOnTypeof(typeValue);
Avoid too many return
statements within this function. Open
if (typeof typeValue !== "string") return;
Avoid too many return
statements within this function. Open
if (!typeofPath) return;
Avoid too many return
statements within this function. Open
return getConditionalAnnotation(ifStatement, name);