jordanstephens/paleta

View on GitHub

Showing 13 of 17 total issues

Class Color has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Color
    include Math

    attr_reader :red, :green, :blue, :hue, :saturation, :lightness, :hex

Severity: Minor
Found in lib/paleta/color.rb - About 3 hrs to fix

    Class Palette has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Palette
        include Math
        include Enumerable
    
        attr_accessor :colors
    Severity: Minor
    Found in lib/paleta/palette.rb - About 3 hrs to fix

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

          def initialize(*args)
            if args.length == 1 && args[0].is_a?(Color)
              args[0].instance_variables.each do |key|
                self.send("#{key[1..key.length]}=".to_sym, args[0].send("#{key[1..key.length]}"))
              end
      Severity: Minor
      Found in lib/paleta/color.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 update_hsl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_hsl
            r = @red / 255.0 rescue 0.0
            g = @green / 255.0 rescue 0.0
            b = @blue / 255.0 rescue 0.0
      
      
      Severity: Minor
      Found in lib/paleta/color.rb - About 1 hr 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 add_monochromatic_in_hues_of_color has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.add_monochromatic_in_hues_of_color(palette, color, size)
            raise(ArgumentError, "Second argument is not a Color") unless color.is_a?(Color)
            hues = palette.map { |c| c.hue }
            step = ugap = dgap = 100 / size
            i = j = 0
      Severity: Minor
      Found in lib/paleta/palette.rb - About 1 hr 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 multiple_regression has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def multiple_regression(dx, dy, dz)
          regression = {}
          regression[:slope], regression[:offset] = {}, {}
          size = dx.size
      
      
      Severity: Minor
      Found in lib/paleta/core_ext/math.rb - About 1 hr to fix

        Method generate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.generate(opts = {})
        
              size = opts[:size] || 5
        
              if !opts[:type].nil? && opts[:type].to_sym == :random
        Severity: Minor
        Found in lib/paleta/palette.rb - About 1 hr 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 generate_monochromatic_from_color has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.generate_monochromatic_from_color(color, size)
              raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
              palette = self.new(color)
              step = (100 / size)
              saturation = color.saturation
        Severity: Minor
        Found in lib/paleta/palette.rb - 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

        Method generate_shades_from_color has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.generate_shades_from_color(color, size)
              raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
              palette = self.new(color)
              step = (100 / size)
              lightness = color.lightness
        Severity: Minor
        Found in lib/paleta/palette.rb - 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

        Method generate_analogous_from_color has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.generate_analogous_from_color(color, size)
              raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
              palette = self.new(color)
              step = 20
              below = (size / 2)
        Severity: Minor
        Found in lib/paleta/palette.rb - About 45 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

        Consider simplifying this complex logical expression.
        Open

            unless (a.is_a?(Hash) && b.is_a?(Hash) && a.keys == b.keys) || (a.is_a?(Array) && b.is_a?(Array) && a.size == b.size)
              raise ArgumentError, "Arguments must be Hashes with identical keys or Arrays of the same size"
            end
        Severity: Major
        Found in lib/paleta/core_ext/math.rb - About 40 mins to fix

          Method distance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def distance(a, b)
              unless (a.is_a?(Hash) && b.is_a?(Hash) && a.keys == b.keys) || (a.is_a?(Array) && b.is_a?(Array) && a.size == b.size)
                raise ArgumentError, "Arguments must be Hashes with identical keys or Arrays of the same size"
              end
              sum = 0
          Severity: Minor
          Found in lib/paleta/core_ext/math.rb - 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

          Method update_hex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_hex
                r = @red.to_i.to_s(16) rescue "00"
                g = @green.to_i.to_s(16) rescue "00"
                b = @blue.to_i.to_s(16) rescue "00"
                r = "0#{r}" if r.length < 2
          Severity: Minor
          Found in lib/paleta/color.rb - About 25 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

          Severity
          Category
          Status
          Source
          Language