jalyna/oakdex-battle

View on GitHub

Showing 8 of 15 total issues

Class Action has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Action
      RECALL_PRIORITY = 7
      ITEM_PRIORITY = 6

      extend Forwardable
Severity: Minor
Found in lib/oakdex/battle/action.rb - About 3 hrs to fix

    Class ActiveInBattlePokemon has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class ActiveInBattlePokemon
          extend Forwardable
    
          def_delegators :@pokemon, :moves_with_pp, :fainted?, :id
          def_delegators :@side, :battle
    Severity: Minor
    Found in lib/oakdex/battle/active_in_battle_pokemon.rb - About 2 hrs to fix

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

            def valid_item_actions_for(trainer)
              return [] if actions.select { |a| a.trainer == trainer }.size >= pokemon_per_trainer
              trainer.items.flat_map do |item_id|
                trainer.team.flat_map.with_index do |pokemon, i|
                  next if actions.any? { |a| a.item_id == item_id }
      Severity: Minor
      Found in lib/oakdex/battle/valid_action_service.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 execute_use_item has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute_use_item
              add_log 'uses_item_on_pokemon', trainer.name, pokemon.name, item_id
              consumed = pokemon.use_item(item_id, in_battle: true)
              trainer.consume_item(item_id) if consumed
              action_id = 0
      Severity: Minor
      Found in lib/oakdex/battle/action.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 execute_stat_modifiers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute_stat_modifiers
              return if move.stat_modifiers.empty?
              move.stat_modifiers.each do |stat_modifier|
                modifier_target = stat_modifier['affects_user'] ? pokemon : target
                stat = stat_modifier['stat']
      Severity: Minor
      Found in lib/oakdex/battle/move_execution.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def execute
              execute_status_conditions(:before_turn)
      
              @actions.each { |a| a.turn = self }
              ordered_actions.each do |action|
      Severity: Minor
      Found in lib/oakdex/battle/turn.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 targets_in_battle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def targets_in_battle(move)
              available_targets(move).map do |targets|
                if targets.last.is_a?(Array)
                  targets if targets_in_battle?(targets)
                elsif target_in_battle?(targets)
      Severity: Minor
      Found in lib/oakdex/battle/active_in_battle_pokemon.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 compare_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def compare_actions(a, b)
              a_prio = a.priority
              b_prio = b.priority
              if a_prio == b_prio && a_prio < 6
                if a.pokemon.speed == b.pokemon.speed
      Severity: Minor
      Found in lib/oakdex/battle/turn.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

      Severity
      Category
      Status
      Source
      Language