Showing 19 of 119 total issues
Function tableCreator
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
export function tableCreator(data, rows = [], cols = [], accCatOrCB,
accTypeOrInitVal, rowHeader, columnSortFunc) {
/** if data is empty, return empty array */
if (data.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 tableCreator
has 205 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function tableCreator(data, rows = [], cols = [], accCatOrCB,
accTypeOrInitVal, rowHeader, columnSortFunc) {
/** if data is empty, return empty array */
if (data.length === 0) {
File tableCreator.js
has 358 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { expect } from 'chai';
import { tableCreator } from '../../src/logic.js';
const data = [
{name: 'patrick', borough: 'brooklyn', age: '28', gender: 'm'},
File logic.js
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @file Contains logic to actually pivot data
*/
/**
File filter.js
has 302 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { expect } from 'chai';
import Pivot from '../../src';
const dataArray = [
['name', 'gender', 'house', 'age'],
Function rowRecurse
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function rowRecurse(rowGroups, depth, rowHeaders = []) {
for (const key in rowGroups) {
if (Array.isArray(rowGroups[key])) {
const recursedData = groupByCategories(rowGroups[key], cols);
File expand.js
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { expect } from 'chai';
import Pivot from '../../src';
const dataArray = [
['name', 'gender', 'house', 'age'],
Function fixDataFormat
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fixDataFormat(data, rows = [], sortFunc) {
if (!Array.isArray(data) || !data.length) return [];
let formattedData = [];
Function recurseThroughMap
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
(function recurseThroughMap(dataPos, map) {
if (Array.isArray(dataPos)) {
if (key === prevKey) {
const datum = dataRows[dataRows.length - 1].value;
Function accumulator
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function accumulator(arr, accCat, accType, accValue) {
if (typeof accCat === 'undefined') accType = 'count';
else if (typeof accCat === 'function') accValue = accType || 0;
return arr.reduce((acc, curr, index, array) => {
Function filter
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
filter(fieldName, filterValues, filterType) {
/** check that the parameters are of allowed type */
if ((typeof fieldName === 'function') ||
(typeof fieldName === 'string' && Array.isArray(filterValues))) {
/** filter out the data set based on the parameters*/
Function createColumnHeaders
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function createColumnHeaders(
data,
cols = [],
firstColumn = '',
columnSortFunc = () => () => {}
- 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 collapse
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function collapse(rowNum, data) {
/** get the current row, row type, and row depth */
const selectedRow = data.table[rowNum];
const {type, depth} = selectedRow;
Function fixDataFormat
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function fixDataFormat(data, rows = [], sortFunc) {
if (!Array.isArray(data) || !data.length) return [];
let formattedData = [];
- 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 tableCreator
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
export function tableCreator(data, rows = [], cols = [], accCatOrCB,
accTypeOrInitVal, rowHeader, columnSortFunc) {
Avoid too many return
statements within this function. Open
return acc;
Avoid too many return
statements within this function. Open
return acc;
Avoid too many return
statements within this function. Open
return acc;
Function collapse
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function collapse(rowNum, data) {
/** get the current row, row type, and row depth */
const selectedRow = data.table[rowNum];
const {type, depth} = selectedRow;
- 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"