jens-ox/metrics-graphics

View on GitHub
packages/lib/src/js/charts/abstractChart.js

Summary

Maintainability
C
1 day
Test Coverage

File abstractChart.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isArrayOfArrays, isArrayOfObjectsOrEmpty, getWidth, getHeight, randomId, makeAccessorFunction } from '../misc/utility'
import { select, event } from 'd3-selection'
import Scale from '../components/scale'
import Axis from '../components/axis'
import Tooltip from '../components/tooltip'
Severity: Minor
Found in packages/lib/src/js/charts/abstractChart.js - About 2 hrs to fix

    AbstractChart has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class AbstractChart {
      id = null
    
      // base chart fields
      data = null
    Severity: Minor
    Found in packages/lib/src/js/charts/abstractChart.js - About 2 hrs to fix

      Function mountBrush has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        mountBrush (whichBrush) {
          if (!whichBrush) return
          const brush = typeof whichBrush === 'string'
            ? whichBrush === 'x' ? brushX() : brushY()
            : d3brush()
      Severity: Minor
      Found in packages/lib/src/js/charts/abstractChart.js - About 1 hr to fix

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

          constructor ({
            data,
            target,
            markers,
            baselines,
        Severity: Minor
        Found in packages/lib/src/js/charts/abstractChart.js - About 1 hr to fix

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

              this.yAxis = new Axis({
                scale: this.yScale,
                orientation: 'left',
                top: this.top,
                left: this.left,
          Severity: Major
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 1 hr to fix
          packages/lib/src/js/charts/abstractChart.js on lines 261..269

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

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

              this.xAxis = new Axis({
                scale: this.xScale,
                orientation: 'bottom',
                top: this.bottom,
                left: this.left,
          Severity: Major
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 1 hr to fix
          packages/lib/src/js/charts/abstractChart.js on lines 284..292

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

          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.yScale.domain = [s[1][1], s[0][1]].map(this.yScale.scaleObject.invert)
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 55 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 221..221

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

          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.xScale.domain = [s[0][0], s[1][0]].map(this.xScale.scaleObject.invert)
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 55 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 222..222

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

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

            get innerWidth () { return this.width - this.margin.left - this.margin.right - 2 * this.buffer }
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 50 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 456..456

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

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

            get innerHeight () { return this.height - this.margin.top - this.margin.bottom - 2 * this.buffer }
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 50 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 455..455

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

          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 (this.brush === 'y') {
                    this.yScale.domain = [s[0], s[1]].map(this.yScale.scaleObject.invert)
                  } else {
                    this.xScale.domain = [s[0][0], s[1][0]].map(this.xScale.scaleObject.invert)
                    this.yScale.domain = [s[1][1], s[0][1]].map(this.yScale.scaleObject.invert)
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 45 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 216..223

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

                  if (this.brush === 'x') {
                    this.xScale.domain = [s[0], s[1]].map(this.xScale.scaleObject.invert)
                  } else if (this.brush === 'y') {
                    this.yScale.domain = [s[0], s[1]].map(this.yScale.scaleObject.invert)
                  } else {
          Severity: Minor
          Found in packages/lib/src/js/charts/abstractChart.js and 1 other location - About 45 mins to fix
          packages/lib/src/js/charts/abstractChart.js on lines 218..223

          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

          There are no issues that match your filters.

          Category
          Status