RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/lib/convertTimeUnit.spec.ts

Summary

Maintainability
F
3 days
Test Coverage

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

    it('should throw an error for invalid timespan', () => {
        const errorMessage = 'timeUnitToMs - invalid timespan';
        expect(() => timeUnitToMs(TIMEUNIT.days, NaN)).toThrow(errorMessage);
        expect(() => timeUnitToMs(TIMEUNIT.days, Infinity)).toThrow(errorMessage);
        expect(() => timeUnitToMs(TIMEUNIT.days, -Infinity)).toThrow(errorMessage);
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 1 other location - About 4 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 58..64

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 132.

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('should throw an error for invalid timespan', () => {
        const errorMessage = 'msToTimeUnit - invalid timespan';
        expect(() => msToTimeUnit(TIMEUNIT.days, NaN)).toThrow(errorMessage);
        expect(() => msToTimeUnit(TIMEUNIT.days, Infinity)).toThrow(errorMessage);
        expect(() => msToTimeUnit(TIMEUNIT.days, -Infinity)).toThrow(errorMessage);
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 1 other location - About 4 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 26..32

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 132.

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('should correctly convert milliseconds to days', () => {
        expect(msToTimeUnit(TIMEUNIT.days, 86400000)).toBe(1); // 1 day
        expect(msToTimeUnit(TIMEUNIT.days, 172800000)).toBe(2); // 2 days
        expect(msToTimeUnit(TIMEUNIT.days, 43200000)).toBe(0.5); // .5 days
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 3 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 42..46
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 48..52

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 95.

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('should correctly convert milliseconds to hours', () => {
        expect(msToTimeUnit(TIMEUNIT.hours, 3600000)).toBe(1); // 1 hour
        expect(msToTimeUnit(TIMEUNIT.hours, 7200000)).toBe(2); // 2 hours
        expect(msToTimeUnit(TIMEUNIT.hours, 1800000)).toBe(0.5); // .5 hours
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 3 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 36..40
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 48..52

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 95.

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('should correctly convert milliseconds to minutes', () => {
        expect(msToTimeUnit(TIMEUNIT.minutes, 60000)).toBe(1); // 1 min
        expect(msToTimeUnit(TIMEUNIT.minutes, 120000)).toBe(2); // 2 min
        expect(msToTimeUnit(TIMEUNIT.minutes, 30000)).toBe(0.5); // .5 min
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 3 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 36..40
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 42..46

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 95.

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('should correctly convert days to milliseconds', () => {
        expect(timeUnitToMs(TIMEUNIT.days, 1)).toBe(86400000);
        expect(timeUnitToMs(TIMEUNIT.days, 2)).toBe(172800000);
        expect(timeUnitToMs(TIMEUNIT.days, 0.5)).toBe(43200000);
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 2 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 10..14
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 16..20

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 85.

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('should correctly convert hours to milliseconds', () => {
        expect(timeUnitToMs(TIMEUNIT.hours, 1)).toBe(3600000);
        expect(timeUnitToMs(TIMEUNIT.hours, 2)).toBe(7200000);
        expect(timeUnitToMs(TIMEUNIT.hours, 0.5)).toBe(1800000);
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 2 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 4..8
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 16..20

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 85.

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('should correctly convert minutes to milliseconds', () => {
        expect(timeUnitToMs(TIMEUNIT.minutes, 1)).toBe(60000);
        expect(timeUnitToMs(TIMEUNIT.minutes, 2)).toBe(120000);
        expect(timeUnitToMs(TIMEUNIT.minutes, 0.5)).toBe(30000);
    });
Severity: Major
Found in apps/meteor/client/lib/convertTimeUnit.spec.ts and 2 other locations - About 2 hrs to fix
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 4..8
apps/meteor/client/lib/convertTimeUnit.spec.ts on lines 10..14

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 85.

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