knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/gantt/ganttRenderer.js

Summary

Maintainability
F
1 wk
Test Coverage

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

export const draw = function (text, id, version, diagObj) {
  const conf = getConfig().gantt;

  const securityLevel = getConfig().securityLevel;
  // Handle root and Document for when rendering in sandbox mode
Severity: Major
Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 2 days to fix

    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

      Function drawRects has 221 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w) {
          // Get unique task orders. Required to draw the background rects when display mode is compact.
          const uniqueTaskOrderIds = [...new Set(theArray.map((item) => item.order))];
          const uniqueTasks = uniqueTaskOrderIds.map((id) => theArray.find((item) => item.order === id));
      
      
      Severity: Major
      Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 1 day to fix

        Function makeGrid has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function makeGrid(theSidePad, theTopPad, w, h) {
            let bottomXAxis = axisBottom(timeScale)
              .tickSize(-h + theTopPad + conf.gridLineStartPadding)
              .tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
        
        
        Severity: Major
        Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 3 hrs to fix

          Function drawExcludeDays has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function drawExcludeDays(theGap, theTopPad, theSidePad, w, h, tasks, excludes, includes) {
              if (excludes.length === 0 && includes.length === 0) {
                return;
              }
          
          
          Severity: Major
          Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 2 hrs to fix

            Function vertLabels has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function vertLabels(theGap, theTopPad) {
                let prevGap = 0;
            
                const numOccurrences = Object.keys(categoryHeights).map((d) => [d, categoryHeights[d]]);
            
            
            Severity: Minor
            Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 1 hr to fix

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

                function drawExcludeDays(theGap, theTopPad, theSidePad, w, h, tasks, excludes, includes) {
              Severity: Major
              Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 1 hr to fix

                Function drawRects has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w) {
                Severity: Major
                Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js - About 50 mins to fix

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

                        if (resultTickInterval !== null) {
                          const every = resultTickInterval[1];
                          const interval = resultTickInterval[2];
                          const weekday = diagObj.db.getWeekday() || conf.weekday;
                  
                  
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 1 day to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 600..628

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

                  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 (resultTickInterval !== null) {
                        const every = resultTickInterval[1];
                        const interval = resultTickInterval[2];
                        const weekday = diagObj.db.getWeekday() || conf.weekday;
                  
                  
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 1 day to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 647..675

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

                  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 bottomXAxis = axisBottom(timeScale)
                        .tickSize(-h + theTopPad + conf.gridLineStartPadding)
                        .tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 1 hr to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 643..645

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

                  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 topXAxis = axisTop(timeScale)
                          .tickSize(-h + theTopPad + conf.gridLineStartPadding)
                          .tickFormat(timeFormat(diagObj.db.getAxisFormat() || conf.axisFormat || '%Y-%m-%d'));
                  Severity: Major
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 1 hr to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 591..593

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

                  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

                          for (const [i, category] of categories.entries()) {
                            if (d.type === category) {
                              secNum = i % conf.numberSectionStyles;
                            }
                          }
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 55 mins to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 325..329

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 53.

                  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

                          for (const [i, category] of categories.entries()) {
                            if (d.type === category) {
                              secNum = i % conf.numberSectionStyles;
                            }
                          }
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 55 mins to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 417..421

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

                  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

                            (
                              timeScale(d.startTime) +
                              theSidePad +
                              0.5 * (timeScale(d.endTime) - timeScale(d.startTime))
                            ).toString() +
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 55 mins to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 571..577

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

                  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

                            (
                              timeScale(d.start) +
                              theSidePad +
                              0.5 * (timeScale(d.end) - timeScale(d.start))
                            ).toString() +
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/gantt/ganttRenderer.js and 1 other location - About 55 mins to fix
                  packages/mermaid/src/diagrams/gantt/ganttRenderer.js on lines 306..312

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

                  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