knsv/mermaid

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

Summary

Maintainability
F
5 days
Test Coverage

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

  updateColors() {
    this.secondBkg = lighten(this.contrast, 55);
    this.border2 = this.contrast;

    /* Sequence Diagram variables */
Severity: Major
Found in packages/mermaid/src/themes/theme-neutral.js - About 7 hrs to fix

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

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

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

        constructor() {
          this.primaryColor = '#eee';
          this.contrast = '#707070';
          this.secondaryColor = lighten(this.contrast, 55);
          this.background = '#ffffff';
      Severity: Major
      Found in packages/mermaid/src/themes/theme-neutral.js - About 2 hrs to fix

        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-neutral.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-default.js on lines 276..290
        packages/mermaid/src/themes/theme-forest.js on lines 244..258

        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-neutral.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-default.js on lines 363..383
        packages/mermaid/src/themes/theme-forest.js on lines 331..351

        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-neutral.js and 1 other location - About 4 hrs to fix
        packages/mermaid/src/themes/theme-base.js on lines 160..166

        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-neutral.js and 2 other locations - About 1 hr to fix
        packages/mermaid/src/themes/theme-base.js on lines 156..158
        packages/mermaid/src/themes/theme-dark.js on lines 191..193

        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 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-neutral.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-default.js on lines 163..165
        packages/mermaid/src/themes/theme-forest.js on lines 137..139

        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, { l: -(8 + i * 5) });
        Severity: Minor
        Found in packages/mermaid/src/themes/theme-neutral.js and 1 other location - About 50 mins to fix
        packages/mermaid/src/themes/theme-neutral.js on lines 166..166

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

        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, { l: -(5 + i * 5) });
        Severity: Minor
        Found in packages/mermaid/src/themes/theme-neutral.js and 1 other location - About 50 mins to fix
        packages/mermaid/src/themes/theme-neutral.js on lines 167..168

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

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

        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-neutral.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-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 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-neutral.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-default.js on lines 262..265
        packages/mermaid/src/themes/theme-forest.js on lines 230..233

        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