bcdice/BCDice

View on GitHub
lib/bcdice/game_system/PhantasmAdventure.rb

Summary

Maintainability
B
6 hrs
Test Coverage
C
77%

Method result_1d20 has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

      def result_1d20(total, _dice_total, cmp_op, diff)
        return Result.nothing if diff == '?'
        return nil unless cmp_op == :<=

        # 技能値の修正を計算する
Severity: Minor
Found in lib/bcdice/game_system/PhantasmAdventure.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 result_1d20 has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def result_1d20(total, _dice_total, cmp_op, diff)
        return Result.nothing if diff == '?'
        return nil unless cmp_op == :<=

        # 技能値の修正を計算する
Severity: Minor
Found in lib/bcdice/game_system/PhantasmAdventure.rb - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

              return Result.critical("決定的成功(#{dice_now}+#{skill_mod}=#{crit_num})")
    Severity: Major
    Found in lib/bcdice/game_system/PhantasmAdventure.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                return Result.success("成功")
      Severity: Major
      Found in lib/bcdice/game_system/PhantasmAdventure.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return Result.failure("失敗")
        Severity: Major
        Found in lib/bcdice/game_system/PhantasmAdventure.rb - About 30 mins to fix

          There are no issues that match your filters.

          Category
          Status