File datatableReducer.js
has 1169 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
import deepmerge from "deepmerge";
import arrayMove from "array-move";
import {
chunk,
cloneDeep,
Function saveAllRowsEdited
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const saveAllRowsEdited = state => {
const {
data,
keyColumn,
rowsGlobalEdited,
Function setRowEdited
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Wontfix
const setRowEdited = (state, { columnId, rowId, newValue, error }) => {
const { rowsEdited, keyColumn, rowsGlobalEdited, features } = state;
let newRowsGlobalEdited = [...rowsGlobalEdited];
const rowsEditedUpdate = rowsEdited.map(row => {
if (row[keyColumn] === rowId) {
- 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 updateRowSizeMultiplier
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const updateRowSizeMultiplier = state => {
const { canEdit, canDelete, canSelectRow, canDuplicate } = state.features;
const numberOfActions = [
canEdit,
canDelete,
Function datatableReducer
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const datatableReducer = (state = defaultState, action) => {
const { payload, type } = action;
switch (type) {
case "INITIALIZE_OPTIONS":
Function setPagination
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Wontfix
const setPagination = ({
state,
newPageSelected = null,
newRowsPerPageSelected = null
}) => {
- 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 updateRowSizeMultiplier
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
const updateRowSizeMultiplier = state => {
const { canEdit, canDelete, canSelectRow, canDuplicate } = state.features;
const numberOfActions = [
canEdit,
canDelete,
- 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 initializeOptions
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
const initializeOptions = (
state,
{
optionsInit,
forceRerender = false,
- 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 addNewRow
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const addNewRow = (state, payload) => {
const {
keyColumn,
data,
pagination,
Function setColumnVisibilty
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const setColumnVisibilty = (state, payload) => {
const { columns } = state.data;
const { columnsOrder } = state.features.userConfiguration;
const orderDisplayed = columns.filter(
col => columnsOrder.includes(col.id) || col.id === payload.id
Function saveRowEdited
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const saveRowEdited = (state, payload) => {
const row = payload;
delete row.idOfColumnErr;
delete row.hasBeenEdited;
const { data, rowsEdited, keyColumn, pagination, actions } = state;
Function rowsEditedUpdate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const rowsEditedUpdate = rowsEdited.map(row => {
if (row[keyColumn] === rowId) {
let idOfColumnErrUpdate = row.idOfColumnErr;
if (error) {
if (!idOfColumnErrUpdate.includes(columnId)) {
Function addToDeleteRow
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
const addToDeleteRow = (state, payload) => {
const row = payload;
const {
data,
keyColumn,
Function revertAllRowsToEdited
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const revertAllRowsToEdited = state => {
const { newRows, data, keyColumn, pagination, rowsDeleted, actions } = state;
const newRowsId = newRows.map(r => r[keyColumn]);
const { rows } = data;
Function convertSizeToNumber
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
const convertSizeToNumber = (val, height) => {
const splitSize = val.match(/[0-9]+|(px|%|vw|vh)/gi);
let valSize = splitSize[0];
const unitSize = splitSize[1];
if (unitSize === "px") {
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Wontfix
let newState = {
...state,
rowsEdited: [...rowsEdited.filter(r => r[keyColumn] !== row[keyColumn])],
rowsGlobalEdited: [
...rowsGlobalEdited.filter(r => r[keyColumn] !== row[keyColumn])
- 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 123.
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
Identical blocks of code found in 2 locations. Consider refactoring. Wontfix
let newState = {
...state,
rowsEdited: [...rowsEdited.filter(r => r[keyColumn] !== row[keyColumn])],
rowsGlobalEdited: [
...rowsGlobalEdited.filter(r => r[keyColumn] !== row[keyColumn])
- 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 123.
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
Identical blocks of code found in 2 locations. Consider refactoring. Wontfix
const hasHeader =
canGlobalEdit ||
canPrint ||
canDownload ||
canSearch ||
- 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 67.
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
Identical blocks of code found in 2 locations. Consider refactoring. Wontfix
const {
canGlobalEdit,
canPrint,
canDownload,
canSearch,
- 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 53.
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