grafana/grafana-polystat-panel

View on GitHub

Showing 95 of 189 total issues

Avoid deeply nested control flow statements.
Open

            if (columnsUsed > maxColumnsUsed) {
              maxColumnsUsed = columnsUsed;
            }
Severity: Major
Found in src/components/layout/layoutManager.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

              if (!aComposite.showMembers) {
                filteredMetrics.push(index);
              } else {
                keepMetrics.push(index);
              }
    Severity: Major
    Found in src/data/composite_processor.ts - About 45 mins to fix

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

      const addValueToTextMappingText = (
        allValueMappings: ValueMapping[],
        valueToTextMapping: ValueMap,
        value: TimeSeriesValue
      ) => {
      Severity: Minor
      Found in src/data/valueMappingsWrapper/v7/valueMappings.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

      Avoid deeply nested control flow statements.
      Open

                if (appendLabels.length > 0) {
                  // sort them first
                  appendLabels.sort();
                  hintValue += '{' + appendLabels.join('') + '}';
                }
      Severity: Major
      Found in src/components/metric_hints.ts - About 45 mins to fix

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

          constructor(
            width: number,
            height: number,
            numColumns: number,
            numRows: number,
        Severity: Minor
        Found in src/components/layout/layoutManager.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

        Avoid deeply nested control flow statements.
        Open

                  if (aMetric.alias && aMetric.alias.length > 0) {
                    seriesItem.displayName = resolveMemberAliasTemplates(aMetric.alias, matches);
                  }
        Severity: Major
        Found in src/data/composite_processor.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                    for (const aLabel in aField.labels) {
                      if (aLabel !== '__name__') {
                        appendLabels.push(`${aLabel}="${aField.labels[aLabel]}"`);
                      }
                    }
          Severity: Major
          Found in src/components/metric_hints.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (formatted.suffix) {
                        data[index].valueFormatted += formatted.suffix;
                      }
            Severity: Major
            Found in src/data/override_processor.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (formatted.prefix) {
                          data[index].valueFormatted = formatted.prefix + data[index].valueFormatted;
                        }
              Severity: Major
              Found in src/data/override_processor.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            for (const aMember of Object.keys(v)) {
                              const x = v[aMember];
                              let member: CompositeMetric = {
                                seriesMatch: x.seriesName,
                                order: memberIndex,
                Severity: Major
                Found in src/migrations.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (aField.state) {
                              copiedField.state = Object.assign({}, aField.state);
                            }
                  Severity: Major
                  Found in src/data/deframer.ts - About 45 mins to fix

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

                    function GetDecimalsForValue(value: any, panelDecimals: any): { decimals: number; scaledDecimals: any } {
                      if (lodashIsNumber(panelDecimals)) {
                        return { decimals: panelDecimals, scaledDecimals: null };
                      }
                    
                    
                    Severity: Minor
                    Found in src/utils.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

                    Avoid deeply nested control flow statements.
                    Open

                                for (const threshold of v) {
                                  const migratedThreshold: PolystatThreshold = {
                                    value: threshold.value,
                                    state: threshold.state,
                                    color: threshold.color,
                    Severity: Major
                    Found in src/migrations.ts - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (value) {
                                    extractedTxt += extractedTxt.length > 0 ? ' ' + value.toString() : value.toString();
                                  }
                      Severity: Major
                      Found in src/data/processor.ts - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if (formatted.suffix) {
                                    data[index].valueFormatted += ` ${formatted.suffix}`;
                                  }
                        Severity: Major
                        Found in src/data/processor.ts - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if (formatted.prefix) {
                                      data[index].valueFormatted = `{$formatted.prefix} ${data[index].valueFormatted}`;
                                    }
                          Severity: Major
                          Found in src/data/processor.ts - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if (valueRounded !== null) {
                                        data[index].valueRounded = valueRounded;
                                      }
                            Severity: Major
                            Found in src/data/processor.ts - About 45 mins to fix

                              Function getTextSizeForWidth has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              function getTextSizeForWidth(text: string, font: any, width: number, minFontPx: number, maxFontPx: number) {
                              Severity: Minor
                              Found in src/utils.ts - About 35 mins to fix

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

                                const addRangeToTextMappingText = (
                                  allValueMappings: ValueMapping[],
                                  rangeToTextMapping: RangeMap,
                                  value: TimeSeriesValue
                                ) => {
                                Severity: Minor
                                Found in src/data/valueMappingsWrapper/v7/valueMappings.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 getMappedValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export function getMappedValue(valueMappings: LegacyValueMapping[], value: any): LegacyValueMapping {
                                  // intentional use of deprecated function for v8 compat
                                  // eslint-disable-next-line deprecation/deprecation
                                  const emptyResult = { type: LegacyMappingType.ValueToText, value: '', text: '', from: '', to: '', id: 0 };
                                  if (!valueMappings?.length) {
                                Severity: Minor
                                Found in src/data/valueMappingsWrapper/v8/valueMappings.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

                                Severity
                                Category
                                Status
                                Source
                                Language