AndyObtiva/glimmer-dsl-libui

View on GitHub
lib/glimmer/libui/control_proxy/path_proxy.rb

Summary

Maintainability
C
1 day
Test Coverage

Method stroke has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def stroke(*args)
          args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
          if args.empty?
            @stroke ||= {}
          else
Severity: Minor
Found in lib/glimmer/libui/control_proxy/path_proxy.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 fill has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def fill(*args)
          args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
          if args.empty?
            @fill ||= {}
          else
Severity: Minor
Found in lib/glimmer/libui/control_proxy/path_proxy.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 init_draw_brush has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def init_draw_brush(draw_brush, draw_brush_args)
          if draw_brush_args[:r] || draw_brush_args[:g] || draw_brush_args[:b] || draw_brush_args[:a]
            draw_brush_args[:type] ||= :solid
          elsif draw_brush_args[:outer_radius]
            draw_brush_args[:type] ||= :radial_gradient
Severity: Minor
Found in lib/glimmer/libui/control_proxy/path_proxy.rb - About 1 hr to fix

    Method init_draw_brush has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def init_draw_brush(draw_brush, draw_brush_args)
              if draw_brush_args[:r] || draw_brush_args[:g] || draw_brush_args[:b] || draw_brush_args[:a]
                draw_brush_args[:type] ||= :solid
              elsif draw_brush_args[:outer_radius]
                draw_brush_args[:type] ||= :radial_gradient
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy/path_proxy.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

    Consider simplifying this complex logical expression.
    Open

              if draw_brush.Type == 0
                draw_brush.R = (draw_brush_args[:r] || draw_brush_args[:red]).to_f / 255.0
                draw_brush.G = (draw_brush_args[:g] || draw_brush_args[:green]).to_f / 255.0
                draw_brush.B = (draw_brush_args[:b] || draw_brush_args[:blue]).to_f / 255.0
                draw_brush.A = (draw_brush_args[:a] || draw_brush_args[:alpha] || 1.0)
    Severity: Major
    Found in lib/glimmer/libui/control_proxy/path_proxy.rb - About 1 hr to fix

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

              def draw_fill_mode
                @args[0].is_a?(Integer) ? (@args[0] == 0 ? :winding : :alternate ) : ((@args[0].is_a?(String) || @args[0].is_a?(Symbol)) ? @args[0].to_sym : :winding)
              end
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy/path_proxy.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 perfect_shape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def perfect_shape
                require 'perfect-shape'
                the_perfect_shape_dependencies = perfect_shape_dependencies
                if the_perfect_shape_dependencies != @perfect_shape_dependencies
                  draw_fill_mode, _ = @perfect_shape_dependencies = the_perfect_shape_dependencies
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy/path_proxy.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

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

                args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
                if args.empty?
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy/path_proxy.rb and 1 other location - About 20 mins to fix
      lib/glimmer/libui/control_proxy/path_proxy.rb on lines 73..74

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

      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

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

                args = args.first if args.size == 1 && (args.first.is_a?(Array) || args.first.is_a?(Hash) || args.first.is_a?(String) || args.first.is_a?(Symbol))
                if args.empty?
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy/path_proxy.rb and 1 other location - About 20 mins to fix
      lib/glimmer/libui/control_proxy/path_proxy.rb on lines 102..103

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

      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