qlik-oss/picasso.js

View on GitHub
plugins/q/src/brush/q-brush.js

Summary

Maintainability
F
5 days
Test Coverage
A
100%

Showing 20 of 20 total issues

Function qBrush has 196 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function qBrush(brush, opts = {}, layout) {
const byCells = opts.byCells;
const primarySource = opts.primarySource;
const selections = [];
const methods = {};
Severity: Major
Found in plugins/q/src/brush/q-brush.js - About 7 hrs to fix

    File q-brush.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import resolve from '../json-path-resolver';
     
    const LAYOUT_TO_PROP = [
    ['qHyperCube', 'qHyperCubeDef'],
    ['qTreeData', 'qTreeDataDef'],
    Severity: Minor
    Found in plugins/q/src/brush/q-brush.js - About 2 hrs to fix

      Function extractFieldFromId has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      export function extractFieldFromId(id, layout) {
      let path = id;
      let dimensionIdx = -1;
      let measureIdx = -1;
      let pathToCube = '';
      Severity: Minor
      Found in plugins/q/src/brush/q-brush.js - About 2 hrs to fix

      Function extractFieldFromId has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function extractFieldFromId(id, layout) {
      let path = id;
      let dimensionIdx = -1;
      let measureIdx = -1;
      let pathToCube = '';
      Severity: Major
      Found in plugins/q/src/brush/q-brush.js - About 2 hrs to fix

        Avoid deeply nested control flow statements.
        Open

        if (!methods.selectHyperCubeCells) {
        methods.selectHyperCubeCells = {
        path: info.path,
        cols: [],
        };
        Severity: Major
        Found in plugins/q/src/brush/q-brush.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

          if (b.id === primarySource || !primarySource) {
          const validValues = b.brush
          .values()
          .map((s) => +s)
          .filter((v) => !isNaN(v));
          Severity: Major
          Found in plugins/q/src/brush/q-brush.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

            if (b.id === primarySource || (!primarySource && !methods.selectHyperCubeCells.values)) {
            methods.selectHyperCubeCells.values = b.brush
            .values()
            .map((s) => +s)
            .filter((v) => !isNaN(v));
            Severity: Major
            Found in plugins/q/src/brush/q-brush.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

              if (!methods.selectPivotCells) {
              methods.selectPivotCells = {
              path: info.path,
              cells: [],
              };
              Severity: Major
              Found in plugins/q/src/brush/q-brush.js - About 45 mins to fix

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

                export default function qBrush(brush, opts = {}, layout) {
                const byCells = opts.byCells;
                const primarySource = opts.primarySource;
                const selections = [];
                const methods = {};
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js - About 35 mins to fix

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

                if (b.type === 'range' && info.measureIdx > -1) {
                const ranges = b.brush.ranges();
                if (ranges.length) {
                hasValues = true;
                if (!methods.rangeSelectHyperCubeValues) {
                Severity: Major
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 7 hrs to fix
                plugins/q/src/brush/q-brush.js on lines 178..200

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

                if (b.type === 'range' && info.dimensionIdx > -1) {
                const ranges = b.brush.ranges();
                if (ranges.length) {
                hasValues = true;
                if (!methods.selectHyperCubeContinuousRange) {
                Severity: Major
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 7 hrs to fix
                plugins/q/src/brush/q-brush.js on lines 155..177

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

                if (methods.selectHyperCubeContinuousRange) {
                selections.push({
                method: 'selectHyperCubeContinuousRange',
                params: [methods.selectHyperCubeContinuousRange.path, methods.selectHyperCubeContinuousRange.ranges],
                });
                Severity: Major
                Found in plugins/q/src/brush/q-brush.js and 2 other locations - About 50 mins to fix
                plugins/q/src/brush/q-brush.js on lines 316..321
                plugins/q/src/brush/q-brush.js on lines 323..328

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

                if (methods.selectPivotCells) {
                selections.push({
                method: 'selectPivotCells',
                params: [methods.selectPivotCells.path, methods.selectPivotCells.cells],
                });
                Severity: Major
                Found in plugins/q/src/brush/q-brush.js and 2 other locations - About 50 mins to fix
                plugins/q/src/brush/q-brush.js on lines 298..303
                plugins/q/src/brush/q-brush.js on lines 323..328

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

                if (methods.multiRangeSelectTreeDataValues) {
                selections.push({
                method: 'multiRangeSelectTreeDataValues',
                params: [methods.multiRangeSelectTreeDataValues.path, methods.multiRangeSelectTreeDataValues.ranges],
                });
                Severity: Major
                Found in plugins/q/src/brush/q-brush.js and 2 other locations - About 50 mins to fix
                plugins/q/src/brush/q-brush.js on lines 298..303
                plugins/q/src/brush/q-brush.js on lines 316..321

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

                } else if (TD_RX.test(id)) {
                pathToCube = `${path.substr(0, path.indexOf('qTreeData') + 9)}`; // 9 = length of 'qTreeData'
                shortenizer = SHORTEN_TD;
                }
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 50 mins to fix
                plugins/q/src/brush/q-brush.js on lines 28..34

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

                if (HC_RX.test(id)) {
                pathToCube = `${path.substr(0, path.indexOf('qHyperCube') + 10)}`; // 10 = length of 'qHyperCube'
                shortenizer = SHORTEN_HC;
                } else if (TD_RX.test(id)) {
                pathToCube = `${path.substr(0, path.indexOf('qTreeData') + 9)}`; // 9 = length of 'qTreeData'
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 50 mins to fix
                plugins/q/src/brush/q-brush.js on lines 31..34

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

                const validValues = b.brush
                .values()
                .map((s) => +s)
                .filter((v) => !isNaN(v));
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 45 mins to fix
                plugins/q/src/brush/q-brush.js on lines 263..266

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

                const values = b.brush
                .values()
                .map((s) => +s)
                .filter((v) => !isNaN(v));
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 45 mins to fix
                plugins/q/src/brush/q-brush.js on lines 221..224

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

                measureIdx = hc.qMeasureInfo.slice(0, offset).reduce((v, meas) => v + meas.qAttrExprInfo.length, measureIdx);
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 30 mins to fix
                plugins/q/src/brush/q-brush.js on lines 71..73

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

                measureIdx = hc.qDimensionInfo
                .slice(0, dimensionIdx)
                .reduce((v, dim) => v + dim.qAttrExprInfo.length, measureIdx);
                Severity: Minor
                Found in plugins/q/src/brush/q-brush.js and 1 other location - About 30 mins to fix
                plugins/q/src/brush/q-brush.js on lines 78..78

                There are no issues that match your filters.

                Category
                Status