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",
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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",
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 = {
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,
File sense-horizon.js
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
module.exports = () => ({
_inherit: true,
_variables: {
"@myColorLight": "#FFFFFF",
"@myColorDark": "#404040",
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 } =
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,
) => {
- Read upRead up
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,
- Read upRead up
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>[] = [],
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);
- Read upRead up
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: {
- Read upRead up
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,
Function handleHeadKeyDown
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
export const handleHeadKeyDown = ({
evt,
rootElement,
cellCoord,
setFocusedCellCoord,
- Read upRead up
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) =>
- Read upRead up
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,
- Read upRead up
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[],
) => {
- Read upRead up
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,
- Read upRead up
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 {};
- Read upRead up
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"