knsv/mermaid

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

Summary

Maintainability
F
5 days
Test Coverage

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

    Function parseData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const parseData = function (prevTaskId, dataStr) {
      let ds;
      if (dataStr.substr(0, 1) === ':') {
        ds = dataStr.substr(1, dataStr.length);
      } else {
    Severity: Minor
    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

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

      const compileTasks = function () {
        const compileTask = function (pos) {
          const task = rawTasks[pos];
          let startTime = '';
          switch (rawTasks[pos].raw.startTime.type) {
      Severity: Minor
      Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

        Function compileData has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const compileData = function (prevTask, dataStr) {
          let ds;
        
          if (dataStr.substr(0, 1) === ':') {
            ds = dataStr.substr(1, dataStr.length);
        Severity: Minor
        Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

          Function getStartDate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const getStartDate = function (prevTime, dateFormat, str) {
            str = str.trim();
          
            // Test for after
            const afterRePattern = /^after\s+(?<ids>[\d\w- ]+)/;
          Severity: Minor
          Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

            Function getEndDate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getEndDate = function (prevTime, dateFormat, str, inclusive = false) {
              str = str.trim();
            
              // test for until
              const untilRePattern = /^until\s+(?<ids>[\d\w- ]+)/;
            Severity: Minor
            Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

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

                const compileTask = function (pos) {
                  const task = rawTasks[pos];
                  let startTime = '';
                  switch (rawTasks[pos].raw.startTime.type) {
                    case 'prevTaskEnd': {
              Severity: Minor
              Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

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

                const setClickFun = function (id, functionName, functionArgs) {
                  if (getConfig().securityLevel !== 'loose') {
                    return;
                  }
                  if (functionName === undefined) {
                Severity: Minor
                Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 1 hr to fix

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

                  const fixTaskDates = function (startTime, endTime, dateFormat, excludes, includes) {
                  Severity: Minor
                  Found in packages/mermaid/src/diagrams/gantt/ganttDb.js - About 35 mins to fix

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

                      if (typeof functionArgs === 'string') {
                        /* Splits functionArgs by ',', ignoring all ',' in double quoted strings */
                        argList = functionArgs.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
                        for (let i = 0; i < argList.length; i++) {
                          let item = argList[i].trim();
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 6 hrs to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 307..319

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

                    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 (afterStatement !== null) {
                        // check all after ids and take the latest
                        let latestTask = null;
                        for (const id of afterStatement.groups.ids.split(' ')) {
                          let task = findTaskById(id);
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 5 hrs to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 344..360

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

                    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 (untilStatement !== null) {
                        // check all until ids and take the earliest
                        let earliestTask = null;
                        for (const id of untilStatement.groups.ids.split(' ')) {
                          let task = findTaskById(id);
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 5 hrs to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 262..278

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

                    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

                        function () {
                          // const elem = d3.select(element).select(`[id="${id}"]`)
                          const elem = document.querySelector(`[id="${id}"]`);
                          if (elem !== null) {
                            elem.addEventListener('click', function () {
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 706..714

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

                    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

                        function () {
                          // const elem = d3.select(element).select(`[id="${id}-text"]`)
                          const elem = document.querySelector(`[id="${id}-text"]`);
                          if (elem !== null) {
                            elem.addEventListener('click', function () {
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 697..705

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

                    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 setClickEvent = function (ids, functionName, functionArgs) {
                      ids.split(',').forEach(function (id) {
                        setClickFun(id, functionName, functionArgs);
                      });
                      setClass(ids, 'clickable');
                    Severity: Major
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 1 hr to fix
                    packages/mermaid/src/diagrams/flowchart/flowDb.js on lines 373..378

                    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

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

                      if (dataStr.substr(0, 1) === ':') {
                        ds = dataStr.substr(1, dataStr.length);
                      } else {
                        ds = dataStr;
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 50 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 404..408

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

                    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 (dataStr.substr(0, 1) === ':') {
                        ds = dataStr.substr(1, dataStr.length);
                      } else {
                        ds = dataStr;
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 50 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 452..456

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

                    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 (task.startTime instanceof Date) {
                        startTime = dayjs(task.startTime);
                      } else {
                        startTime = dayjs(task.startTime, dateFormat, true);
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 50 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 212..216

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

                    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 (task.endTime instanceof Date) {
                        originalEndTime = dayjs(task.endTime);
                      } else {
                        originalEndTime = dayjs(task.endTime, dateFormat, true);
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 50 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 204..208

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

                    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 (let i = 0; i < data.length; i++) {
                        data[i] = data[i].trim();
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 40 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 417..419

                    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

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

                      for (let i = 0; i < data.length; i++) {
                        data[i] = data[i].trim();
                      }
                    Severity: Minor
                    Found in packages/mermaid/src/diagrams/gantt/ganttDb.js and 1 other location - About 40 mins to fix
                    packages/mermaid/src/diagrams/gantt/ganttDb.js on lines 465..467

                    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

                    There are no issues that match your filters.

                    Category
                    Status