grafana/grafana-polystat-panel

View on GitHub

Showing 62 of 189 total issues

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 (v !== 'all') {
                  aComposite.displayMode = DisplayModes[1].value;
                }
    Severity: Major
    Found in src/migrations.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 (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 (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 (let rowNum = 0; rowNum < rowsOfField; rowNum++) {
                      // only create a new field when the rowValue is not null
                      if (aFieldValues[rowNum] !== null) {
                        if (aField.state) {
                          copiedField.state = Object.assign({}, aField.state);
          Severity: Major
          Found in src/data/deframer.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 OverrideItem has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export const OverrideItem: React.FC<OverrideItemProps> = (props) => {
                const [metricHints, setMetricHints] = useState<CascaderOption[]>([]);
                const [override, _setOverride] = useState(props.override);
              
                const setOverride = (value: OverrideItemType) => {
              Severity: Minor
              Found in src/components/overrides/OverrideItem.tsx - 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

              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

              Avoid too many return statements within this function.
              Open

                return null;
              Severity: Major
              Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                  return allValueMappings.concat(valueToTextMapping);
                Severity: Major
                Found in src/data/valueMappingsWrapper/v7/valueMappings.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                return vm.options.result;
                  Severity: Major
                  Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                  return vm.options.result;
                    Severity: Major
                    Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return { thresholdLevel: currentState, color: currentColor };
                      Severity: Major
                      Found in src/data/threshold_processor.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                      return vm.options.result;
                        Severity: Major
                        Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                        return vm.options.result;
                          Severity: Major
                          Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                              return allValueMappings;
                            Severity: Major
                            Found in src/data/valueMappingsWrapper/v7/valueMappings.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                            return vm.options.result;
                              Severity: Major
                              Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 30 mins to fix

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

                                function getWorstSeries(series1: PolystatModel, series2: PolystatModel): any {
                                  let worstSeries = series1;
                                  const series1ThresholdLevel = series1.thresholdLevel;
                                  const series2ThresholdLevel = series2.thresholdLevel;
                                
                                
                                Severity: Minor
                                Found in src/data/threshold_processor.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