grafana/grafana-polystat-panel

View on GitHub

Showing 96 of 189 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  const arrayMove = (arr: any, oldIndex: number, newIndex: number) => {
    if (newIndex >= arr.length) {
      let k = newIndex - arr.length + 1;
      while (k--) {
        arr.push(undefined);
Severity: Major
Found in src/components/overrides/OverrideEditor.tsx and 1 other location - About 3 hrs to fix
src/components/composites/CompositeEditor.tsx on lines 77..85

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 109.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                <Field label="Stat" description="The statistic to be displayed" disabled={!override.enabled}>
                  <Select
                    menuShouldPortal={true}
                    value={operatorName}
                    onChange={(v) => {
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 1 other location - About 3 hrs to fix
      src/components/composites/CompositeItem.tsx on lines 153..167

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 104.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

                <Field label="Open URL in New Tab" description="Open link in new tab" disabled={!override.enabled}>
                  <Switch
                    transparent={false}
                    value={override.clickThroughOpenNewTab}
                    disabled={!override.enabled}
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 3 other locations - About 3 hrs to fix
      src/components/composites/CompositeItem.tsx on lines 105..112
      src/components/composites/CompositeItem.tsx on lines 141..152
      src/components/composites/CompositeItem.tsx on lines 183..190

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 103.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                <Field label="Sanitize URL" description="Sanitize URL before evaluating" disabled={!override.enabled}>
                  <Switch
                    transparent={false}
                    disabled={!override.enabled}
                    value={override.clickThroughSanitize}
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 1 other location - About 3 hrs to fix
      src/components/composites/CompositeItem.tsx on lines 175..182

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 103.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        if (mappingType === 1) {
          for (let i = 0; i < panel.valueMaps.length; i++) {
            const map = panel.valueMaps[i];
            mappings.push(
              upgradeOldAngularValueMapping(
      Severity: Major
      Found in src/data/valueMappingsWrapper/v8/valueMappings.ts and 1 other location - About 3 hrs to fix
      src/data/valueMappingsWrapper/v8/valueMappings.ts on lines 244..258

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 102.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        } else if (mappingType === 2) {
          for (let i = 0; i < panel.rangeMaps.length; i++) {
            const map = panel.rangeMaps[i];
            mappings.push(
              upgradeOldAngularValueMapping(
      Severity: Major
      Found in src/data/valueMappingsWrapper/v8/valueMappings.ts and 1 other location - About 3 hrs to fix
      src/data/valueMappingsWrapper/v8/valueMappings.ts on lines 230..258

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 102.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

      Similar blocks of code found in 6 locations. Consider refactoring.
      Open

                <Field label="Suffix" description="Apply text to end of metric" disabled={!override.enabled}>
                  <Input
                    value={override.suffix}
                    placeholder=""
                    onChange={(e) => setOverride({ ...override, suffix: e.currentTarget.value })}
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 5 other locations - About 2 hrs to fix
      src/components/overrides/OverrideItem.tsx on lines 82..92
      src/components/overrides/OverrideItem.tsx on lines 171..177
      src/components/overrides/OverrideItem.tsx on lines 185..191
      src/components/composites/CompositeItem.tsx on lines 90..96
      src/components/composites/CompositeItem.tsx on lines 168..174

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 6 locations. Consider refactoring.
      Open

                <Field label="Clickthrough URL" description="URL to Open on Click" disabled={!override.enabled}>
                  <Input
                    value={override.clickThrough}
                    placeholder="https://"
                    onChange={(e) => setOverride({ ...override, clickThrough: e.currentTarget.value })}
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 5 other locations - About 2 hrs to fix
      src/components/overrides/OverrideItem.tsx on lines 82..92
      src/components/overrides/OverrideItem.tsx on lines 171..177
      src/components/overrides/OverrideItem.tsx on lines 178..184
      src/components/composites/CompositeItem.tsx on lines 90..96
      src/components/composites/CompositeItem.tsx on lines 168..174

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 6 locations. Consider refactoring.
      Open

                <Field
                  label="Label"
                  description="Sets the name of the override in the configuration editor."
                  disabled={!override.enabled}
                >
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 5 other locations - About 2 hrs to fix
      src/components/overrides/OverrideItem.tsx on lines 171..177
      src/components/overrides/OverrideItem.tsx on lines 178..184
      src/components/overrides/OverrideItem.tsx on lines 185..191
      src/components/composites/CompositeItem.tsx on lines 90..96
      src/components/composites/CompositeItem.tsx on lines 168..174

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 6 locations. Consider refactoring.
      Open

                <Field label="Prefix" description="Apply text to beginning of metric" disabled={!override.enabled}>
                  <Input
                    value={override.prefix}
                    placeholder=""
                    onChange={(e) => setOverride({ ...override, prefix: e.currentTarget.value })}
      Severity: Major
      Found in src/components/overrides/OverrideItem.tsx and 5 other locations - About 2 hrs to fix
      src/components/overrides/OverrideItem.tsx on lines 82..92
      src/components/overrides/OverrideItem.tsx on lines 178..184
      src/components/overrides/OverrideItem.tsx on lines 185..191
      src/components/composites/CompositeItem.tsx on lines 90..96
      src/components/composites/CompositeItem.tsx on lines 168..174

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 91.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

      Severity
      Category
      Status
      Source
      Language