knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/block/layout.ts

Summary

Maintainability
D
1 day
Test Coverage

Function setBlockSizes has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function setBlockSizes(block: Block, db: BlockDB, siblingWidth = 0, siblingHeight = 0) {
  log.debug(
    'setBlockSizes abc95 (start)',
    block.id,
    block?.size?.x,
Severity: Major
Found in packages/mermaid/src/diagrams/block/layout.ts - About 4 hrs to fix

    Function layoutBlocks has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function layoutBlocks(block: Block, db: BlockDB) {
      log.debug(
        `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${block?.size?.x} y: ${block?.size?.y} width: ${block?.size?.width}`
      );
      const columns = block.columns || -1;
    Severity: Major
    Found in packages/mermaid/src/diagrams/block/layout.ts - About 2 hrs to fix

      File layout.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import type { BlockDB } from './blockDB.js';
      import type { Block } from './blockTypes.js';
      import { log } from '../../logger.js';
      import { getConfig } from '../../diagram-api/diagramAPI.js';
      const padding = getConfig()?.block?.padding || 8;
      Severity: Minor
      Found in packages/mermaid/src/diagrams/block/layout.ts - About 2 hrs to fix

        Function getMaxChildSize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getMaxChildSize = (block: Block) => {
          let maxWidth = 0;
          let maxHeight = 0;
          // find max width of children
          // log.debug('getMaxChildSize abc95 (start) parent:', block.id);
        Severity: Minor
        Found in packages/mermaid/src/diagrams/block/layout.ts - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                    if (child.size) {
                      child.size.width = childWidth;
                    }
          Severity: Major
          Found in packages/mermaid/src/diagrams/block/layout.ts - About 45 mins to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              log.debug(
                `abc85 layout blocks (=>layoutBlocks) ${block.id} x: ${block?.size?.x} y: ${block?.size?.y} width: ${block?.size?.width}`
              );
            Severity: Major
            Found in packages/mermaid/src/diagrams/block/layout.ts and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/block/layout.ts on lines 280..282

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              log.debug(
                `layout blocks (<==layoutBlocks) ${block.id} x: ${block?.size?.x} y: ${block?.size?.y} width: ${block?.size?.width}`
              );
            Severity: Major
            Found in packages/mermaid/src/diagrams/block/layout.ts and 1 other location - About 1 hr to fix
            packages/mermaid/src/diagrams/block/layout.ts on lines 206..208

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 60.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                let startingPosX = block?.size?.x ? block?.size?.x + (-block?.size?.width / 2 || 0) : -padding;
            Severity: Minor
            Found in packages/mermaid/src/diagrams/block/layout.ts and 1 other location - About 35 mins to fix
            packages/mermaid/src/diagrams/block/layout.ts on lines 235..235

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 47.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    startingPosX = block?.size?.x ? block?.size?.x + (-block?.size?.width / 2 || 0) : -padding;
            Severity: Minor
            Found in packages/mermaid/src/diagrams/block/layout.ts and 1 other location - About 35 mins to fix
            packages/mermaid/src/diagrams/block/layout.ts on lines 223..223

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 47.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status