jordanstephens/paleta

View on GitHub
lib/paleta/palette.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    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

    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

          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

    There are no issues that match your filters.

    Category
    Status