Showing 31 of 69 total issues
File reader.spec.ts
has 434 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as fs from 'fs';
import * as path from 'path';
import html from 'remark-html';
import unified from 'unified';
Function computeMetaProps
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
function computeMetaProps(annotations: object) {
const metaProps = [];
if (Object.keys(annotations).length) {
for (const key in annotations) {
const annotationVal = annotations[key];
- 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 smdAnnotations
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
export const smdAnnotations: unified.Attacher = function () {
return function transform($root) {
const root = $root as MDAST.Root;
const nodes = root.children;
- 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 smdAnnotations
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const smdAnnotations: unified.Attacher = function () {
return function transform($root) {
const root = $root as MDAST.Root;
const nodes = root.children;
Function transform
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function transform($root) {
const root = $root as MDAST.Root;
const nodes = root.children;
const processed: MDAST.Content[] = [];
Function applicable
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
function applicable(node: Parent, inLink?: boolean): boolean | null {
let image: boolean | null = null;
let children = node.children;
let length = children.length;
let index = -1;
- 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
File resolver.spec.ts
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as fs from 'fs';
import * as path from 'path';
import remarkStringify, { RemarkStringifyOptions } from 'remark-stringify';
import unified from 'unified';
Function captureAnnotations
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function captureAnnotations<T extends Dictionary<any>>(node: MDAST.Content | undefined): T | {} {
if (!node?.value) return {};
if (
// @ts-expect-error
- 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 findNode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function findNode(root: MDAST.Parent | MDAST.Content, node: MDAST.Content, path: JsonPath): MDAST.Content | undefined {
if (node.position === undefined || root.position === undefined) return;
if (
node.position.start.line === root.position.start.line &&
- 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 findNodeAtPosition
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function findNodeAtPosition(
node: MDAST.Parent | MDAST.Content,
position: IPosition,
path: JsonPath,
): MDAST.Parent | MDAST.Content | undefined {
- 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
File fronmatter.spec.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as fs from 'fs';
import { join } from 'path';
import { MDAST } from '../../ast-types';
import { parse } from '../../parse';
Function resolveCodeBlocks
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const resolveCodeBlocks: unified.Attacher<[{ resolver?: Resolver }]> = function (opts) {
const resolver = opts?.resolver;
if (!resolver) return;
return async function transformer(tree, _file) {
- 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 unset
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public unset(prop: PropertyPath) {
if (this.properties !== null) {
const path = _toPath(prop);
const lastSegment = Number(path[path.length - 1]);
if (!Number.isNaN(lastSegment)) {
- 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 smdCode
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const smdCode: unified.Attacher = function () {
return function transform(root) {
let sequentialCodeBlocks: MDAST.Code[] = [];
let lastIndex = -1;
let lastParent: MDAST.Parent | undefined;
Function transform
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
return function transform(root) {
let sequentialCodeBlocks: MDAST.Code[] = [];
let lastIndex = -1;
let lastParent: MDAST.Parent | undefined;
Function computeMetaProps
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function computeMetaProps(annotations: object) {
const metaProps = [];
if (Object.keys(annotations).length) {
for (const key in annotations) {
const annotationVal = annotations[key];
Function captureAnnotations
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function captureAnnotations<T extends Dictionary<any>>(node: MDAST.Content | undefined): T | {} {
if (!node?.value) return {};
if (
// @ts-expect-error
Function resolveCodeBlocks
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const resolveCodeBlocks: unified.Attacher<[{ resolver?: Resolver }]> = function (opts) {
const resolver = opts?.resolver;
if (!resolver) return;
return async function transformer(tree, _file) {
Function applicable
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applicable(node: Parent, inLink?: boolean): boolean | null {
let image: boolean | null = null;
let children = node.children;
let length = children.length;
let index = -1;
Function transformer
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
return async function transformer(tree, _file) {
const codes: Array<{ node: MDAST.Code; index: number | null; parent: Parent | null }> = [];
const promises: Array<Promise<void>> = [];
visit<MDAST.Code>(tree, 'code', (node, index, parent) => {