grafana/grafana-polystat-panel

View on GitHub

Showing 62 of 189 total issues

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

export const CompositeItem: React.FC<CompositeItemProps> = (props: CompositeItemProps) => {
  const [composite, _setComposite] = useState(props.composite);
  const getDisplayMode = (displayMode: string) => {
    const keys = DisplayModes.keys();
    for (const aKey of keys) {
Severity: Minor
Found in src/components/composites/CompositeItem.tsx - 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 config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const config = async (env): Promise<Configuration> => {
  const baseConfig: Configuration = {
    cache: {
      type: 'filesystem',
      buildDependencies: {
Severity: Minor
Found in .config/webpack/webpack.config.ts - About 55 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 getProcessedDataFrames has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function getProcessedDataFrames(results?: DataQueryResponseData[]): DataFrame[] {
  if (!results || !isArray(results)) {
    return [];
  }

Severity: Minor
Found in src/data/snapshotdata.ts - About 55 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 (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 (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

        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 (aField.state) {
                      copiedField.state = Object.assign({}, aField.state);
                    }
          Severity: Major
          Found in src/data/deframer.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 (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

                            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 (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

                    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 (valueRounded !== null) {
                                data[index].valueRounded = valueRounded;
                              }
                    Severity: Major
                    Found in src/data/processor.ts - About 45 mins to fix

                      Function getTextSizeForWidthAndHeight has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        text: string,
                        font: any,
                        width: number,
                        height: number,
                        minFontPx: number,
                      Severity: Minor
                      Found in src/utils.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

                                  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

                          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

                                      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

                                          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
                                Severity
                                Category
                                Status
                                Source
                                Language