AndyObtiva/glimmer-dsl-libui

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

Summary

Maintainability
D
2 days
Test Coverage

Class ControlProxy has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ControlProxy
      class << self
        def exists?(keyword)
          ::LibUI.respond_to?("new_#{keyword}") or
            ::LibUI.respond_to?(keyword) or
Severity: Minor
Found in lib/glimmer/libui/control_proxy.rb - About 6 hrs to fix

    File control_proxy.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'glimmer/libui/data_bindable'
    
    module Glimmer
      module LibUI
        # Proxy for LibUI control objects
    Severity: Minor
    Found in lib/glimmer/libui/control_proxy.rb - About 4 hrs to fix

      Method send_to_libui has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

            def send_to_libui(method_name, *args, &block)
              if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
                property = method_name.to_s.sub(/\?$/, '')
                value = ::LibUI.send("#{libui_api_keyword}_#{property}", libui, *args)
                handle_string_property(property, handle_boolean_property(property, value))
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy.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 send_to_libui has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def send_to_libui(method_name, *args, &block)
              if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
                property = method_name.to_s.sub(/\?$/, '')
                value = ::LibUI.send("#{libui_api_keyword}_#{property}", libui, *args)
                handle_string_property(property, handle_boolean_property(property, value))
      Severity: Minor
      Found in lib/glimmer/libui/control_proxy.rb - About 1 hr to fix

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

              def initialize(keyword, parent, args, &block)
                @keyword = keyword
                @custom_control = CustomControl.custom_controls_being_interpreted.last
                @parent_custom_control = parent if parent.is_a?(CustomControl)
                @parent_proxy = parent.is_a?(CustomControl) ? parent.body_root : parent
        Severity: Minor
        Found in lib/glimmer/libui/control_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

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

              def handle_listener(listener_name, &listener)
                # replace first listener argument (control libui pointer) with actual Ruby libui object
                safe_listener = Proc.new { |*args| listener.call(self, *args[1..-1]) }
                if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
                  if listeners[listener_name].nil?
        Severity: Minor
        Found in lib/glimmer/libui/control_proxy.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 append_property has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def append_property(property, value = nil)
                property = property.to_s.sub(/(=|\?)$/, '')
                @append_property_hash ||= {}
                if value.nil?
                  value = @append_property_hash[property]
        Severity: Minor
        Found in lib/glimmer/libui/control_proxy.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 visible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def visible(value = nil)
                current_value = send_to_libui('visible')
                if value.nil?
                  current_value
                elsif value != current_value
        Severity: Minor
        Found in lib/glimmer/libui/control_proxy.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 enabled has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def enabled(value = nil)
                if value.nil?
                  @enabled
                elsif value != @enabled
                  @enabled = value == 1 || value
        Severity: Minor
        Found in lib/glimmer/libui/control_proxy.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