qlik-oss/picasso.js

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

Summary

Maintainability
F
1 wk
Test Coverage

Showing 25 of 25 total issues

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

import qBrush, { extractFieldFromId } from '../q-brush';
 
describe('q-brush', () => {
let brush;
let layout;
Severity: Major
Found in plugins/q/src/brush/__tests__/q-brush.spec.js - About 1 day to fix

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

    it('should have valid params if opts = { orMode: false }', () => {
    const selections = qBrush(brush, { orMode: false });
    expect(selections[0].params).to.eql([
    '/qHyperCubeDef',
    [
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 6 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 125..161

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

    it('should have valid params if opts = { orMode: true }', () => {
    const selections = qBrush(brush, { orMode: true });
    expect(selections[0].params).to.eql([
    '/qHyperCubeDef',
    [
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 6 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 163..199

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

    it('should get top dimension', () => {
    layout.qHyperCube.qNoOfLeftDims = 0;
    layout.qHyperCube.qEffectiveInterColumnSortOrder.push(1);
     
    const selections = qBrush(
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 5 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 391..420

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

    it('should have valid params when primary is specified', () => {
    layout.qHyperCube.qNoOfLeftDims = 1;
    layout.qHyperCube.qEffectiveInterColumnSortOrder.push(1);
     
    const selections = qBrush(
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 5 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 422..451

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

    expect(selections[0].params).to.eql([
    '/layers/0/qHyperCubeDef',
    [
    {
    qCol: 2,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 4 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 457..491

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

    expect(selections[0].params).to.eql([
    '/layers/0/qHyperCubeDef',
    [
    {
    qCol: 2,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 4 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 354..388

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

    beforeEach(() => {
    brush.brushes.returns([
    {
    id: '/qHyperCube/qDimensionInfo/1',
    type: 'range',
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 60..80
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 645..665

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

    beforeEach(() => {
    brush.brushes.returns([
    {
    id: '/qTreeData/qDimensionInfo/1/qMeasureInfo/2',
    type: 'range',
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 60..80
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 203..223

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

    beforeEach(() => {
    brush.brushes.returns([
    {
    id: '/qHyperCube/qMeasureInfo/3',
    type: 'range',
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 203..223
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 645..665

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

    brush.brushes.returns([
    {
    id: 'layers/0/qHyperCube/qDimensionInfo/2',
    type: 'value',
    brush: {
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 2 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 305..320

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

    brush.brushes.returns([
    {
    id: 'layers/0/qHyperCube/qDimensionInfo/2',
    type: 'value',
    brush: {
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 2 hrs to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 269..284

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

    it('should have method="selectPivotCells" when qMode="K"', () => {
    layout.qHyperCube.qMode = 'K';
     
    const selections = qBrush(brush, { byCells: true }, layout);
    expect(selections[0].method).to.equal('selectPivotCells');
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 342..347

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

    it('should have method="selectPivotCells" when qMode="P"', () => {
    layout.qHyperCube.qMode = 'P';
     
    const selections = qBrush(brush, { byCells: true }, layout);
    expect(selections[0].method).to.equal('selectPivotCells');
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 1 other location - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 335..340

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

    it('should map attribute dimension layout value to params (on measure)', () => {
    let v = extractFieldFromId('/qHyperCube/qMeasureInfo/2/qAttrDimInfo/4');
    expect(v).to.eql({
    path: '/qHyperCubeDef/qMeasures/2/qAttributeDimensions/4',
    dimensionIdx: 0,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should map attribute expression layout value to params (on dimension) - without layout', () => {
    let v = extractFieldFromId('/qHyperCube/qDimensionInfo/1/qAttrExprInfo/1');
    expect(v).to.eql({
    path: '/qHyperCubeDef',
    measureIdx: 1,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583

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

    it('should map attribute dimension column layout value to params (on measure)', () => {
    let v = extractFieldFromId('qHyperCube/qMeasureInfo/2/qAttrDimInfo/4/3');
    expect(v).to.eql({
    path: '/qHyperCubeDef/qMeasures/2/qAttributeDimensions/4',
    dimensionIdx: 3,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should map attribute dimension layout value to params (on dimension)', () => {
    let v = extractFieldFromId('/qHyperCube/qDimensionInfo/2/qAttrDimInfo/5');
    expect(v).to.eql({
    path: '/qHyperCubeDef/qDimensions/2/qAttributeDimensions/5',
    dimensionIdx: 0,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should map attribute expression layout value to params (on measure) - without layout', () => {
    let v = extractFieldFromId('/qHyperCube/qMeasureInfo/1/qAttrExprInfo/1');
    expect(v).to.eql({
    path: '/qHyperCubeDef',
    measureIdx: 3,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should map attribute dimension column layout value to params (on dimension)', () => {
    let v = extractFieldFromId('/qHyperCube/qDimensionInfo/2/qAttrDimInfo/5/3');
    expect(v).to.eql({
    path: '/qHyperCubeDef/qDimensions/2/qAttributeDimensions/5',
    dimensionIdx: 3,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 508..515
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should map dimension layout value to params', () => {
    let v = extractFieldFromId('/qHyperCube/qDimensionInfo/3');
    expect(v).to.eql({
    path: '/qHyperCubeDef',
    dimensionIdx: 3,
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 6 other locations - About 1 hr to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 526..533
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 535..542
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 544..551
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 553..560
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 576..583
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 599..606

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

    it('should have method="rangeSelectHyperCubeValues"', () => {
    const selections = qBrush(brush);
    expect(selections[0].method).to.equal('rangeSelectHyperCubeValues');
    });
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 3 other locations - About 50 mins to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 48..51
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 225..228
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 667..670

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

    it('should have method="selectHyperCubeContinuousRange"', () => {
    const selections = qBrush(brush);
    expect(selections[0].method).to.equal('selectHyperCubeContinuousRange');
    });
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 3 other locations - About 50 mins to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 48..51
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 82..85
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 667..670

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

    it('should have method="multiRangeSelectTreeDataValues"', () => {
    const selections = qBrush(brush);
    expect(selections[0].method).to.equal('multiRangeSelectTreeDataValues');
    });
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 3 other locations - About 50 mins to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 48..51
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 82..85
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 225..228

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

    it('should have method="selectHyperCubeValues"', () => {
    const selections = qBrush(brush);
    expect(selections[0].method).to.equal('selectHyperCubeValues');
    });
    Severity: Major
    Found in plugins/q/src/brush/__tests__/q-brush.spec.js and 3 other locations - About 50 mins to fix
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 82..85
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 225..228
    plugins/q/src/brush/__tests__/q-brush.spec.js on lines 667..670
    Category
    Status