qlik-oss/picasso.js

View on GitHub
plugins/q/src/formatter/__tests__/timeFormat.spec.js

Summary

Maintainability
F
2 wks
Test Coverage

Showing 16 of 16 total issues

File timeFormat.spec.js has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import timeFormat, { QlikTimeToDate } from '../timeFormat';
 
/**
* PLEASE NOTE / WARNING: THIS FUNCTION *MAY* HAVE FLOATING POINT ERRORS
* IT MIGHT BE OFF BY MILLISECONDS.
Severity: Minor
Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js - About 5 hrs to fix

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

    it('in short form', () => {
    n = timeFormat('MMM');
    expect(n(_0)).to.equal('Jan');
    expect(n(_1)).to.equal('Feb');
    expect(n(_2)).to.equal('Mar');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 3 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 142..156
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 158..172
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 190..204

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

    it('as padded number', () => {
    n = timeFormat('MM');
    expect(n(_0)).to.equal('01');
    expect(n(_1)).to.equal('02');
    expect(n(_2)).to.equal('03');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 3 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 142..156
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 174..188
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 190..204

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

    it('in long form', () => {
    n = timeFormat('MMMM');
    expect(n(_0)).to.equal('January');
    expect(n(_1)).to.equal('February');
    expect(n(_2)).to.equal('March');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 3 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 142..156
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 158..172
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 174..188

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

    it('as number', () => {
    n = timeFormat('M');
    expect(n(_0)).to.equal('1');
    expect(n(_1)).to.equal('2');
    expect(n(_2)).to.equal('3');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 3 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 158..172
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 174..188
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 190..204

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

    it('as number (small)', () => {
    n = timeFormat('w');
    expect(n(mon)).to.equal('0'); // Mon 6th January 2014
    expect(n(tue)).to.equal('1'); // Tue 7th January 2014
    expect(n(wed)).to.equal('2'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('in long form (small)', () => {
    n = timeFormat('wwww');
    expect(n(mon)).to.equal('Monday'); // Mon 6th January 2014
    expect(n(tue)).to.equal('Tuesday'); // Tue 7th January 2014
    expect(n(wed)).to.equal('Wednesday'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295

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

    it('as number', () => {
    n = timeFormat('W');
    expect(n(mon)).to.equal('0'); // Mon 6th January 2014
    expect(n(tue)).to.equal('1'); // Tue 7th January 2014
    expect(n(wed)).to.equal('2'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('in long form', () => {
    n = timeFormat('WWWW');
    expect(n(mon)).to.equal('Monday'); // Mon 6th January 2014
    expect(n(tue)).to.equal('Tuesday'); // Tue 7th January 2014
    expect(n(wed)).to.equal('Wednesday'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('as padded number (small)', () => {
    n = timeFormat('ww');
    expect(n(mon)).to.equal('00'); // Mon 6th January 2014
    expect(n(tue)).to.equal('01'); // Tue 7th January 2014
    expect(n(wed)).to.equal('02'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('in short form (small)', () => {
    n = timeFormat('www');
    expect(n(mon)).to.equal('Mon'); // Mon 6th January 2014
    expect(n(tue)).to.equal('Tue'); // Tue 7th January 2014
    expect(n(wed)).to.equal('Wed'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('as padded number', () => {
    n = timeFormat('WW');
    expect(n(mon)).to.equal('00'); // Mon 6th January 2014
    expect(n(tue)).to.equal('01'); // Tue 7th January 2014
    expect(n(wed)).to.equal('02'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 264..273
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('in short form', () => {
    n = timeFormat('WWW');
    expect(n(mon)).to.equal('Mon'); // Mon 6th January 2014
    expect(n(tue)).to.equal('Tue'); // Tue 7th January 2014
    expect(n(wed)).to.equal('Wed'); // Wed 8th January 2014
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 7 other locations - About 1 day to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 220..229
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 231..240
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 242..251
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 253..262
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 275..284
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 286..295
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 297..306

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

    it('as number', () => {
    expect(n.format('h', midnight)).to.equal('0');
    expect(n.format('H', midnight)).to.equal('0');
    expect(n.format('h', preNoon)).to.equal('11');
    expect(n.format('H', preNoon)).to.equal('11');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 379..384
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 419..425

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

    it('as padded number', () => {
    expect(n.format('hh', midnight)).to.equal('00');
    expect(n.format('HH', midnight)).to.equal('00');
    expect(n.format('hh', preNoon)).to.equal('11');
    expect(n.format('HH', preNoon)).to.equal('11');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 372..377
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 419..425

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

    it('as number', () => {
    expect(n.format('s', midnight)).to.equal('0');
    expect(n.format('S', midnight)).to.equal('0');
     
    expect(n.format('s', midnight59)).to.equal('59');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/timeFormat.spec.js and 2 other locations - About 4 hrs to fix
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 372..377
    plugins/q/src/formatter/__tests__/timeFormat.spec.js on lines 379..384
    Category
    Status