knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/timeline/svgDraw.js

Summary

Maintainability
F
2 wks
Test Coverage

File svgDraw.js has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { arc as d3arc, select } from 'd3';
const MAX_SECTIONS = 12;

export const drawRect = function (elem, rectData) {
  const rectElem = elem.append('rect');
Severity: Minor
Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 7 hrs to fix

    Function drawFace has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const drawFace = function (element, faceData) {
      const radius = 15;
      const circleElement = element
        .append('circle')
        .attr('cx', faceData.cx)
    Severity: Major
    Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 2 hrs to fix

      Function _drawTextCandidateFunc has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const _drawTextCandidateFunc = (function () {
        /**
         * @param {any} content
         * @param {any} g
         * @param {any} x
      Severity: Major
      Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 2 hrs to fix

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

        export const drawTask = function (elem, task, conf) {
          const center = task.x + conf.width / 2;
          const g = elem.append('g');
          taskCount++;
          const maxHeight = 300 + 5 * 30;
        Severity: Minor
        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

          Function wrap has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function wrap(text, width) {
            text.each(function () {
              var text = select(this),
                words = text
                  .text()
          Severity: Minor
          Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

            Function drawLabel has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const drawLabel = function (elem, txtObject) {
              /**
               * @param {any} x
               * @param {any} y
               * @param {any} width
            Severity: Minor
            Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

              Function byTspan has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) {
              Severity: Major
              Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

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

                export const drawNode = function (elem, node, fullSection, conf) {
                  const section = (fullSection % MAX_SECTIONS) - 1;
                  const nodeElem = elem.append('g');
                  node.section = section;
                  nodeElem.attr(
                Severity: Minor
                Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

                  Function byText has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function byText(content, g, x, y, width, height, textAttrs, colour) {
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

                    Function byFo has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function byFo(content, g, x, y, width, height, textAttrs, conf) {
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 1 hr to fix

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

                        function genPoints(x, y, width, height, cut) {
                      Severity: Minor
                      Found in packages/mermaid/src/diagrams/timeline/svgDraw.js - About 35 mins to fix

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

                        export const drawFace = function (element, faceData) {
                          const radius = 15;
                          const circleElement = element
                            .append('circle')
                            .attr('cx', faceData.cx)
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 4 days to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 8..95

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

                        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 _drawTextCandidateFunc = (function () {
                          /**
                           * @param {any} content
                           * @param {any} g
                           * @param {any} x
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 4 days to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 273..389

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

                        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/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

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

                        export const drawCircle = function (element, circleData) {
                          const circleElement = element.append('circle');
                          circleElement.attr('cx', circleData.cx);
                          circleElement.attr('cy', circleData.cy);
                          circleElement.attr('class', 'actor-' + circleData.pos);
                        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 97..115

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

                        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

                        const initGraphics = function (graphics) {
                          graphics
                            .append('defs')
                            .append('marker')
                            .attr('id', 'arrowhead')
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 3 hrs to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 391..403

                        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

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

                          g.append('line')
                            .attr('id', 'task' + taskCount)
                            .attr('x1', center)
                            .attr('y1', task.y)
                            .attr('x2', center)
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 3 hrs to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 204..213

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

                        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

                          const txt = textElem
                            .append('text')
                            .text(node.descr)
                            .attr('dy', '1em')
                            .attr('alignment-baseline', 'middle')
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 2 hrs to fix
                        packages/mermaid/src/diagrams/timeline/svgDraw.js on lines 527..534

                        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

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

                          const txt = textElem
                            .append('text')
                            .text(node.descr)
                            .attr('dy', '1em')
                            .attr('alignment-baseline', 'middle')
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 2 hrs to fix
                        packages/mermaid/src/diagrams/timeline/svgDraw.js on lines 552..559

                        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

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

                          _drawTextCandidateFunc(conf)(
                            section.text,
                            g,
                            rect.x,
                            rect.y,
                        Severity: Major
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 1 hr to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 178..188

                        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

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

                          _drawTextCandidateFunc(conf)(
                            task.task,
                            g,
                            rect.x,
                            rect.y,
                        Severity: Minor
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 40 mins to fix
                        packages/mermaid/src/diagrams/user-journey/svgDraw.js on lines 250..260

                        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

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

                          const fontSize =
                            conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace('px', '') : conf.fontSize;
                        Severity: Minor
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 35 mins to fix
                        packages/mermaid/src/diagrams/timeline/svgDraw.js on lines 561..562

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

                        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

                          const fontSize =
                            conf.fontSize && conf.fontSize.replace ? conf.fontSize.replace('px', '') : conf.fontSize;
                        Severity: Minor
                        Found in packages/mermaid/src/diagrams/timeline/svgDraw.js and 1 other location - About 35 mins to fix
                        packages/mermaid/src/diagrams/timeline/svgDraw.js on lines 536..537

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

                        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