knsv/mermaid

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

Summary

Maintainability
F
1 wk
Test Coverage

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

  updateColors() {
    // The || is to make sure that if the variable has been defined by a user override that value is to be used

    /* Main */
    this.primaryTextColor = this.primaryTextColor || (this.darkMode ? '#eee' : '#333'); // invert(this.primaryColor);
Severity: Major
Found in packages/mermaid/src/themes/theme-base.js - About 1 day to fix

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

    import { darken, lighten, adjust, invert, isDark, toRgba } from 'khroma';
    import { mkBorder } from './theme-helpers.js';
    import {
      oldAttributeBackgroundColorEven,
      oldAttributeBackgroundColorOdd,
    Severity: Minor
    Found in packages/mermaid/src/themes/theme-base.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-base.js and 2 other locations - About 1 day to fix
      packages/mermaid/src/themes/theme-default.js on lines 310..328
      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-base.js and 4 other locations - About 1 day to fix
      packages/mermaid/src/themes/theme-dark.js on lines 255..269
      packages/mermaid/src/themes/theme-default.js on lines 276..290
      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-base.js and 4 other locations - About 5 hrs to fix
      packages/mermaid/src/themes/theme-dark.js on lines 328..348
      packages/mermaid/src/themes/theme-default.js on lines 363..383
      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++) {
            if (this.darkMode) {
              this['cScalePeer' + i] = this['cScalePeer' + i] || lighten(this['cScale' + i], 10);
            } else {
              this['cScalePeer' + i] = this['cScalePeer' + i] || darken(this['cScale' + i], 10);
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 1 other location - About 4 hrs to fix
      packages/mermaid/src/themes/theme-neutral.js on lines 148..154

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

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

          for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
            this['cScaleInv' + i] = this['cScaleInv' + i] || invert(this['cScale' + i]);
          }
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 2 other locations - About 1 hr to fix
      packages/mermaid/src/themes/theme-dark.js on lines 191..193
      packages/mermaid/src/themes/theme-neutral.js on lines 144..146

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

      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: 180, s: -15, l: multiplier * (8 + i * 3) });
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 1 other location - About 1 hr to fix
      packages/mermaid/src/themes/theme-base.js on lines 177..179

      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

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

      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

          } else {
            for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
              this['cScale' + i] = darken(this['cScale' + i], 25);
            }
          }
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 1 other location - About 1 hr to fix
      packages/mermaid/src/themes/theme-base.js on lines 145..149

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

          for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
            this['cScaleLabel' + i] = this['cScaleLabel' + i] || this.scaleLabelColor;
          }
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 3 other locations - About 1 hr to fix
      packages/mermaid/src/themes/theme-default.js on lines 163..165
      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

          if (this.darkMode) {
            for (let i = 0; i < this.THEME_COLOR_LIMIT; i++) {
              this['cScale' + i] = darken(this['cScale' + i], 75);
            }
          } else {
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 1 other location - About 1 hr to fix
      packages/mermaid/src/themes/theme-base.js on lines 149..153

      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 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-base.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-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-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-base.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 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-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.quadrant2TextFill =
            this.quadrant2TextFill || adjust(this.primaryTextColor, { r: -5, g: -5, b: -5 });
      Severity: Major
      Found in packages/mermaid/src/themes/theme-base.js and 14 other locations - About 45 mins to fix
      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-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

      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-base.js and 4 other locations - About 40 mins to fix
      packages/mermaid/src/themes/theme-dark.js on lines 241..244
      packages/mermaid/src/themes/theme-default.js on lines 262..265
      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