knsv/mermaid

View on GitHub

Showing 1,488 of 1,488 total issues

File flowRenderer-elk.js has 668 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { select, line, curveLinear } from 'd3';
import { insertNode } from '../../../dagre-wrapper/nodes.js';
import insertMarkers from '../../../dagre-wrapper/markers.js';
import { insertEdgeLabel } from '../../../dagre-wrapper/edges.js';
import { findCommonAncestor } from './render-utils.js';
Severity: Major
Found in packages/mermaid/src/diagrams/flowchart/elk/flowRenderer-elk.js - About 1 day to fix

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

      switch (rel.relSpec.cardA) {
        case diagObj.db.Cardinality.ZERO_OR_ONE:
          svgPath.attr('marker-end', 'url(' + url + '#' + erMarkers.ERMarkers.ZERO_OR_ONE_END + ')');
          break;
        case diagObj.db.Cardinality.ZERO_OR_MORE:
    Severity: Major
    Found in packages/mermaid/src/diagrams/er/erRenderer.js and 1 other location - About 1 day to fix
    packages/mermaid/src/diagrams/er/erRenderer.js on lines 486..511

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

    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

      switch (rel.relSpec.cardB) {
        case diagObj.db.Cardinality.ZERO_OR_ONE:
          svgPath.attr(
            'marker-start',
            'url(' + url + '#' + erMarkers.ERMarkers.ZERO_OR_ONE_START + ')'
    Severity: Major
    Found in packages/mermaid/src/diagrams/er/erRenderer.js and 1 other location - About 1 day to fix
    packages/mermaid/src/diagrams/er/erRenderer.js on lines 468..484

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

    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

    File ganttRenderer.js has 634 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import dayjs from 'dayjs';
    import { log } from '../../logger.js';
    import {
      select,
      scaleTime,
    Severity: Major
    Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 1 day to fix

      File gantt.spec.js has 633 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
      
      describe('Gantt diagram', () => {
        beforeEach(() => {
          cy.clock(new Date('1010-10-10').getTime());
      Severity: Major
      Found in cypress/integration/rendering/gantt.spec.js - About 1 day to fix

        File mermaidAPI.spec.ts has 633 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        import { vi } from 'vitest';
        
        // -------------------------------------
        //  Mocks and mocking
        Severity: Major
        Found in packages/mermaid/src/mermaidAPI.spec.ts - About 1 day to fix

          File utils.ts has 629 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { sanitizeUrl } from '@braintree/sanitize-url';
          import type { CurveFactory } from 'd3';
          import {
            curveBasis,
            curveBasisClosed,
          Severity: Major
          Found in packages/mermaid/src/utils.ts - About 1 day to fix

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

            export const drawLabel = function (elem, txtObject) {
              /**
               * @param {any} x
               * @param {any} y
               * @param {any} width
            Severity: Major
            Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 1 day to fix
            packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 121..159

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

            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

            export const drawLabel = function (elem, txtObject) {
              /**
               * @param {any} x
               * @param {any} y
               * @param {any} width
            Severity: Major
            Found in packages/mermaid/src/diagrams/user-journey/svgDraw.js and 1 other location - About 1 day to fix
            packages/mermaid/src/diagrams/timeline/svgDraw.js on lines 153..191

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

            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

            File flowDb.js has 618 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { select } from 'd3';
            import utils from '../../utils.js';
            import { getConfig, defaultConfig } from '../../diagram-api/diagramAPI.js';
            import common from '../common/common.js';
            import { log } from '../../logger.js';
            Severity: Major
            Found in packages/mermaid/src/diagrams/flowchart/flowDb.js - About 1 day to fix

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

                    if (node) {
                      const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.classes.join(' '));
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'href', vertex.link);
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');
              Severity: Major
              Found in packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js and 1 other location - About 1 day to fix
              packages/mermaid/src/diagrams/flowchart/flowRenderer.js on lines 471..499

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

              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

                    if (node) {
                      const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.classes.join(' '));
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'href', vertex.link);
                      link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');
              Severity: Major
              Found in packages/mermaid/src/diagrams/flowchart/flowRenderer.js and 1 other location - About 1 day to fix
              packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js on lines 472..500

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

              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 (edge.endLabelRight) {
                  // Create the actual text element
                  const endLabelElement = createLabel(edge.endLabelRight, edge.labelStyle);
                  const endEdgeLabelRight = elem.insert('g').attr('class', 'edgeTerminals');
                  const inner = endEdgeLabelRight.insert('g').attr('class', 'inner');
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 1 other location - About 1 day to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 88..104

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

              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 (edge.endLabelLeft) {
                  // Create the actual text element
                  const endLabelElement = createLabel(edge.endLabelLeft, edge.labelStyle);
                  const endEdgeLabelLeft = elem.insert('g').attr('class', 'edgeTerminals');
                  const inner = endEdgeLabelLeft.insert('g').attr('class', 'inner');
              Severity: Major
              Found in packages/mermaid/src/dagre-wrapper/edges.js and 1 other location - About 1 day to fix
              packages/mermaid/src/dagre-wrapper/edges.js on lines 105..121

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

              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

                  it('should add bracket members in right order', () => {
                    const str =
                      'classDiagram\n' +
                      'class Class1 {\n' +
                      'int testMember\n' +
              Severity: Major
              Found in packages/mermaid/src/diagrams/class/classDiagram.spec.ts and 1 other location - About 1 day to fix
              packages/mermaid/src/diagrams/class/classDiagram.spec.ts on lines 1319..1337

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

              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

                  it('should add bracket members in right order', function () {
                    const str =
                      'classDiagram\n' +
                      'class Class1 {\n' +
                      'int : test\n' +
              Severity: Major
              Found in packages/mermaid/src/diagrams/class/classDiagram.spec.ts and 1 other location - About 1 day to fix
              packages/mermaid/src/diagrams/class/classDiagram.spec.ts on lines 492..510

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

              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

              File ganttDb.js has 606 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { sanitizeUrl } from '@braintree/sanitize-url';
              import dayjs from 'dayjs';
              import dayjsIsoWeek from 'dayjs/plugin/isoWeek.js';
              import dayjsCustomParseFormat from 'dayjs/plugin/customParseFormat.js';
              import dayjsAdvancedFormat from 'dayjs/plugin/advancedFormat.js';
              Severity: Major
              Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 day to fix

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

                const dependency = (elem, type, id) => {
                  elem
                    .append('defs')
                    .append('marker')
                    .attr('id', id + '_' + type + '-dependencyStart')
                Severity: Major
                Found in packages/mermaid/src/dagre-wrapper/markers.js and 2 other locations - About 1 day to fix
                packages/mermaid/src/dagre-wrapper/markers.js on lines 41..67
                packages/mermaid/src/dagre-wrapper/markers.js on lines 68..94

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

                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

                const composition = (elem, type, id) => {
                  elem
                    .append('defs')
                    .append('marker')
                    .attr('id', id + '_' + type + '-compositionStart')
                Severity: Major
                Found in packages/mermaid/src/dagre-wrapper/markers.js and 2 other locations - About 1 day to fix
                packages/mermaid/src/dagre-wrapper/markers.js on lines 68..94
                packages/mermaid/src/dagre-wrapper/markers.js on lines 95..121

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

                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

                const aggregation = (elem, type, id) => {
                  elem
                    .append('defs')
                    .append('marker')
                    .attr('id', id + '_' + type + '-aggregationStart')
                Severity: Major
                Found in packages/mermaid/src/dagre-wrapper/markers.js and 2 other locations - About 1 day to fix
                packages/mermaid/src/dagre-wrapper/markers.js on lines 41..67
                packages/mermaid/src/dagre-wrapper/markers.js on lines 95..121

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

                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

                Severity
                Category
                Status
                Source
                Language