knsv/mermaid

View on GitHub
packages/mermaid/src/diagrams/git/gitGraphAst.js

Summary

Maintainability
F
4 days
Test Coverage

File gitGraphAst.js has 431 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { log } from '../../logger.js';
import { random } from '../../utils.js';
import { getConfig } from '../../diagram-api/diagramAPI.js';
import common from '../common/common.js';
import {
Severity: Minor
Found in packages/mermaid/src/diagrams/git/gitGraphAst.js - About 6 hrs to fix

    Function merge has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const merge = function (otherBranch, custom_id, override_type, custom_tag) {
      otherBranch = common.sanitizeText(otherBranch, getConfig());
      custom_id = common.sanitizeText(custom_id, getConfig());
    
      const currentCommit = commits[branches[curBranch]];
    Severity: Major
    Found in packages/mermaid/src/diagrams/git/gitGraphAst.js - About 3 hrs to fix

      Function cherryPick has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const cherryPick = function (sourceId, targetId, tag, parentCommitId) {
        log.debug('Entering cherryPick:', sourceId, targetId, tag);
        sourceId = common.sanitizeText(sourceId, getConfig());
        targetId = common.sanitizeText(targetId, getConfig());
        tag = common.sanitizeText(tag, getConfig());
      Severity: Major
      Found in packages/mermaid/src/diagrams/git/gitGraphAst.js - About 3 hrs to fix

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

        function prettyPrintCommitHistory(commitArr) {
          const commit = commitArr.reduce((out, commit) => {
            if (out.seq > commit.seq) {
              return out;
            }
        Severity: Minor
        Found in packages/mermaid/src/diagrams/git/gitGraphAst.js - About 1 hr to fix

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

              if (sourceCommitBranch === curBranch) {
                let error = new Error(
                  'Incorrect usage of "cherryPick". Source commit is already on current branch'
                );
                error.hash = {
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 3 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 265..277

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

          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 (!sourceId || commits[sourceId] === undefined) {
              let error = new Error(
                'Incorrect usage of "cherryPick". Source commit id should exist and provided'
              );
              error.hash = {
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 3 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 298..310

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

          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

            } else if (currentCommit === undefined || !currentCommit) {
              let error = new Error(
                'Incorrect usage of "merge". Current branch (' + curBranch + ')has no commits'
              );
              error.hash = {
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 190..229

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

          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

            } else if (otherCommit === undefined || !otherCommit) {
              let error = new Error(
                'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') has no commits'
              );
              error.hash = {
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 166..229

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

          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

            } else if (currentCommit === otherCommit) {
              let error = new Error('Incorrect usage of "merge". Both branches have same head');
              error.hash = {
                text: 'merge ' + otherBranch,
                token: 'merge ' + otherBranch,
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 156..229

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

          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 (curBranch === otherBranch) {
              let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
              error.hash = {
                text: 'merge ' + otherBranch,
                token: 'merge ' + otherBranch,
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 202..229

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

          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

              error.hash = {
                text: 'checkout ' + branch,
                token: 'checkout ' + branch,
                line: '1',
                loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 139..145

          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

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

              error.hash = {
                text: 'branch ' + name,
                token: 'branch ' + name,
                line: '1',
                loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
          Severity: Major
          Found in packages/mermaid/src/diagrams/git/gitGraphAst.js and 1 other location - About 2 hrs to fix
          packages/mermaid/src/diagrams/git/gitGraphAst.js on lines 351..357

          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

          There are no issues that match your filters.

          Category
          Status