Compass/compass

View on GitHub
core/lib/compass/core/sass_extensions/functions/gradient_support.rb

Summary

Maintainability
F
4 days
Test Coverage

File gradient_support.rb has 721 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Compass::Core::SassExtensions::Functions::GradientSupport

  GRADIENT_ASPECTS = %w(webkit moz svg css2 o owg).freeze

  class CSS3AngleToSVGConverter
Severity: Major
Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 1 day to fix

    Method normalize_stops has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_stops(color_list)
          positions = color_list.value.map{|obj| obj.dup}
          # fill in the start and end positions, if unspecified
          positions.first.stop = number(0) unless positions.first.stop
          positions.last.stop = number(100, "%") unless positions.last.stop
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 3 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 handle_keywords has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_keywords(angle)
          if angle.is_a?(Sass::Script::Value::List) || angle.is_a?(Sass::Script::Value::String)
            direction = angle.to_sass
            is_end_point = !!/\bto\b/i.match(direction)
            dir = 0
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 grad_position has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def grad_position(color_list, index, default, radial = bool(false))
          assert_type color_list, :List
          stop = color_list.value[index.value - 1].stop
          if stop && radial.to_bool
            orig_stop = stop
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 grad_point has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def grad_point(position)
          original_value = position
          position = unless position.is_a?(Sass::Script::Value::List)
            opts(list([position], :space))
          else
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 grad_point has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def grad_point(position)
          original_value = position
          position = unless position.is_a?(Sass::Script::Value::List)
            opts(list([position], :space))
          else
    Severity: Minor
    Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 1 hr to fix

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

          def normalize_stops(color_list)
            positions = color_list.value.map{|obj| obj.dup}
            # fill in the start and end positions, if unspecified
            positions.first.stop = number(0) unless positions.first.stop
            positions.last.stop = number(100, "%") unless positions.last.stop
      Severity: Minor
      Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 1 hr to fix

        Method radial_gradient has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def radial_gradient(position_or_angle, shape_and_size, *color_stops)
              # Have to deal with variable length/meaning arguments.
              if color_stop?(shape_and_size)
                color_stops.unshift(shape_and_size)
                shape_and_size = nil
        Severity: Minor
        Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 1 hr to fix

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

              def list_of_color_stops?(arg)
                if arg.respond_to?(:value)
                  arg.value.is_a?(Array) && arg.value.all?{|a| color_stop?(a)} ? arg.value : nil
                elsif arg.is_a?(Array)
                  arg.all?{|a| color_stop?(a)} ? arg : nil
          Severity: Minor
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 convert_angle_from_offical has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def convert_angle_from_offical(deg)
                if deg.is_a?(Sass::Script::Value::Number)
                  return number((deg.value.to_f - 450).abs % 360, 'deg')
                else
                  args = deg.value
          Severity: Minor
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 radial_gradient has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def radial_gradient(position_or_angle, shape_and_size, *color_stops)
                # Have to deal with variable length/meaning arguments.
                if color_stop?(shape_and_size)
                  color_stops.unshift(shape_and_size)
                  shape_and_size = nil
          Severity: Minor
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 color_stops has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def color_stops(*args)
                opts(list(args.map do |arg|
                  if ColorStop === arg
                    arg
                  elsif Sass::Script::Value::Color === arg
          Severity: Minor
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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

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

              def color_stops_in_percentages(color_list)
                assert_type color_list, :List
                color_list = normalize_stops(color_list)
                max = color_list.value.last.stop
                last_value = nil
          Severity: Minor
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 Sass::Script::Value::Color === color ||
                       Sass::Script::Tree::Funcall === color ||
                       (Sass::Script::Value::String === color && color.value == "currentColor")||
                       (Sass::Script::Value::String === color && color.value == "transparent")
                  raise Sass::SyntaxError, "Expected a color. Got: #{color}"
          Severity: Major
          Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 40 mins to fix

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

                def linear_svg(color_stops, x1, y1, x2, y2)
            Severity: Minor
            Found in core/lib/compass/core/sass_extensions/functions/gradient_support.rb - About 35 mins to fix

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

                  def parse_color_stop(arg)
                    return ColorStop.new(arg) if arg.is_a?(Sass::Script::Value::Color)
                    return nil unless arg.is_a?(Sass::Script::Value::String)
                    color = stop = nil
                    expr = Sass::Script::Parser.parse(arg.value, 0, 0)
              Severity: Minor
              Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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 assert_legal_color! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def assert_legal_color!(color)
                    unless Sass::Script::Value::Color === color ||
                           Sass::Script::Tree::Funcall === color ||
                           (Sass::Script::Value::String === color && color.value == "currentColor")||
                           (Sass::Script::Value::String === color && color.value == "transparent")
              Severity: Minor
              Found in core/lib/compass/core/sass_extensions/functions/gradient_support.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

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

                  def new_standard_arguments(options = self.options)
                    if shape_and_size
                      "#{array_to_s(shape_and_size, options)} at #{array_to_s(position, options)}, #{array_to_s(color_stops, options)}"
                    elsif position
                      "#{array_to_s(position, options)}, #{array_to_s(color_stops, options)}"
              core/lib/compass/core/sass_extensions/functions/gradient_support.rb on lines 343..350

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

              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 old_standard_arguments(options = self.options)
                    if shape_and_size
                      "#{array_to_s(position, options)}, #{array_to_s(shape_and_size, options)}, #{array_to_s(color_stops, options)}"
                    elsif position
                      "#{array_to_s(position, options)}, #{array_to_s(color_stops, options)}"
              core/lib/compass/core/sass_extensions/functions/gradient_support.rb on lines 333..340

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

              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 to_s_prefixed(options = self.options)
                    s = "linear-gradient("
                    if legacy
                      s << position_or_angle.to_s(options) << ", " if position_or_angle
                    else
              core/lib/compass/core/sass_extensions/functions/gradient_support.rb on lines 411..419

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

              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 to_s(options = self.options)
                    s = 'linear-gradient('
                    if legacy
                      s << convert_to_or_from_legacy(position_or_angle, options) << ", " if position_or_angle
                    else
              core/lib/compass/core/sass_extensions/functions/gradient_support.rb on lines 391..399

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

              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