knsv/mermaid

View on GitHub
packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js

Summary

Maintainability
D
2 days
Test Coverage

File mermaid-graphlib.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/** Decorates with functions required by mermaids dagre-wrapper. */
import { log } from '../logger.js';
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';

Severity: Minor
Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js - About 5 hrs to fix

    Function adjustClustersAndEdges has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const adjustClustersAndEdges = (graph, depth) => {
      if (!graph || depth > 10) {
        log.debug('Opting out, no graph ');
        return;
      } else {
    Severity: Major
    Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js - About 4 hrs to fix

      Function extractor has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const extractor = (graph, depth) => {
        log.warn('extractor - ', depth, graphlibJson.write(graph), graph.children('D'));
        if (depth > 10) {
          log.error('Bailing out');
          return;
      Severity: Major
      Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js - About 3 hrs to fix

        Function copy has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const copy = (clusterId, graph, newGraph, rootId) => {
          log.warn(
            'Copying children of ',
            clusterId,
            'root',
        Severity: Major
        Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js - About 2 hrs to fix

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

                if (w !== e.w) {
                  const parent = graph.parent(w);
                  clusterDb[parent].externalConnections = true;
                  edge.toCluster = e.w;
                }
          Severity: Major
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 1 other location - About 1 hr to fix
          packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js on lines 320..324

          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

                if (v !== e.v) {
                  const parent = graph.parent(v);
                  clusterDb[parent].externalConnections = true;
                  edge.fromCluster = e.v;
                }
          Severity: Major
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 1 other location - About 1 hr to fix
          packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js on lines 325..329

          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 3 locations. Consider refactoring.
          Open

              log.warn('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(graph.edge(e)));
          Severity: Major
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 2 other locations - About 1 hr to fix
          packages/mermaid/src/diagrams/class/classRenderer.js on lines 258..258
          packages/mermaid/src/diagrams/state/stateRenderer.js on lines 273..273

          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 55.

          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 3 locations. Consider refactoring.
          Open

              log.warn('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(e));
          Severity: Minor
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 2 other locations - About 35 mins to fix
          packages/mermaid/src/dagre-wrapper/index.js on lines 94..94
          packages/mermaid/src/dagre-wrapper/index.js on lines 103..103

          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

              if (graph.children(edge.w).length > 0) {
                log.trace('The node ', edge.w, ' is part of and edge even though it has children');
                return false;
              }
          Severity: Minor
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 1 other location - About 35 mins to fix
          packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js on lines 151..154

          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

              if (graph.children(edge.v).length > 0) {
                log.trace('The node ', edge.v, ' is part of and edge even though it has children');
                return false;
              }
          Severity: Minor
          Found in packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js and 1 other location - About 35 mins to fix
          packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js on lines 155..158

          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