briangann/grafana-gauge-panel

View on GitHub

Showing 17 of 46 total issues

File d3gauge.ts has 579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as d3 from 'd3';
import { MarkerStartShapes, MarkerEndShapes } from '../types';

export class DrawGauge {
  defaultFonts: any;
Severity: Major
Found in src/libs/d3gauge.ts - About 1 day to fix

    File ctrl.ts has 573 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { MetricsPanelCtrl } from 'grafana/app/plugins/sdk';
    import { PanelEvents } from '@grafana/data';
    import _ from 'lodash';
    import $ from 'jquery';
    import kbn from 'grafana/app/core/utils/kbn';
    Severity: Major
    Found in src/ctrl.ts - About 1 day to fix

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

        constructor(svg: any, opt: any) {
          this.svg = svg;
          // Set defaults if not supplied
          this.opt = this.initOptDefaults(opt);
          // Calculate required values
      Severity: Major
      Found in src/libs/d3gauge.ts - About 1 day to fix

        Function setValues has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

          setValues(data: any) {
            data.flotpairs = [];
            if (this.series.length > 1) {
              const error = new Error();
              error.message = 'Multiple Series Error';
        Severity: Minor
        Found in src/ctrl.ts - About 5 hrs 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 27 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(svg: any, opt: any) {
            this.svg = svg;
            // Set defaults if not supplied
            this.opt = this.initOptDefaults(opt);
            // Calculate required values
        Severity: Minor
        Found in src/libs/d3gauge.ts - About 3 hrs 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 renderGauge has 92 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          renderGauge() {
            // update the values to be sent to the gauge constructor
            this.setValues(this.data);
            if ($('#' + this.panel.gaugeDivId).length) {
              $('#' + this.panel.gaugeDivId).remove();
        Severity: Major
        Found in src/ctrl.ts - About 3 hrs to fix

          D3GaugePanelCtrl has 28 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class D3GaugePanelCtrl extends MetricsPanelCtrl {
            static templateUrl = 'partials/template.html';
          
            containerDivId: any;
            scoperef: any;
          Severity: Minor
          Found in src/ctrl.ts - About 3 hrs to fix

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

              setValues(data: any) {
                data.flotpairs = [];
                if (this.series.length > 1) {
                  const error = new Error();
                  error.message = 'Multiple Series Error';
            Severity: Major
            Found in src/ctrl.ts - About 2 hrs to fix

              Function validateGaugeTickDegreeValues has 50 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                validateGaugeTickDegreeValues() {
                  if (
                    this.panel.gauge.zeroTickAngle === null ||
                    this.panel.gauge.zeroTickAngle === '' ||
                    this.panel.gauge.zeroTickAngle < 0 ||
              Severity: Minor
              Found in src/ctrl.ts - About 2 hrs to fix

                Function validateGaugeNeedleDegreeValues has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  validateGaugeNeedleDegreeValues() {
                    if (
                      this.panel.gauge.zeroNeedleAngle === null ||
                      this.panel.gauge.zeroNeedleAngle === '' ||
                      this.panel.gauge.zeroNeedleAngle < 0 ||
                Severity: Minor
                Found in src/ctrl.ts - About 2 hrs to fix

                  Function updateGauge has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    updateGauge(newVal: any, newValFormatted: any, newValRounded: any) {
                      // Set default values if necessary
                      if (newVal === undefined) {
                        newVal = this.opt.minVal;
                      }
                  Severity: Minor
                  Found in src/libs/d3gauge.ts - About 2 hrs to fix

                    Function renderGauge has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      renderGauge() {
                        // update the values to be sent to the gauge constructor
                        this.setValues(this.data);
                        if ($('#' + this.panel.gaugeDivId).length) {
                          $('#' + this.panel.gaugeDivId).remove();
                    Severity: Minor
                    Found in src/ctrl.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 getPanelHeight has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      getPanelHeight() {
                        // panel can have a fixed height set via "General" tab in panel editor
                        let tmpPanelHeight = this.panel.height;
                        if (typeof tmpPanelHeight === 'undefined' || tmpPanelHeight === '') {
                          // grafana also supplies the height, try to use that if the panel does not have a height
                    Severity: Minor
                    Found in src/ctrl.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 getDecimalsForValue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      getDecimalsForValue(value: any) {
                        if (_.isNumber(this.panel.decimals)) {
                          return { decimals: this.panel.decimals, scaledDecimals: null };
                        }
                    
                    
                    Severity: Minor
                    Found in src/ctrl.ts - About 1 hr to fix

                      Function updateGauge has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                        updateGauge(newVal: any, newValFormatted: any, newValRounded: any) {
                          // Set default values if necessary
                          if (newVal === undefined) {
                            newVal = this.opt.minVal;
                          }
                      Severity: Minor
                      Found in src/libs/d3gauge.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

                      Avoid deeply nested control flow statements.
                      Open

                                if (data.value === null || data.value === void 0) {
                                  data.valueFormatted = rangeMap.text;
                                  return;
                                }
                      Severity: Major
                      Found in src/ctrl.ts - About 45 mins to fix

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

                          getDecimalsForValue(value: any) {
                            if (_.isNumber(this.panel.decimals)) {
                              return { decimals: this.panel.decimals, scaledDecimals: null };
                            }
                        
                        
                        Severity: Minor
                        Found in src/ctrl.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

                        Severity
                        Category
                        Status
                        Source
                        Language