shawn42/gamebox

View on GitHub
lib/gamebox/core/input_manager.rb

Summary

Maintainability
C
1 day
Test Coverage

Method handle_event has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_event(gosu_id, action) #:nodoc:
    @window.close if @auto_quit && gosu_id == @auto_quit
    if action == :down
      @down_ids[gosu_id] = true 
    else
Severity: Minor
Found in lib/gamebox/core/input_manager.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 handle_event has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def handle_event(gosu_id, action) #:nodoc:
    @window.close if @auto_quit && gosu_id == @auto_quit
    if action == :down
      @down_ids[gosu_id] = true 
    else
Severity: Minor
Found in lib/gamebox/core/input_manager.rb - About 1 hr to fix

    Method fire_event has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def fire_event(event)
        fire :event_received, event
    
        # fix for pause bug?
        @hooks ||= {}
    Severity: Minor
    Found in lib/gamebox/core/input_manager.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 _register_hook has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def _register_hook(listener, event_class, *event_ids, &block)
        return unless block_given?
        @hooks[event_class] ||= {}
        for event_id in event_ids
          @uses_mouse = true if event_id >= MsRangeBegin && event_id <= MsRangeEnd
    Severity: Minor
    Found in lib/gamebox/core/input_manager.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 unregister_hook has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def unregister_hook(event_class, *event_ids, &block)
        event_class = :down if DOWN_EVENTS.include? event_class
        event_class = :up if UP_EVENTS.include? event_class
        @hooks[event_class] ||= {}
        for event_id in event_ids
    Severity: Minor
    Found in lib/gamebox/core/input_manager.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 register has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def register(game)
        @window.when :button_up do |button_id|
          handle_event button_id, :up
        end
        @window.when :button_down do |button_id|
    Severity: Minor
    Found in lib/gamebox/core/input_manager.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 clear_hooks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def clear_hooks(listener=nil)
        if listener
          for event_klass, id_listeners in @hooks
            for key in id_listeners.keys.dup
              id_listeners[key].delete_if do |block|
    Severity: Minor
    Found in lib/gamebox/core/input_manager.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

    There are no issues that match your filters.

    Category
    Status