knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/c4/c4Renderer.js

Summary

Maintainability
F
5 days
Test Coverage

File c4Renderer.js has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { select } from 'd3';
import svgDraw from './svgDraw.js';
import { log } from '../../logger.js';
import { parser } from './parser/c4Diagram.jison';
import common from '../common/common.js';
Severity: Major
Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 1 day to fix

    Function drawInsideBoundary has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function drawInsideBoundary(
      diagram,
      parentBoundaryAlias,
      parentBounds,
      currentBoundaries,
    Severity: Major
    Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 3 hrs to fix

      Function drawC4ShapeArray has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const drawC4ShapeArray = function (currentBounds, diagram, c4ShapeArray, c4ShapeKeys) {
        // Upper Y is relative point
        let Y = 0;
        // Draw the c4ShapeArray
        for (const c4ShapeKey of c4ShapeKeys) {
      Severity: Major
      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 2 hrs to fix

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

        export const draw = function (_text, id, _version, diagObj) {
          conf = getConfig().c4;
          const securityLevel = getConfig().securityLevel;
          // Handle root and Document for when rendering in sandbox mode
          let sandboxElement;
        Severity: Major
        Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 2 hrs to fix

          Function getIntersectPoint has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          let getIntersectPoint = function (fromNode, endPoint) {
            let x1 = fromNode.x;
          
            let y1 = fromNode.y;
          
          
          Severity: Major
          Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 2 hrs to fix

            Function insert has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              insert(c4Shape) {
                this.nextData.cnt = this.nextData.cnt + 1;
                let _startx =
                  this.nextData.startx === this.nextData.stopx
                    ? this.nextData.stopx + c4Shape.margin
            Severity: Minor
            Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 1 hr to fix

              Function drawRels has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const drawRels = function (diagram, rels, getC4ShapeObj, diagObj) {
                let i = 0;
                for (let rel of rels) {
                  i = i + 1;
                  let relTextWrap = rel.wrap && conf.wrap;
              Severity: Minor
              Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                    if (fromDYX >= tanDYX) {
                      returnPoint = new Point(x1, fromCenterY - (fromNode.width / 2) * tanDYX);
                    } else {
                      returnPoint = new Point(fromCenterX - ((fromNode.height / 2) * dx) / dy, y1);
                    }
                Severity: Major
                Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 45 mins to fix

                  Function calcC4ShapeTextWH has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function calcC4ShapeTextWH(textType, c4Shape, c4ShapeTextWrap, textConf, textLimitWidth) {
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 35 mins to fix

                    Function drawInsideBoundary has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      diagram,
                      parentBoundaryAlias,
                      parentBounds,
                      currentBoundaries,
                      diagObj
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/c4/c4Renderer.js - About 35 mins to fix

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

                          if (c4Shape.type && c4Shape.type.text !== '') {
                            c4Shape.type.text = '[' + c4Shape.type.text + ']';
                            let c4ShapeTypeConf = c4ShapeFont(conf, c4Shape.typeC4Shape.text);
                            calcC4ShapeTextWH('type', c4Shape, c4ShapeTextWrap, c4ShapeTypeConf, textLimitWidth);
                            c4Shape['type'].Y = Y + 5;
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 3 hrs to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 270..276

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

                      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

                          } else if (c4Shape.techn && c4Shape.techn.text !== '') {
                            c4Shape.techn.text = '[' + c4Shape.techn.text + ']';
                            let c4ShapeTechnConf = c4ShapeFont(conf, c4Shape.techn.text);
                            calcC4ShapeTextWH('techn', c4Shape, c4ShapeTextWrap, c4ShapeTechnConf, textLimitWidth);
                            c4Shape['techn'].Y = Y + 5;
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 3 hrs to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 264..276

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

                      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 (c4Shape.sprite) {
                            c4Shape.image.width = 48;
                            c4Shape.image.height = 48;
                            c4Shape.image.Y = Y;
                            Y = c4Shape.image.Y + c4Shape.image.height;
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 2 hrs to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 466..471

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

                      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 (currentBoundary.sprite) {
                            currentBoundary.image.width = 48;
                            currentBoundary.image.height = 48;
                            currentBoundary.image.Y = Y;
                            Y = currentBoundary.image.Y + currentBoundary.image.height;
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 2 hrs to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 245..250

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

                      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 (rel.techn && rel.techn.text !== '') {
                            textLimitWidth = calculateTextWidth(rel.techn.text, relConf);
                            calcC4ShapeTextWH('techn', rel, relTextWrap, relConf, textLimitWidth);
                          }
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 1 hr to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 427..430

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

                      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 (rel.descr && rel.descr.text !== '') {
                            textLimitWidth = calculateTextWidth(rel.descr.text, relConf);
                            calcC4ShapeTextWH('descr', rel, relTextWrap, relConf, textLimitWidth);
                          }
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 1 hr to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 422..425

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

                      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

                      const c4ShapeFont = (cnf, typeC4Shape) => {
                        return {
                          fontFamily: cnf[typeC4Shape + 'FontFamily'],
                          fontSize: cnf[typeC4Shape + 'FontSize'],
                          fontWeight: cnf[typeC4Shape + 'FontWeight'],
                      Severity: Major
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 1 hr to fix
                      packages/mermaid/src/diagrams/c4/svgDraw.js on lines 557..563

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

                      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

                          parentBounds.data.stopy = Math.max(
                            currentBounds.data.stopy + conf.c4ShapeMargin,
                            parentBounds.data.stopy
                          );
                      Severity: Minor
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 40 mins to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 565..568

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

                      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

                          parentBounds.data.stopx = Math.max(
                            currentBounds.data.stopx + conf.c4ShapeMargin,
                            parentBounds.data.stopx
                          );
                      Severity: Minor
                      Found in packages/mermaid/src/diagrams/c4/c4Renderer.js and 1 other location - About 40 mins to fix
                      packages/mermaid/src/diagrams/c4/c4Renderer.js on lines 561..564

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

                      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