AndyObtiva/glimmer-dsl-libui

View on GitHub
lib/glimmer/libui.rb

Summary

Maintainability
D
1 day
Test Coverage

Method boolean_to_integer has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def boolean_to_integer(bool, allow_nil: true, allow_integer: true)
        bool.nil? ? (allow_nil ? nil : 0) : (allow_integer && bool.is_a?(Integer) ? bool : (bool.is_a?(TrueClass) || bool.is_a?(FalseClass) ? (bool == true ? 1 : 0) : (allow_nil ? nil : 0)))
      end
Severity: Minor
Found in lib/glimmer/libui.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 interpret_color has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def interpret_color(value)
        if value.is_a?(Array) && value.last.is_a?(Hash)
          options = value.last
          value = value[0...-1]
        end
Severity: Minor
Found in lib/glimmer/libui.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 integer_to_boolean has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

      def integer_to_boolean(int, allow_nil: true, allow_boolean: true)
        int.nil? ? (allow_nil ? nil : false) : (allow_boolean && (int.is_a?(TrueClass) || int.is_a?(FalseClass)) ? int : (int.is_a?(Integer) ? int == 1 : (allow_nil ? nil : false)))
      end
Severity: Minor
Found in lib/glimmer/libui.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 interpret_color has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def interpret_color(value)
        if value.is_a?(Array) && value.last.is_a?(Hash)
          options = value.last
          value = value[0...-1]
        end
Severity: Minor
Found in lib/glimmer/libui.rb - About 1 hr to fix

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

          def timer(time_in_seconds = 0.1, repeat: true, &block)
            closure = fiddle_closure_block_caller(4, [0]) do
              result = boolean_to_integer(block.call, allow_integer: false)
              repeat -= 1 if repeat.is_a?(Integer)
              if result.nil?
    Severity: Minor
    Found in lib/glimmer/libui.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 hex_to_rgb has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def hex_to_rgb(value)
            if value.is_a?(String)
              value = value[2..-1] if value.start_with?('0x')
              value = value[1..-1] if value.start_with?('#')
              value = value.chars.map {|char| [char, char]}.flatten.join if value.length == 3
    Severity: Minor
    Found in lib/glimmer/libui.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 blank_color? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def blank_color?(value)
            value.nil? ||
              (value.respond_to?(:empty?) && value.empty?) ||
              (value.is_a?(Array) && value.compact.empty?) ||
              (value.is_a?(Hash) && value.values.compact.empty?)
    Severity: Minor
    Found in lib/glimmer/libui.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

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

          def enum_symbol_to_value(enum_name, enum_symbol, default_symbol: nil, default_index: 0)
            if enum_symbol.is_a?(Integer)
              enum_symbol
            elsif enum_symbols(enum_name).include?(enum_symbol.to_s.to_sym)
              enum_symbol_values(enum_name)[enum_symbol.to_s.to_sym]
    Severity: Minor
    Found in lib/glimmer/libui.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

    There are no issues that match your filters.

    Category
    Status