knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/sequence/sequenceDb.js

Summary

Maintainability
F
3 days
Test Coverage

File sequenceDb.js has 562 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { getConfig } from '../../diagram-api/diagramAPI.js';
import { log } from '../../logger.js';
import { sanitizeText } from '../common/common.js';
import {
  clear as commonClear,
Severity: Major
Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 1 day to fix

    Function apply has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const apply = function (param) {
      if (Array.isArray(param)) {
        param.forEach(function (item) {
          apply(item);
        });
    Severity: Major
    Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 5 hrs to fix

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

      export const addActor = function (id, name, description, type) {
        let assignedBox = state.records.currentBox;
        const old = state.records.actors[id];
        if (old) {
          // If already set and trying to set to a new one throw error
      Severity: Minor
      Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 1 hr to fix

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

        export const parseBoxData = function (str) {
          const match = str.match(/^((?:rgba?|hsla?)\s*\(.*\)|\w*)(.*)$/);
          let color = match != null && match[1] ? match[1].trim() : 'transparent';
          let title = match != null && match[2] ? match[2].trim() : undefined;
        
        
        Severity: Minor
        Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                    if (
                      param.to !== state.records.lastDestroyed &&
                      param.from !== state.records.lastDestroyed
                    ) {
                      throw new Error(
          Severity: Major
          Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 45 mins to fix

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

              idFrom,
              idTo,
              message = { text: undefined, wrap: undefined },
              messageType,
              activate = false
            Severity: Minor
            Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js - About 35 mins to fix

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

              function insertLinks(actor, links) {
                if (actor.links == null) {
                  actor.links = links;
                } else {
                  for (let key in links) {
              Severity: Major
              Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js and 1 other location - About 1 hr to fix
              packages/mermaid/src/diagrams/sequence/sequenceDb.js on lines 406..414

              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 insertProperties(actor, properties) {
                if (actor.properties == null) {
                  actor.properties = properties;
                } else {
                  for (let key in properties) {
              Severity: Major
              Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js and 1 other location - About 1 hr to fix
              packages/mermaid/src/diagrams/sequence/sequenceDb.js on lines 378..386

              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

                  if (
                    state.records.messages[i].type === LINETYPE.ACTIVE_END &&
                    state.records.messages[i].from.actor === part
                  ) {
                    count--;
              Severity: Major
              Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js and 1 other location - About 1 hr to fix
              packages/mermaid/src/diagrams/sequence/sequenceDb.js on lines 101..106

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

              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 (
                    state.records.messages[i].type === LINETYPE.ACTIVE_START &&
                    state.records.messages[i].from.actor === part
                  ) {
                    count++;
              Severity: Major
              Found in packages/mermaid/src/diagrams/sequence/sequenceDb.js and 1 other location - About 1 hr to fix
              packages/mermaid/src/diagrams/sequence/sequenceDb.js on lines 107..112

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

              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