AndyObtiva/glimmer-dsl-swt

View on GitHub
lib/glimmer/swt/style_constantizable.rb

Summary

Maintainability
C
7 hrs
Test Coverage
F
31%

Method constant has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

        def constant(symbol)
          return symbol unless symbol.is_a?(Symbol) || symbol.is_a?(String)
          symbol_string, negative = extract_symbol_string_negativity(symbol)
          swt_constant_symbol = symbol_string.downcase == symbol_string ? symbol_string.upcase.to_sym : symbol_string.to_sym
          bit_value = constant_source_class.const_get(swt_constant_symbol)
Severity: Minor
Found in lib/glimmer/swt/style_constantizable.rb - About 4 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 [] has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def [](*symbols)
          symbols = symbols.first if symbols.size == 1 && symbols.first.is_a?(Array)
          result = symbols.compact.map do |symbol|
            constant(symbol).tap do |constant_value|
              raise Glimmer::Error, symbol.to_s + error_message_invalid_style unless constant_value.is_a?(Integer)
Severity: Minor
Found in lib/glimmer/swt/style_constantizable.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

Avoid deeply nested control flow statements.
Open

                negative ? ~bit_value : bit_value
Severity: Major
Found in lib/glimmer/swt/style_constantizable.rb - About 45 mins to fix

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

            def deconstruct(integer)
              constant_source_class.constants.reduce([]) do |found, c|
                constant_value = constant_source_class.const_get(c) rescue -1
                is_found = constant_value.is_a?(Integer) && (integer & constant_value) == constant_value
                is_found ? found += [c] : found
    Severity: Minor
    Found in lib/glimmer/swt/style_constantizable.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 reverse_lookup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def reverse_lookup(integer)
              # TODO support looking up compound style mixes
              constant_source_class.constants.reduce([]) do |found, c|
                constant_value = constant_source_class.const_get(c) rescue -1
                is_found = constant_value.is_a?(Integer) && integer == constant_value
    Severity: Minor
    Found in lib/glimmer/swt/style_constantizable.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