qlik-oss/sn-table

View on GitHub

Showing 18 of 28 total issues

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

  sizePercentage: {
    ref: "qDef.columnWidth.percentage",
    translation: "Object.Table.Column.Percentage",
    type: "number",
    expression: "optional",
Severity: Major
Found in src/ext/property-panel/data.js and 1 other location - About 5 hrs to fix
src/ext/property-panel/data.js on lines 191..204

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

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

  sizePixels: {
    ref: "qDef.columnWidth.pixels",
    translation: "Object.Table.Column.Pixels",
    type: "number",
    expression: "optional",
Severity: Major
Found in src/ext/property-panel/data.js and 1 other location - About 5 hrs to fix
src/ext/property-panel/data.js on lines 205..218

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

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 data.js has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Modifiers from "qlik-modifiers";
// eslint-disable-next-line import/no-unresolved, import/extensions
import { ColumnWidthType, ColumnWidthValues } from "@qlik/nebula-table-utils/lib/constants";

const columnCommonHidden = {
Severity: Minor
Found in src/ext/property-panel/data.js - About 4 hrs to fix

    File types.ts has 324 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Direction, TableCellProps } from "@mui/material";
    import { stardust } from "@nebula.js/stardust";
    import type { ExtendedTheme } from "@qlik/nebula-table-utils/lib/hooks/use-extended-theme/types";
    import {
      Announce,
    Severity: Minor
    Found in src/table/types.ts - About 3 hrs to fix

      File sense-horizon.js has 316 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module.exports = () => ({
        _inherit: true,
        _variables: {
          "@myColorLight": "#FFFFFF",
          "@myColorDark": "#404040",
      Severity: Minor
      Found in test/rendering/theme/sense-horizon.js - About 3 hrs to fix

        Function TableWrapper has 133 lines of code (exceeds 100 allowed). Consider refactoring.
        Open

        const TableWrapper = (props: TableWrapperProps) => {
          const { pageInfo, setPageInfo, direction, footerContainer, announce } = props;
          const { page, rowsPerPage } = pageInfo;
        
          const { totalColumnCount, totalRowCount, totalPages, paginationNeeded, rows, columns, totalsPosition } =
        Severity: Major
        Found in src/table/pagination-table/components/TableWrapper.tsx - About 2 hrs to fix

          Function sortingFactory has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
          Open

          export const sortingFactory = (
            dimensionsLength: number,
            model: EngineAPI.IGenericObject | undefined,
            isNewHeadCellMenuEnabled: boolean,
          ) => {
          Severity: Minor
          Found in src/nebula-hooks/use-sorting.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 HeadCellMenu has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
          Open

          const HeadCellMenu = ({ column, tabIndex }: HeadCellMenuProps) => {
            const { isDim, qLibraryId, fieldId, headTextAlign, pageColIdx } = column;
            const { translator, embed, model, interactions, layout } = useContextSelector(
              TableContext,
              (value) => value.baseProps,
          Severity: Minor
          Found in src/table/components/head/HeadCellMenu.tsx - 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 generateLayout has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            nDims: number,
            nMeas: number,
            nRows: number,
            qColumnOrder: number[] = [],
            qGrandTotalRow: Record<string, string>[] = [],
          Severity: Minor
          Found in src/__test__/generate-test-data.ts - About 45 mins to fix

            Function Cell has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
            Open

            const Cell = ({ columnIndex, rowIndex, style, data }: CellProps) => {
              const { rowsInPage, columns, bodyStyle, isHoverEnabled, maxLineCount } = data;
            
              const rowIsHovered = useContextSelector(TableContext, (value) => value.hoverIndex === rowIndex);
              const setHoverIndex = useContextSelector(TableContext, (value) => value.setHoverIndex);
            Severity: Minor
            Found in src/table/virtualized-table/Cell.tsx - 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

            Function getNextCellCoord has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
            Open

            export const getNextCellCoord = (
              evt: React.KeyboardEvent,
              rootElement: HTMLElement,
              cellCoord: FocusedCellCoord,
              allowedRows: {
            Severity: Minor
            Found in src/table/utils/get-element-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

            Function manageData has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              model: EngineAPI.IGenericObject,
              layout: TableLayout,
              pageInfo: PageInfo,
              setPageInfo: SetPageInfo,
              viewService: ViewService,
            Severity: Minor
            Found in src/handle-data.ts - About 35 mins to fix

              Function handleHeadKeyDown has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
              Open

              export const handleHeadKeyDown = ({
                evt,
                rootElement,
                cellCoord,
                setFocusedCellCoord,
              Severity: Minor
              Found in src/table/utils/handle-keyboard.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 handleHeadCellMenuKeyDown has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
              Open

              export const handleHeadCellMenuKeyDown = (event: React.KeyboardEvent) => {
                const { key, currentTarget } = event;
                const currentFocusItem = document.activeElement ?? currentTarget; // The rest key are handled by handleKeyDown in MUIMenuList
                if (key === KeyCodes.DOWN || key === KeyCodes.UP) {
                  const getNewFocusItem = (currentItem: Element) =>
              Severity: Minor
              Found in src/table/utils/handle-keyboard.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 getTotalPosition has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

              export function getTotalPosition(layout: TableLayout, viewService: ViewService) {
                // For multi-page pdf the totals row may not be needed from the second pdf page
                if (viewService.viewState?.skipTotals) return { atTop: false, atBottom: false };
                const [hasDimension, hasMeasure, hasGrandTotal, isTotalModeAuto, position] = [
                  layout.qHyperCube.qDimensionInfo.length > 0,
              Severity: Minor
              Found in src/handle-data.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

              Function getVisibleColumnOrder has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

              const getVisibleColumnOrder = (
                columnOrder: number[],
                qDimensionInfo: ExtendedNxDimensionInfo[],
                qMeasureInfo: ExtendedNxMeasureInfo[],
              ) => {
              Severity: Minor
              Found in src/handle-data.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

              Function resetFocus has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

              export const resetFocus = ({
                focusedCellCoord,
                rootElement,
                shouldRefocus,
                isSelectionMode,
              Severity: Minor
              Found in src/table/utils/accessibility-utils.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

              Function findVirtualizedVisibleRows has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
              Open

              export function findVirtualizedVisibleRows(rootElement: HTMLElement, viewService: ViewService) {
                const tableBody = rootElement.querySelector(".sn-table-body");
                const bodyRect = tableBody?.getBoundingClientRect();
                const cells = tableBody?.querySelectorAll(".sn-table-body .sn-table-cell");
                if (!cells || !bodyRect) return {};
              Severity: Minor
              Found in src/table/utils/find-visible-rows.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