Showing 3 of 9 total issues
Function createConfig
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function createConfig() {
/** @type {import('@docusaurus/types').Config} */
return {
title: 'mdx-mermaid',
tagline: 'Plug and play Mermaid in MDX',
Function outputSVG
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const outputSVG = async (node: CodeMermaid, index: number | null, parent: Parent<Node<Data>, Data>, config?: Config): Promise<OutputResult> => {
const value = await renderToSvg(`mermaid-svg-${index}`, node.value, config && config.mermaid ? config.mermaid : {},
config?.svgMermaidSrc ?? 'https://cdn.jsdelivr.net/npm/mermaid@9.3.0/dist/mermaid.min.js')
const { fromHtml } = await import('hast-util-from-html')
const { toEstree } = await import('hast-util-to-estree')
Function plugin
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
export default function plugin(config?: Config) {
/* istanbul ignore next */
if (config?.output === 'svg') {
return async function transformer(ast: any): Promise<Parent> {
// Find all the mermaid diagram code blocks. i.e. ```mermaid
- 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"