qlik-oss/picasso.js

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

Summary

Maintainability
F
5 days
Test Coverage

Showing 12 of 12 total issues

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

import formatter from '../numberFormat';
 
describe('numberFormat', () => {
describe('formatter', () => {
let f;
Severity: Minor
Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js - About 5 hrs to fix

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

    it('should support octal formatting', () => {
    f = formatter('(oct)');
     
    expect(f(0)).to.equal('0');
    expect(f(1)).to.equal('1');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 5 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 355..363

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

    it('should support binary formatting', () => {
    f = formatter('(bin)');
     
    expect(f(0)).to.equal('0');
    expect(f(1)).to.equal('1');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 5 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 345..353

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

    it('should support roman numerals and ignore decimals', () => {
    f = formatter('(ROM)');
     
    expect(f(0.12345)).to.equal('0');
    expect(f(1.2345)).to.equal('I');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 4 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 365..372

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

    it('should support arbitrary base/radix', () => {
    f = formatter('(r04)');
     
    expect(f(0)).to.equal('0');
    expect(f(1)).to.equal('1');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 4 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 411..418

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

    it('should round values correctly when type is "F"', () => {
    f = formatter('0', ',', '.', 'F');
     
    expect(f(0.3)).to.equal('0');
    expect(f(-0.3)).to.equal('0');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 3 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 36..42

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

    it('should round values correctly when type is "I"', () => {
    f = formatter('0', ',', '.', 'I');
     
    expect(f(0.3)).to.equal('0');
    expect(f(-0.3)).to.equal('0');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 3 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 52..58

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

    it('numbers >= 1e15 should always be formatted in scientific notation', () => {
    f = formatter('#', ',', '.');
     
    expect(f(1.123e15)).to.equal('1e+15');
     
     
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 2 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 195..203

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

    it('should ignore grouping if grouping separator is same as decimal separator', () => {
    f = formatter('#.###.###', '.', '.');
     
    expect(f(123456789.987)).to.equal('123456789.987');
     
     
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 1 other location - About 2 hrs to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 26..34

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

    it('should support positive and negative formatting', () => {
    f = formatter('0.0;(0.0)');
     
    expect(f(1.234)).to.equal('1.2');
    expect(f(-1.234)).to.equal('(1.2)');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 2 other locations - About 1 hr to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 308..313
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 431..436

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

    it('should support positive and negative formatting with percentage', () => {
    f = formatter('0.0%;(0.0%)');
     
    expect(f(0.1234)).to.equal('12.3%');
    expect(f(-0.1234)).to.equal('(12.3%)');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 2 other locations - About 1 hr to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 301..306
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 431..436

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

    it('should support roman numerals and return the same format as engine when value > 500000', () => {
    f = formatter('(ROM)');
     
    expect(f(500001)).to.equal('(ROM)5e+5');
    expect(f(-99999999)).to.equal('(ROM)-1e+8');
    Severity: Major
    Found in plugins/q/src/formatter/__tests__/numberFormat.spec.js and 2 other locations - About 1 hr to fix
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 301..306
    plugins/q/src/formatter/__tests__/numberFormat.spec.js on lines 308..313

    There are no issues that match your filters.

    Category
    Status