jordanstephens/paleta

View on GitHub

Showing 17 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

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

            def self.generate_triad_from_color(color, size)
              raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
              color2 = Paleta::Color.new(:hsl, (color.hue + 120) % 360, color.saturation, color.lightness)
              color3 = Paleta::Color.new(:hsl, (color2.hue + 120) % 360, color2.saturation, color2.lightness)
              palette = self.new(color, color2, color3)
        Severity: Major
        Found in lib/paleta/palette.rb and 1 other location - About 1 hr to fix
        lib/paleta/palette.rb on lines 310..315

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

        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

            def self.generate_split_complement_from_color(color, size)
              raise(ArgumentError, "Passed argument is not a Color") unless color.is_a?(Color)
              color2 = Paleta::Color.new(:hsl, (color.hue + 150) % 360, color.saturation, color.lightness)
              color3 = Paleta::Color.new(:hsl, (color2.hue + 60) % 360, color2.saturation, color2.lightness)
              palette = self.new(color, color2, color3)
        Severity: Major
        Found in lib/paleta/palette.rb and 1 other location - About 1 hr to fix
        lib/paleta/palette.rb on lines 257..262

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

        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

        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

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

                below.times do |i|
                  hue = color.hue - ((i + 1) * step)
                  hue += 360 if hue < 0
                  palette << Paleta::Color.new(:hsl, hue, color.saturation, color.lightness)
          Severity: Minor
          Found in lib/paleta/palette.rb and 1 other location - About 30 mins to fix
          lib/paleta/palette.rb on lines 242..245

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

          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

                above.times do |i|
                  hue = color.hue + ((i + 1) * step)
                  hue -= 360 if hue > 360
                  palette << Paleta::Color.new(:hsl, hue, color.saturation, color.lightness)
          Severity: Minor
          Found in lib/paleta/palette.rb and 1 other location - About 30 mins to fix
          lib/paleta/palette.rb on lines 237..240

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

          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

          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