bcdice/BCDice

View on GitHub

Showing 809 of 1,233 total issues

Avoid too many return statements within this method.
Open

        return 'Average(そこそこ)' if stepTotal >= average
Severity: Major
Found in lib/bcdice/game_system/EarthDawn3.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return nil
    Severity: Major
    Found in lib/bcdice/common_command/choice.rb - About 30 mins to fix

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

            def parse_nw(string)
              m = /^([-+]?\d+)?#{@nw_command}((?:[-+]\d+)+)?(?:@(\d+(?:,\d+)*))?(?:#(\d+(?:,\d+)*))?(?:\$(\d+))?((?:[-+]\d+)+)?(?:([>=]+)(\d+))?$/.match(string)
              unless m
                return nil
              end
      Severity: Minor
      Found in lib/bcdice/game_system/NightWizard.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 judge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def judge(target, total)
              double = (total / 10) == (total % 10)
              total_text = format00(total)
              if total <= target
                double ? Result.critical("(#{total_text})クリティカル") : Result.success("(#{total_text})成功")
      Severity: Minor
      Found in lib/bcdice/game_system/AssaultEngine.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 roll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def roll(cr, modifier, randomizer)
                return nil if cr == 0 && modifier == 0
      
                index =
                  if cr == 0 && modifier != 0
      Severity: Minor
      Found in lib/bcdice/game_system/LogHorizon.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 pick_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def pick_item(index)
                if index <= 6
                  translate("LogHorizon.TRS.below_lower_limit", value: 6) # 6以下の出目は未定義です
                elsif index <= 62
                  @items[index]
      Severity: Minor
      Found in lib/bcdice/game_system/LogHorizon.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 roll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def roll(randomizer)
                dice = randomizer.roll_once(@items.length)
                chosen = @items[dice - 1]
      
                critical = chosen == CRITICAL
      Severity: Minor
      Found in lib/bcdice/game_system/KamitsubakiCityUnderConstructionNarrative.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 getBulletResults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def getBulletResults(bullet_count, hit_type, diff)
              bullet_set_count = getSetOfBullet(diff)
              hit_bullet_count_base = getHitBulletCountBase(diff, bullet_set_count)
              impale_bullet_count_base = (bullet_set_count / 2.to_f)
      
      
      Severity: Minor
      Found in lib/bcdice/game_system/Cthulhu7th_Korean.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 return_result has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def return_result(result1, result2, text)
              if result1.critical? || result2.critical?
                Result.critical(text)
              elsif result1.success? || result2.success?
                Result.success(text)
      Severity: Minor
      Found in lib/bcdice/game_system/AssaultEngine.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 roll_ot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def roll_ot(command)
              m = /^(\d+)OT>=(\d+)$/.match(command)
              return nil unless m
      
              times = m[1].to_i
      Severity: Minor
      Found in example/OnseTool.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 eval_game_system_specific_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def eval_game_system_specific_command(command)
              cmd = Command::Parser.new(/AES?/, round_type: round_type).enable_prefix_number
                                   .has_suffix_number.parse(command)
              return nil unless cmd
      
      
      Severity: Minor
      Found in lib/bcdice/game_system/AssaultEngine.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 pick_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def pick_item(index)
                if index <= 6
                  translate("LogHorizon.TRS.below_lower_limit", value: 6)
                elsif index <= 162
                  @items[index]
      Severity: Minor
      Found in lib/bcdice/game_system/LogHorizon.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 check_roll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_roll(command)
              m = /^(\d+)?ATK([1-6]{0,6})$/.match(command)
              return nil unless m
      
              dice_count = m[1]&.to_i || 1
      Severity: Minor
      Found in lib/bcdice/game_system/LiveraDoll.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 parse_2r6 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_2r6(string)
              m = /^2R6m\[([-+]?\d+(?:[-+]\d+)*)(?:,([-+]?\d+(?:[-+]\d+)*))?\](?:c\[(\d+(?:,\d+)*)\])?(?:f\[(\d+(?:,\d+)*)\])?(?:([>=]+)(\d+))?/i.match(string)
              unless m
                return nil
              end
      Severity: Minor
      Found in lib/bcdice/game_system/NightWizard.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 eval_game_system_specific_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def eval_game_system_specific_command(command)
              case command
              when /\AFF/
                # 対抗なしロール
                # '成功' or '失敗' を出力する
      Severity: Minor
      Found in lib/bcdice/game_system/AFF2e.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 result_nd6 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def result_nd6(total, _dice_total, dice_list, cmp_op, target)
              n_max = dice_list.count(6)
      
              if dice_list.count(1) == dice_list.size
                # 全部1の目ならファンブル
      Severity: Minor
      Found in lib/bcdice/game_system/Arianrhod.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 roll_mal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def roll_mal(command)
              m = /^MAL(\d{1,2})$/i.match(command)
              return nil unless m
      
              mal = m[1].to_i
      Severity: Minor
      Found in lib/bcdice/game_system/CastleInGray.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 use_petit_quest_chart has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def use_petit_quest_chart(command)
              match_data = command.match(/PQ([VA]?)/)
              chart_symbol = match_data[1] == '' ? 'V' : match_data[1]
      
              roll_result1 = @randomizer.roll_once(D6)
      Severity: Minor
      Found in lib/bcdice/game_system/Villaciel.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 expr_r has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def expr_r()
              modify_number = Format.modifier(@cmd.modify_number)
              critical = @critical == 12 ? "" : "c[#{@critical}]"
              fumble = @fumble == 2 ? "" : "f[#{@fumble}]"
              brak = @break == 0 ? "" : "b[#{@break}]"
      Severity: Minor
      Found in lib/bcdice/game_system/OracleEngine.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 result_nd6_only has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def result_nd6_only(total, dice_total, cmp_op, target)
              return nil unless cmp_op == :>=
      
              if dice_total <= 2
                Result.fumble("絶対失敗")
      Severity: Minor
      Found in lib/bcdice/game_system/MeikyuKingdom.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