halostatue/color

View on GitHub
lib/color/rgb.rb

Summary

Maintainability
D
2 days
Test Coverage

Class RGB has 51 methods (exceeds 20 allowed). Consider refactoring.
Open

class Color::RGB
  include Color

  # The format of a DeviceRGB colour for PDF. In color-tools 2.0 this will
  # be removed from this package and added back as a modification by the
Severity: Major
Found in lib/color/rgb.rb - About 7 hrs to fix

    File rgb.rb has 394 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Color::RGB
      include Color
    
      # The format of a DeviceRGB colour for PDF. In color-tools 2.0 this will
      # be removed from this package and added back as a modification by the
    Severity: Minor
    Found in lib/color/rgb.rb - About 5 hrs to fix

      Method to_hsl has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def to_hsl
          min   = [ @r, @g, @b ].min
          max   = [ @r, @g, @b ].max
          delta = (max - min).to_f
      
      
      Severity: Minor
      Found in lib/color/rgb.rb - About 2 hrs 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

      Method delta_e94 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def delta_e94(color_1, color_2, weighting_type = :graphic_arts)
          case weighting_type
          when :graphic_arts
            k_1 = 0.045
            k_2 = 0.015
      Severity: Minor
      Found in lib/color/rgb.rb - About 1 hr to fix

        Method to_hsl has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def to_hsl
            min   = [ @r, @g, @b ].min
            max   = [ @r, @g, @b ].max
            delta = (max - min).to_f
        
        
        Severity: Minor
        Found in lib/color/rgb.rb - About 1 hr to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def initialize(r = 0, g = 0, b = 0, radix = 255.0, &block) # :yields self:
          Severity: Minor
          Found in lib/color/rgb.rb - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status