kolory/color-utilities

View on GitHub

Showing 7 of 25 total issues

ColorUtilities has 40 functions (exceeds 20 allowed). Consider refactoring.
Open

export class ColorUtilities {
  /**
   * A factory method for obtaining an instance of the service.
   * @returns {ColorUtilities} An instance of the service.
   */
Severity: Minor
Found in src/library.ts - About 5 hrs to fix

    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

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

      import {hexColor, hexColorValues, colorValues, rgbColor, basicColor, hslColor} from './types'
      import {ColorTypes} from './color-types-enum'
      
      /**
       * Utility library for parsing colors, validation, normalization and some other useful features.
      Severity: Minor
      Found in src/library.ts - About 2 hrs to fix

        Function convertValuesToHsl has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          private convertValuesToHsl(values: colorValues): hslColor {
            /* tslint:disable:cyclomatic-complexity */
            const [r, g, b] = values.map(v => v / 255)
            const M = Math.max(r, g, b)
            const m = Math.min(r, g, b)
        Severity: Minor
        Found in src/library.ts - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function splitHslColor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          splitHslColor(hslColor: hslColor): colorValues {
            const [hue, saturation, lightness] = this.getValues(hslColor).map(Number)
            const normalizedSaturation = saturation / 100
            const normalizedLightness = lightness / 100
        
        
        Severity: Minor
        Found in src/library.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid too many return statements within this function.
        Open

                return [X, 0, C]
        Severity: Major
        Found in src/library.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return [C, 0, X]
          Severity: Major
          Found in src/library.ts - About 30 mins to fix
            Severity
            Category
            Status
            Source
            Language