airbnb/caravel

View on GitHub
superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx

Summary

Maintainability
F
6 days
Test Coverage

Function PivotTableChart has 406 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function PivotTableChart(props: PivotTableProps) {
  const {
    data,
    height,
    width,

    Function PivotTableChart has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function PivotTableChart(props: PivotTableProps) {
      const {
        data,
        height,
        width,

    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 PivotTableChart.tsx has 503 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /**
     * Licensed to the Apache Software Foundation (ASF) under one
     * or more contributor license agreements.  See the NOTICE file
     * distributed with this work for additional information
     * regarding copyright ownership.  The ASF licenses this file

      Function getCrossFilterDataMask has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          (value: { [key: string]: string }) => {
            const isActiveFilterValue = (key: string, val: DataRecordValue) =>
              !!selectedFilters && selectedFilters[key]?.includes(val);
      
            if (!value) {

        Function handleContextMenu has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            (
              e: MouseEvent,
              colKey: (string | number | boolean)[] | undefined,
              rowKey: (string | number | boolean)[] | undefined,
              dataPoint: { [key: string]: string },

          Function handleChange has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              (filters: SelectedFiltersType) => {
                const filterKeys = Object.keys(filters);
                const groupby = [...groupbyRowsRaw, ...groupbyColumnsRaw];
                setDataMask({
                  extraFormData: {

            Function toggleFilter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                (
                  e: MouseEvent,
                  value: string,
                  filters: FilterType,
                  pivotData: Record<string, any>,

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

                                const col =
                                  groupby.find(item => {
                                    if (isPhysicalColumn(item)) {
                                      return item === key;
                                    }
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 338..347

              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 68.

              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

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

                                  const col =
                                    groupby.find(item => {
                                      if (isPhysicalColumn(item)) {
                                        return item === key;
                                      }
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 276..285

              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 68.

              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

                        filterState: {
                          value:
                            values && Object.keys(values).length
                              ? Object.values(values)
                              : null,
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 298..305

              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 68.

              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

                      filterState: {
                        value:
                          filters && Object.keys(filters).length
                            ? Object.values(filters)
                            : null,
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 360..367

              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 68.

              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 8 locations. Consider refactoring.
              Open

              const StyledPlusSquareOutlined = styled(PlusSquareOutlined)`
                stroke: ${({ theme }) => theme.colors.grayscale.light2};
                stroke-width: 16px;
              `;
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 71..74
              superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx on lines 31..35
              superset-frontend/src/components/InfoTooltip/index.tsx on lines 48..53
              superset-frontend/src/components/Switch/index.tsx on lines 23..27
              superset-frontend/src/components/Timer/index.tsx on lines 32..35
              superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx on lines 239..254
              superset-frontend/src/pages/QueryHistoryList/index.tsx on lines 93..96

              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 46.

              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 8 locations. Consider refactoring.
              Open

              const StyledMinusSquareOutlined = styled(MinusSquareOutlined)`
                stroke: ${({ theme }) => theme.colors.grayscale.light2};
                stroke-width: 16px;
              `;
              superset-frontend/plugins/plugin-chart-pivot-table/src/PivotTableChart.tsx on lines 66..69
              superset-frontend/src/SqlLab/components/TemplateParamsEditor/index.tsx on lines 31..35
              superset-frontend/src/components/InfoTooltip/index.tsx on lines 48..53
              superset-frontend/src/components/Switch/index.tsx on lines 23..27
              superset-frontend/src/components/Timer/index.tsx on lines 32..35
              superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx on lines 239..254
              superset-frontend/src/pages/QueryHistoryList/index.tsx on lines 93..96

              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 46.

              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

              There are no issues that match your filters.

              Category
              Status