qlik-oss/picasso.js

View on GitHub
plugins/q/src/data/extractor-t.js

Summary

Maintainability
F
6 days
Test Coverage
A
99%

Showing 17 of 17 total issues

Function doIt has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
Open

function doIt({ propsArr, props, item, itemData, ret, sourceKey }) {
for (let i = 0; i < propsArr.length; i++) {
const pCfg = props[propsArr[i]];
const arr = pCfg.fields || [pCfg];
let coll;
Severity: Minor
Found in plugins/q/src/data/extractor-t.js - About 2 days to fix

File extractor-t.js has 403 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint no-nested-ternary: 0 */
 
import { hierarchy, stratify } from 'd3-hierarchy';
 
import picker from '../json-path-resolver';
Severity: Minor
Found in plugins/q/src/data/extractor-t.js - About 5 hrs to fix

    Function extract has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

    export function extract(config, dataset, cache, util) {
    const cfgs = Array.isArray(config) ? config : [config];
    let dataItems = [];
    for (let g = 0; g < cfgs.length; g++) {
    if (typeof cfgs[g].field !== 'undefined') {
    Severity: Minor
    Found in plugins/q/src/data/extractor-t.js - About 4 hrs to fix

    Function getFieldDepth has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    export function getFieldDepth(field, { cube }) {
    if (!field) {
    return -1;
    }
     
     
    Severity: Minor
    Found in plugins/q/src/data/extractor-t.js - About 3 hrs to fix

    Function extract has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function extract(config, dataset, cache, util) {
    const cfgs = Array.isArray(config) ? config : [config];
    let dataItems = [];
    for (let g = 0; g < cfgs.length; g++) {
    if (typeof cfgs[g].field !== 'undefined') {
    Severity: Major
    Found in plugins/q/src/data/extractor-t.js - About 2 hrs to fix

      Function augment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      export function augment(config = {}, dataset, cache, util) {
      const cube = dataset.raw();
      const sourceKey = dataset.key();
      const h = cube.qMode === 'S' ? getHierarchyForSMode(dataset) : getHierarchy(cube, cache, config);
      if (!h) {
      Severity: Minor
      Found in plugins/q/src/data/extractor-t.js - About 2 hrs to fix

      Function augment has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function augment(config = {}, dataset, cache, util) {
      const cube = dataset.raw();
      const sourceKey = dataset.key();
      const h = cube.qMode === 'S' ? getHierarchyForSMode(dataset) : getHierarchy(cube, cache, config);
      if (!h) {
      Severity: Major
      Found in plugins/q/src/data/extractor-t.js - About 2 hrs to fix

        Function getHierarchyForSMode has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getHierarchyForSMode(dataset) {
        const matrix = dataset.raw().qDataPages.length ? dataset.raw().qDataPages[0].qMatrix : [];
        const order = getColumnOrder(dataset);
        const fields = dataset.fields();
        const dimensions = dataset
        Severity: Minor
        Found in plugins/q/src/data/extractor-t.js - About 1 hr to fix

          Function getHierarchyForSMode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          function getHierarchyForSMode(dataset) {
          const matrix = dataset.raw().qDataPages.length ? dataset.raw().qDataPages[0].qMatrix : [];
          const order = getColumnOrder(dataset);
          const fields = dataset.fields();
          const dimensions = dataset
          Severity: Minor
          Found in plugins/q/src/data/extractor-t.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

          if (Array.isArray(nodes)) {
          // propably descendants
          cells = nodes.map(p.valueAccessor);
          if (p.attrAccessor) {
          cells = cells.map(p.attrAccessor);
          Severity: Major
          Found in plugins/q/src/data/extractor-t.js - About 45 mins to fix

            Function attachPropsAccessors has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const attachPropsAccessors = ({ propsArr, props, cube, cache, itemDepthObject, f }) => {
            for (let i = 0; i < propsArr.length; i++) {
            const pCfg = props[propsArr[i]];
            const arr = pCfg.fields ? pCfg.fields : [pCfg];
            for (let j = 0; j < arr.length; j++) {
            Severity: Minor
            Found in plugins/q/src/data/extractor-t.js - About 45 mins to fix

            Function datumExtract has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function datumExtract(propCfg, cell, { key }) {
            const datum = {
            value:
            typeof propCfg.value === 'function'
            ? propCfg.value(cell)
            Severity: Minor
            Found in plugins/q/src/data/extractor-t.js - About 35 mins to fix

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

            function datumExtract(propCfg, cell, { key }) {
            const datum = {
            value:
            typeof propCfg.value === 'function'
            ? propCfg.value(cell)
            Severity: Major
            Found in plugins/q/src/data/extractor-t.js and 1 other location - About 7 hrs to fix
            plugins/q/src/data/extractor-s.js on lines 62..87

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

            const measures = dataset
            .fields()
            .filter((f) => f.type() === 'measure')
            .map((f) => order.indexOf(fields.indexOf(f)));
            Severity: Major
            Found in plugins/q/src/data/extractor-t.js and 1 other location - About 1 hr to fix
            plugins/q/src/data/extractor-t.js on lines 245..248

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

            const dimensions = dataset
            .fields()
            .filter((f) => f.type() === 'dimension')
            .map((f) => order.indexOf(fields.indexOf(f)));
            Severity: Major
            Found in plugins/q/src/data/extractor-t.js and 1 other location - About 1 hr to fix
            plugins/q/src/data/extractor-t.js on lines 249..252

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

            if (track) {
            util.track({
            cfg: cfgs[g],
            itemData,
            obj: ret,
            Severity: Major
            Found in plugins/q/src/data/extractor-t.js and 1 other location - About 1 hr to fix
            plugins/q/src/data/extractor-s.js on lines 182..191

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

            const f = typeof cfgs[g].field === 'object' ? cfgs[g].field : dataset.field(cfgs[g].field);
            Severity: Minor
            Found in plugins/q/src/data/extractor-t.js and 1 other location - About 50 mins to fix
            plugins/q/src/data/extractor-s.js on lines 108..108
            Category
            Status