kolory/color-utilities

View on GitHub
src/library.spec.ts

Summary

Maintainability
F
3 days
Test Coverage

File library.spec.ts has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {ColorUtilities} from './library'
import {ColorTypes} from './color-types-enum'
import {
  invalidHslColors, invalidRgbColors, invalidHexColors, strictlyValidHexColors,
  validRgbColors, validHslColors, basicHexColor
Severity: Minor
Found in src/library.spec.ts - About 2 hrs to fix

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

        it('should have a specific RGB conversion method accepting string or basicColor', () => {
          expect(colorUtil.convertToRgb('#FFA500')).toBe('rgb(255, 165, 0)')
          expect(colorUtil.convertToRgb('#000000')).toBe('rgb(0, 0, 0)')
          expect(colorUtil.convertToRgb('#FFFFFF')).toBe('rgb(255, 255, 255)')
          expect(colorUtil.convertToRgb('hsl(253, 98%, 47%)')).toBe('rgb(53, 2, 237)')
    Severity: Major
    Found in src/library.spec.ts and 1 other location - About 5 hrs to fix
    src/library.spec.ts on lines 121..128

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

    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 have a specific HEX conversion method accepting string or basicColor', () => {
          expect(colorUtil.convertToHex('rgb(255, 165, 0)')).toBe('#FFA500')
          expect(colorUtil.convertToHex('rgb(0, 0, 0)')).toBe('#000000')
          expect(colorUtil.convertToHex('rgb(255, 255, 255)')).toBe('#FFFFFF')
          expect(colorUtil.convertToHex('hsl(253, 98%, 47%)')).toBe('#3502ED')
    Severity: Major
    Found in src/library.spec.ts and 1 other location - About 5 hrs to fix
    src/library.spec.ts on lines 130..137

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

    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 validate RGB colors', () => {
          validRgbColors.forEach(color => expect(colorUtil.isValidRgbColor(color)).toBeTruthy())
          invalidRgbColors.forEach(color => expect(colorUtil.isValidRgbColor(color)).toBeFalsy())
          expect(colorUtil.isValidRgbColor(undefined)).toBeFalsy()
          expect(colorUtil.isValidRgbColor('')).toBeFalsy()
    Severity: Major
    Found in src/library.spec.ts and 1 other location - About 4 hrs to fix
    src/library.spec.ts on lines 241..246

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

    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 validate HSL colors', () => {
          validHslColors.forEach(color => expect(colorUtil.isValidHslColor(color)).toBeTruthy())
          invalidHslColors.forEach(color => expect(colorUtil.isValidHslColor(color)).toBeFalsy())
          expect(colorUtil.isValidHslColor(undefined)).toBeFalsy()
          expect(colorUtil.isValidHslColor('')).toBeFalsy()
    Severity: Major
    Found in src/library.spec.ts and 1 other location - About 4 hrs to fix
    src/library.spec.ts on lines 234..239

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

    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 allow creating an instance using the `new` operator and as from a factory', () => {
          expect(new ColorUtilities()).toBeDefined()
          expect(ColorUtilities.create() instanceof ColorUtilities).toBeTruthy()
        })
    Severity: Major
    Found in src/library.spec.ts and 1 other location - About 1 hr to fix
    src/color.spec.ts on lines 22..25

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

    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 not handle invalid RGB colors', () => {
          invalidRgbColors.forEach(invalidColor =>
            expect(() => colorUtil.normalizeRgbColor(invalidColor)).toThrowError(TypeError))
        })
    Severity: Major
    Found in src/library.spec.ts and 2 other locations - About 50 mins to fix
    src/library.spec.ts on lines 284..287
    src/library.spec.ts on lines 308..311

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

    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 not handle invalid HSL colors', () => {
          invalidHslColors.forEach(invalidColor =>
            expect(() => colorUtil.normalizeHslColor(invalidColor)).toThrowError(TypeError))
        })
    Severity: Major
    Found in src/library.spec.ts and 2 other locations - About 50 mins to fix
    src/library.spec.ts on lines 284..287
    src/library.spec.ts on lines 296..299

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

    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 not handle invalid hex colors', () => {
          invalidHexColors.forEach(invalidColor =>
            expect(() => colorUtil.normalizeHexColor(invalidColor)).toThrowError(TypeError))
        })
    Severity: Major
    Found in src/library.spec.ts and 2 other locations - About 50 mins to fix
    src/library.spec.ts on lines 296..299
    src/library.spec.ts on lines 308..311

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

    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