mozilla/metrics-graphics

View on GitHub

Showing 11 of 42 total issues

File abstractChart.ts has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { select, extent, max, brush as d3brush, brushX, brushY } from 'd3'
import { randomId, makeAccessorFunction } from '../misc/utility'
import Scale from '../components/scale'
import Axis, { IAxis, AxisOrientation } from '../components/axis'
import Tooltip from '../components/tooltip'
Severity: Minor
Found in lib/src/charts/abstractChart.ts - About 4 hrs to fix

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

      mountBrush(whichBrush?: BrushType): void {
        // if no brush is specified, there's nothing to mount
        if (!whichBrush) return
    
        // brush can only be mounted after content is set
    Severity: Minor
    Found in lib/src/charts/abstractChart.ts - About 1 hr to fix

      Function Home has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Home: React.FC = () => {
        const chartRef = useRef(null)
        useEffect(() => {
          if (!chartRef.current) return
          const lineChart = new LineChart({
      Severity: Minor
      Found in docs/src/views/Home.tsx - About 1 hr to fix

        Function diffToTimeFormat has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          diffToTimeFormat(): FormatFunction {
            const diff = Math.abs(this.scale.domain[1] - this.scale.domain[0]) / 1000
        
            const millisecondDiff = diff < 1
            const secondDiff = diff < 60
        Severity: Minor
        Found in lib/src/components/axis.ts - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function mountRugs has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          mountRugs(): void {
            // if content is not set yet, abort
            if (!this.content) {
              console.error('error: content not set yet')
              return
        Severity: Minor
        Found in lib/src/charts/scatter.ts - About 1 hr to fix

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

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

            Function normalizePoints has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              normalizePoints({
                points,
                nested,
                aggregate,
                defined
            Severity: Minor
            Found in lib/src/components/delaunay.ts - About 1 hr to fix

              Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor({ data, xAccessor, yAccessor, y0Accessor, y1Accessor, xScale, yScale, curve, color, defined }: IArea) {
                  this.data = data
                  this.color = color ?? this.color
              
                  const y0 = y0Accessor ?? ((d) => 0)
              Severity: Minor
              Found in lib/src/components/area.ts - About 45 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                constructor({ data, xAccessor, yAccessor, xScale, yScale, curve, color, defined }: ILine) {
                  // cry if no data was passed
                  if (!data) throw new Error('line needs data')
                  this.data = data
                  this.color = color ?? 'black'
              Severity: Minor
              Found in lib/src/components/line.ts - About 35 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function normalizePoints has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                normalizePoints({
                  points,
                  nested,
                  aggregate,
                  defined
              Severity: Minor
              Found in lib/src/components/delaunay.ts - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function mountBrush has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                mountBrush(whichBrush?: BrushType): void {
                  // if no brush is specified, there's nothing to mount
                  if (!whichBrush) return
              
                  // brush can only be mounted after content is set
              Severity: Minor
              Found in lib/src/charts/abstractChart.ts - About 25 mins to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Severity
              Category
              Status
              Source
              Language