grafana/grafana-polystat-panel

View on GitHub

Showing 62 of 189 total issues

File processor.ts has 317 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { InsertTime } from './deframer';
import {
  Field,
  FieldType,
  reduceField,
Severity: Minor
Found in src/data/processor.ts - About 3 hrs to fix

    Function generatePossibleColumnAndRowsSizes has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      generatePossibleColumnAndRowsSizes(columnAutoSize: boolean, rowAutoSize: boolean, dataSize: number) {
        if (rowAutoSize && columnAutoSize) {
          // sqrt of # data items
          const squared = Math.sqrt(dataSize);
          // favor columns when width is greater than height
    Severity: Minor
    Found in src/components/layout/layoutManager.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 ProcessDataFrames has 28 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      compositesEnabled: boolean,
      composites: CompositeItemType[],
      overrides: OverrideItemType[],
      data: PanelData,
      replaceVariables: InterpolateFunction,
    Severity: Major
    Found in src/data/processor.ts - About 3 hrs to fix

      Function OverrideEditor has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      export const OverrideEditor: React.FC<Props> = ({ item, context, onChange }) => {
        const [settings] = useState(context.options.overrideConfig);
        const [tracker, _setTracker] = useState((): OverrideItemTracker[] => {
          if (!settings.overrides) {
            return [] as OverrideItemTracker[];
      Severity: Minor
      Found in src/components/overrides/OverrideEditor.tsx - 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 CompositeEditor has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

      export const CompositeEditor: React.FC<Props> = ({ context, onChange }) => {
        const [settings] = useState(context.options.compositeConfig);
        const [animationSpeed, _setAnimationSpeed] = useState(context.options.compositeConfig.animationSpeed);
        const [compositesEnabled, _setCompositesEnabled] = useState(context.options.compositeConfig.enabled);
        const [tracker, _setTracker] = useState((): CompositeItemTracker[] => {
      Severity: Minor
      Found in src/components/composites/CompositeEditor.tsx - 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 generatePoints has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        generatePoints(data: any, displayLimit: number, shape: PolygonShapes): LayoutPoint[] {
          const points: LayoutPoint[] = [];
          if (typeof data === 'undefined') {
            return points;
          }
      Severity: Minor
      Found in src/components/layout/layoutManager.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 generateUniformPoints has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        generateUniformPoints(data: any, displayLimit: number): any {
          const points = [] as any;
          if (typeof data === 'undefined') {
            return points;
          }
      Severity: Minor
      Found in src/components/layout/layoutManager.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 migrateComposites has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      export const migrateComposites = (angular: AngularSavedComposites, animationSpeed: string) => {
        let options = {} as any;
        // Composites
        options.compositeConfig = {
          composites: [],
      Severity: Minor
      Found in src/migrations.ts - About 2 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 FilterByGlobalDisplayMode has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      const FilterByGlobalDisplayMode = (data: any, globalDisplayMode: string): PolystatModel[] => {
        const filteredMetrics: number[] = [];
        const compositeMetrics: PolystatModel[] = [];
        if (globalDisplayMode !== 'all') {
          const dataLen = data.length;
      Severity: Minor
      Found in src/data/processor.ts - About 2 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 generateActualColumnAndRowUsage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        generateActualColumnAndRowUsage(data: any, displayLimit: number) {
          let polygonsUsed = 0;
          let maxRowsUsed = 0;
          let columnsUsed = 0;
          let maxColumnsUsed = 0;
      Severity: Minor
      Found in src/components/layout/layoutManager.ts - About 2 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 upgradeOldAngularValueMapping has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      function upgradeOldAngularValueMapping(old: any, thresholds?: ThresholdsConfig): ValueMapping {
        const valueMaps: ValueMap = { type: MappingType.ValueToText, options: {} };
        const newMappings: ValueMapping[] = [];
      
        // Use the color we would have picked from thresholds
      Severity: Minor
      Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 2 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

      File valueMappings.ts has 252 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { getActiveThreshold } from './thresholds';
      import { stringToJsRegex } from '@grafana/data';
      import {
        MappingType,
        SpecialValueMatch,
      Severity: Minor
      Found in src/data/valueMappingsWrapper/v8/valueMappings.ts - About 2 hrs to fix

        Function ApplyGlobalRegexPattern has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const ApplyGlobalRegexPattern = (data: PolystatModel[], regexPattern: string): PolystatModel[] => {
          for (let i = 0; i < data.length; i++) {
            if (regexPattern !== '') {
              const regexVal = stringToJsRegex(regexPattern);
              if (data[i].name && regexVal.test(data[i].name.toString())) {
        Severity: Minor
        Found in src/data/processor.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 ThresholdsEditor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const ThresholdsEditor: React.FC<Props> = (options) => {
          const [tracker, _setTracker] = useState((): ThresholdItemTracker[] => {
            if (!options.thresholds) {
              return [] as ThresholdItemTracker[];
            }
        Severity: Minor
        Found in src/components/thresholds/ThresholdsEditor.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 migrateOverrides has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const migrateOverrides = (angular: AngularSavedOverrides) => {
          let options = {} as any;
        
          options.overrideConfig = {
            overrides: [],
        Severity: Minor
        Found in src/migrations.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 DataFrameToPolystat has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        export const DataFrameToPolystat = (frame: DataFrame, globalOperator: string): PolystatModel[] => {
        
          const valueFields: Field[] = [];
          let newestTimestamp = 0;
        
        
        Severity: Minor
        Found in src/data/processor.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 CompositeMetricItem has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        export const CompositeMetricItem: React.FC<CompositeMetricItemProps> = (props) => {
          const [metricHints, setMetricHints] = useState<CascaderOption[]>([]);
        
          async function copySelectedMetricToClipboard(index: number) {
            if (props.metric.seriesMatch) {
        Severity: Minor
        Found in src/components/composites/CompositeMetricItem.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 getThresholdLevelForValue has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        function getThresholdLevelForValue(
          thresholds: PolystatThreshold[] | undefined,
          value: number | null,
          defaultColor: string
        ): { thresholdLevel: number; color: string } {
        Severity: Minor
        Found in src/data/threshold_processor.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 convertOldAngularValueMappings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export function convertOldAngularValueMappings(panel: any, migratedThresholds?: ThresholdsConfig): ValueMapping[] {
          const mappings: ValueMapping[] = [];
        
          // Guess the right type based on options
          let mappingType = panel.mappingType;
        Severity: Minor
        Found in src/data/valueMappingsWrapper/v8/valueMappings.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 transformNthMetric has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          static transformNthMetric(url: string, data: PolystatModel[]) {
            while (url.match(this.nthCellName)) {
              const matched = url.match(this.nthCellName);
              if (matched && matched.length >= 2) {
                // get the capture number
        Severity: Minor
        Found in src/data/clickThroughTransformer.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

        Severity
        Category
        Status
        Source
        Language