knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/requirement/requirementRenderer.js

Summary

Maintainability
D
2 days
Test Coverage

File requirementRenderer.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { line, select } from 'd3';
import { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
import { log } from '../../logger.js';
import { configureSvgSize } from '../../setupGraphViewbox.js';
Severity: Minor
Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 3 hrs to fix

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

    export const draw = (text, id, _version, diagObj) => {
      conf = getConfig().requirement;
    
      const securityLevel = conf.securityLevel;
      // Handle root and Document for when rendering in sandbox mode
    Severity: Minor
    Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 1 hr to fix

      Function newTitleNode has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const newTitleNode = (parentNode, id, txts) => {
        let x = conf.rect_min_width / 2;
      
        let title = parentNode
          .append('text')
      Severity: Minor
      Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 1 hr to fix

        Function drawReqs has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const drawReqs = (reqs, graph, svgNode) => {
          Object.keys(reqs).forEach((reqName) => {
            let req = reqs[reqName];
            reqName = elementString(reqName);
            log.info('Added new requirement: ', reqName);
        Severity: Minor
        Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 1 hr to fix

          Function drawRelationshipFromLayout has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
            // Find the edge relating to this relationship
            const edge = g.edge(elementString(rel.src), elementString(rel.dst));
          
            // Get a function that will generate the line path
          Severity: Minor
          Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 1 hr to fix

            Function newBodyNode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const newBodyNode = (parentNode, id, txts, yStart) => {
              let body = parentNode
                .append('text')
                .attr('class', 'req reqLabel')
                .attr('id', id)
            Severity: Minor
            Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 1 hr to fix

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

              const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) {
              Severity: Minor
              Found in packages/mermaid/src/diagrams/requirement/requirementRenderer.js - About 35 mins to fix

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

                      svgNode
                        .select('#' + v)
                        .attr(
                          'transform',
                          'translate(' +
                packages/mermaid/src/diagrams/er/erRenderer.js on lines 362..371

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

                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 g = new graphlib.Graph({
                    multigraph: false,
                    compound: false,
                    directed: true,
                  })
                packages/mermaid/src/diagrams/er/erRenderer.js on lines 598..613

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

                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

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

                  svg.attr('viewBox', `${svgBounds.x - padding} ${svgBounds.y - padding} ${width} ${height}`);
                packages/mermaid/src/diagrams/er/erRenderer.js on lines 644..644

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

                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 body = parentNode
                    .append('text')
                    .attr('class', 'req reqLabel')
                    .attr('id', id)
                    .attr('x', conf.rect_padding)
                packages/mermaid/src/diagrams/requirement/requirementRenderer.js on lines 125..130

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

                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 labelNode = parentNode
                    .append('text')
                    .attr('class', 'req relationshipLabel')
                    .attr('id', labelId)
                    .attr('x', labelPoint.x)
                packages/mermaid/src/diagrams/requirement/requirementRenderer.js on lines 76..81

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

                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