knsv/mermaid

View on GitHub
packages/mermaid/src/themes/theme-default.js

Summary

Maintainability
F
1 wk
Test Coverage

Function updateColors has 201 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  updateColors() {
    /* Color Scale */
    /* Each color-set will have a background, a foreground and a border color */

    this.cScale0 = this.cScale0 || this.primaryColor;
Severity: Major
Found in packages/mermaid/src/themes/theme-default.js - About 1 day to fix

    File theme-default.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { invert, lighten, rgba, adjust, darken, isDark } from 'khroma';
    import { mkBorder } from './theme-helpers.js';
    import {
      oldAttributeBackgroundColorEven,
      oldAttributeBackgroundColorOdd,
    Severity: Minor
    Found in packages/mermaid/src/themes/theme-default.js - About 3 hrs to fix

      Function constructor has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor() {
          /* Base variables */
          this.background = '#f4f4f4';
          this.primaryColor = '#ECECFF';
      
      
      Severity: Major
      Found in packages/mermaid/src/themes/theme-default.js - About 3 hrs to fix

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

            if (this.darkMode) {
              this.git0 = lighten(this.git0, 25);
              this.git1 = lighten(this.git1, 25);
              this.git2 = lighten(this.git2, 25);
              this.git3 = lighten(this.git3, 25);
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 2 other locations - About 1 day to fix
        packages/mermaid/src/themes/theme-base.js on lines 285..303
        packages/mermaid/src/themes/theme-forest.js on lines 278..296

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

        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 5 locations. Consider refactoring.
        Open

            this.xyChart = {
              backgroundColor: this.xyChart?.backgroundColor || this.background,
              titleColor: this.xyChart?.titleColor || this.primaryTextColor,
              xAxisTitleColor: this.xyChart?.xAxisTitleColor || this.primaryTextColor,
              xAxisLabelColor: this.xyChart?.xAxisLabelColor || this.primaryTextColor,
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 4 other locations - About 1 day to fix
        packages/mermaid/src/themes/theme-base.js on lines 249..263
        packages/mermaid/src/themes/theme-dark.js on lines 255..269
        packages/mermaid/src/themes/theme-forest.js on lines 244..258
        packages/mermaid/src/themes/theme-neutral.js on lines 275..289

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

        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 5 locations. Consider refactoring.
        Open

          calculate(overrides) {
            if (typeof overrides !== 'object') {
              // Calculate colors form base colors
              this.updateColors();
              return;
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 4 other locations - About 5 hrs to fix
        packages/mermaid/src/themes/theme-base.js on lines 340..360
        packages/mermaid/src/themes/theme-dark.js on lines 328..348
        packages/mermaid/src/themes/theme-forest.js on lines 331..351
        packages/mermaid/src/themes/theme-neutral.js on lines 346..366

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

        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 < this.THEME_COLOR_LIMIT; i++) {
              // Setup the peer color for the set, useful for borders
              this['cScale' + i] = darken(this['cScale' + i], 10);
              this['cScalePeer' + i] = this['cScalePeer' + i] || darken(this['cScale' + i], 25);
            }
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 1 other location - About 3 hrs to fix
        packages/mermaid/src/themes/theme-forest.js on lines 120..124

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

        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 4 locations. Consider refactoring.
        Open

              for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
                this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.labelTextColor;
              }
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 3 other locations - About 1 hr to fix
        packages/mermaid/src/themes/theme-base.js on lines 171..173
        packages/mermaid/src/themes/theme-forest.js on lines 137..139
        packages/mermaid/src/themes/theme-neutral.js on lines 161..163

        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

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

              this['surfacePeer' + i] =
                this['surfacePeer' + i] || adjust(this.mainBkg, { h: 30, l: -(7 + i * 5) });
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 1 other location - About 1 hr to fix
        packages/mermaid/src/themes/theme-default.js on lines 150..150

        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

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

              this['surface' + i] = this['surface' + i] || adjust(this.mainBkg, { h: 30, l: -(5 + i * 5) });
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 1 other location - About 1 hr to fix
        packages/mermaid/src/themes/theme-default.js on lines 151..152

        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

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

            this.quadrant2TextFill =
              this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 });
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 14 other locations - About 45 mins to fix
        packages/mermaid/src/themes/theme-base.js on lines 229..230
        packages/mermaid/src/themes/theme-base.js on lines 231..232
        packages/mermaid/src/themes/theme-base.js on lines 233..234
        packages/mermaid/src/themes/theme-dark.js on lines 235..236
        packages/mermaid/src/themes/theme-dark.js on lines 237..238
        packages/mermaid/src/themes/theme-dark.js on lines 239..240
        packages/mermaid/src/themes/theme-default.js on lines 258..259
        packages/mermaid/src/themes/theme-default.js on lines 260..261
        packages/mermaid/src/themes/theme-forest.js on lines 224..225
        packages/mermaid/src/themes/theme-forest.js on lines 226..227
        packages/mermaid/src/themes/theme-forest.js on lines 228..229
        packages/mermaid/src/themes/theme-neutral.js on lines 255..256
        packages/mermaid/src/themes/theme-neutral.js on lines 257..258
        packages/mermaid/src/themes/theme-neutral.js on lines 259..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 50.

        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 15 locations. Consider refactoring.
        Open

            this.quadrant3TextFill =
              this.quadrant3TextFill || adjust(this.primaryTextColor, { r: -10, g: -10, b: -10 });
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 14 other locations - About 45 mins to fix
        packages/mermaid/src/themes/theme-base.js on lines 229..230
        packages/mermaid/src/themes/theme-base.js on lines 231..232
        packages/mermaid/src/themes/theme-base.js on lines 233..234
        packages/mermaid/src/themes/theme-dark.js on lines 235..236
        packages/mermaid/src/themes/theme-dark.js on lines 237..238
        packages/mermaid/src/themes/theme-dark.js on lines 239..240
        packages/mermaid/src/themes/theme-default.js on lines 256..257
        packages/mermaid/src/themes/theme-default.js on lines 260..261
        packages/mermaid/src/themes/theme-forest.js on lines 224..225
        packages/mermaid/src/themes/theme-forest.js on lines 226..227
        packages/mermaid/src/themes/theme-forest.js on lines 228..229
        packages/mermaid/src/themes/theme-neutral.js on lines 255..256
        packages/mermaid/src/themes/theme-neutral.js on lines 257..258
        packages/mermaid/src/themes/theme-neutral.js on lines 259..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 50.

        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 15 locations. Consider refactoring.
        Open

            this.quadrant4TextFill =
              this.quadrant4TextFill || adjust(this.primaryTextColor, { r: -15, g: -15, b: -15 });
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 14 other locations - About 45 mins to fix
        packages/mermaid/src/themes/theme-base.js on lines 229..230
        packages/mermaid/src/themes/theme-base.js on lines 231..232
        packages/mermaid/src/themes/theme-base.js on lines 233..234
        packages/mermaid/src/themes/theme-dark.js on lines 235..236
        packages/mermaid/src/themes/theme-dark.js on lines 237..238
        packages/mermaid/src/themes/theme-dark.js on lines 239..240
        packages/mermaid/src/themes/theme-default.js on lines 256..257
        packages/mermaid/src/themes/theme-default.js on lines 258..259
        packages/mermaid/src/themes/theme-forest.js on lines 224..225
        packages/mermaid/src/themes/theme-forest.js on lines 226..227
        packages/mermaid/src/themes/theme-forest.js on lines 228..229
        packages/mermaid/src/themes/theme-neutral.js on lines 255..256
        packages/mermaid/src/themes/theme-neutral.js on lines 257..258
        packages/mermaid/src/themes/theme-neutral.js on lines 259..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 50.

        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 < this.THEME_COLOR_LIMIT; i++) {
              this['cScaleInv' + i] = this['cScaleInv' + i] || adjust(this['cScale' + i], { h: 180 });
            }
        Severity: Minor
        Found in packages/mermaid/src/themes/theme-default.js and 1 other location - About 45 mins to fix
        packages/mermaid/src/themes/theme-forest.js on lines 127..129

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

        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 5 locations. Consider refactoring.
        Open

            this.quadrantPointFill =
              this.quadrantPointFill || isDark(this.quadrant1Fill)
                ? lighten(this.quadrant1Fill)
                : darken(this.quadrant1Fill);
        Severity: Major
        Found in packages/mermaid/src/themes/theme-default.js and 4 other locations - About 40 mins to fix
        packages/mermaid/src/themes/theme-base.js on lines 235..238
        packages/mermaid/src/themes/theme-dark.js on lines 241..244
        packages/mermaid/src/themes/theme-forest.js on lines 230..233
        packages/mermaid/src/themes/theme-neutral.js on lines 261..264

        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