Showing 31 of 69 total issues
Function getProperty
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const getProperty = (propName: string, element?: string, data?: MDAST.Root) => {
let target: string | void | undefined;
if (data) {
try {
- 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 replaceRefs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function replaceRefs(obj: object) {
for (const value of Object.values(obj)) {
if (typeof value !== 'object' || value === null) continue;
if ('$ref' in value) {
value.$ref = '<replaced>';
- 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 deeply nested control flow statements. Open
if (annotationVal === 'json_schema') {
// camelCase to be consistent with rest of annotation props
metaProps.push('jsonSchema');
}
Avoid deeply nested control flow statements. Open
} else if (key === 'highlightLines') {
// handle deprecated way of adding highlightLines via array annotation
if (Array.isArray(annotationVal)) {
const rangeVals = [];
for (const val of annotationVal) {
Function constructor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
constructor(data: MDAST.Root | string, mutate = false) {
const root =
typeof data === 'string' ? parseWithPointers(data).data : mutate ? data : JSON.parse(JSON.stringify(data));
if (root.type !== 'root') {
throw new TypeError('Malformed yaml was provided');
- 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 unwrapImages
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const unwrapImages: unified.Attacher = function () {
// Patch slugs on heading nodes.
return function transformer(tree) {
visit<Parent>(tree, 'paragraph', (node, index, parent) => {
if (!index) return;
- 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 getTags
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const getTags = (data?: MDAST.Root): string[] => {
const tags: string[] = [];
if (data) {
try {
- 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 handleLegacyAnnotations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function handleLegacyAnnotations(annotations: MDAST.Code['annotations']) {
if (!annotations) return;
if (annotations.hasOwnProperty('type')) {
// @ts-expect-error type is no longer part of the typings, it is deprecated
- 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 updateDocument
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private updateDocument() {
const children = this.document.children as MDAST.Parent['children'] | undefined;
if (!children) return;
const index = children.indexOf(this.node);
- 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 inlineImages
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const inlineImages: unified.Attacher = function () {
// Set `inline` prop on images that we consider "inline", so that downstream renderers can render them nicely
return function transformer(tree) {
visit<Parent>(tree, ['image', 'imageReference'], (node, index, parent) => {
if (!parent) return;
- 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 parseMeta
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function parseMeta(metastring?: string | null) {
const props: Record<string, boolean | string> = {};
if (!metastring) return props;
- 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"