polkadot-js/common

View on GitHub
packages/util/src/format/formatBalance.spec.ts

Summary

Maintainability
D
2 days
Test Coverage

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

    it('finds the SI value', (): void => {
      expect(
        formatBalance.findSi('k')
      ).toEqual({ power: 3, text: 'Kilo', value: 'k' });
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 1 other location - About 1 hr to fix
packages/util/src/format/formatBalance.spec.ts on lines 266..270

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 * 1000 (decimals=12)', (): void => {
      expect(
        formatBalance(TESTVAL.muln(1000), { decimals: 12, withSi: true })
      ).toEqual('123.4567 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 1 hr to fix
packages/util/src/format/formatBalance.spec.ts on lines 182..186
packages/util/src/format/formatBalance.spec.ts on lines 188..192

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 * 100 (decimals=12)', (): void => {
      expect(
        formatBalance(TESTVAL.muln(100), { decimals: 12, withSi: true })
      ).toEqual('12.3456 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 1 hr to fix
packages/util/src/format/formatBalance.spec.ts on lines 182..186
packages/util/src/format/formatBalance.spec.ts on lines 194..198

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('returns default on not found', (): void => {
      expect(
        formatBalance.findSi('blah')
      ).toEqual({ power: 0, text: 'Unit', value: '-' });
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 1 other location - About 1 hr to fix
packages/util/src/format/formatBalance.spec.ts on lines 260..264

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 * 10 (decimals=12)', (): void => {
      expect(
        formatBalance(TESTVAL.muln(10), { decimals: 12, withSi: true })
      ).toEqual('1.2345 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 1 hr to fix
packages/util/src/format/formatBalance.spec.ts on lines 188..192
packages/util/src/format/formatBalance.spec.ts on lines 194..198

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 56.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=9, no unit)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 9, withSi: true, withUnit: false })
      ).toEqual('123.4567');
    });
Severity: Minor
Found in packages/util/src/format/formatBalance.spec.ts and 1 other location - About 55 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 152..156

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=0, unit specified)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 0, withSi: true, withUnit: 'BAR' })
      ).toEqual('123.4567 BBAR');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 55 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 134..138
packages/util/src/format/formatBalance.spec.ts on lines 170..174

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=12, full SI, no unit)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 12, withSiFull: true, withUnit: false })
      ).toEqual('123.4567 milli');
    });
Severity: Minor
Found in packages/util/src/format/formatBalance.spec.ts and 1 other location - About 55 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 128..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=9, unit given)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 9, withSi: true, withUnit: 'FOO' })
      ).toEqual('123.4567 FOO');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 55 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 170..174
packages/util/src/format/formatBalance.spec.ts on lines 176..180

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=6, unit specified)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 6, withSi: true, withUnit: 'BAR' })
      ).toEqual('123.4567 kBAR');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 55 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 134..138
packages/util/src/format/formatBalance.spec.ts on lines 176..180

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 53.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=6)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 6, withSi: true })
      ).toEqual('123.4567 kUnit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=15, forceUnit=micro)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 15, forceUnit: 'µ' })
      ).toEqual('123.4567 µUnit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 3 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 208..212
packages/util/src/format/formatBalance.spec.ts on lines 214..218
packages/util/src/format/formatBalance.spec.ts on lines 220..224

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456 (decimals=0)', (): void => {
      expect(
        formatBalance(123456, { decimals: 0, withSi: true })
      ).toEqual('123.4560 kUnit');
    });
Severity: Minor
Found in packages/util/src/format/formatBalance.spec.ts and 2 other locations - About 40 mins to fix
packages/util/src/bi/toHex.spec.ts on lines 33..37
packages/util/src/bi/toHex.spec.ts on lines 39..43

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=9)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 9, withSi: true })
      ).toEqual('123.4567 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=9, full SI)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 9, withSiFull: true })
      ).toEqual('123.4567 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=15)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 15, withSi: true })
      ).toEqual('123.4567 µUnit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=12)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 12, withSi: true })
      ).toEqual('123.4567 mUnit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=15, old style)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 15, withSi: true })
      ).toEqual('123.4567 µUnit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=12, no SI)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 12, withSi: false })
      ).toEqual('123.4567');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 146..150
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=7, forceUnit=base)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 7, forceUnit: '-' })
      ).toEqual('12,345.6789 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 3 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 208..212
packages/util/src/format/formatBalance.spec.ts on lines 214..218
packages/util/src/format/formatBalance.spec.ts on lines 226..230

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=12, full SI)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 12, withSiFull: true })
      ).toEqual('123.4567 milli Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 7 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 62..66
packages/util/src/format/formatBalance.spec.ts on lines 80..84
packages/util/src/format/formatBalance.spec.ts on lines 116..120
packages/util/src/format/formatBalance.spec.ts on lines 122..126
packages/util/src/format/formatBalance.spec.ts on lines 140..144
packages/util/src/format/formatBalance.spec.ts on lines 158..162
packages/util/src/format/formatBalance.spec.ts on lines 164..168

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=9, forceUnit=base)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 9, forceUnit: '-' })
      ).toEqual('123.4567 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 3 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 208..212
packages/util/src/format/formatBalance.spec.ts on lines 220..224
packages/util/src/format/formatBalance.spec.ts on lines 226..230

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    it('formats 123,456,789,000 (decimals=12, forceUnit=base)', (): void => {
      expect(
        formatBalance(TESTVAL, { decimals: 12, forceUnit: '-' })
      ).toEqual('0.1234 Unit');
    });
Severity: Major
Found in packages/util/src/format/formatBalance.spec.ts and 3 other locations - About 40 mins to fix
packages/util/src/format/formatBalance.spec.ts on lines 214..218
packages/util/src/format/formatBalance.spec.ts on lines 220..224
packages/util/src/format/formatBalance.spec.ts on lines 226..230

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

There are no issues that match your filters.

Category
Status