bcdice/BCDice

View on GitHub

Showing 1,176 of 1,233 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def mk_item_jyuka_table(num)
        table = [
          [1, "「呪い」のバッドステータス"],
          [2, "「肥満」のバッドステータス"],
          [3, "「愚か」のバッドステータス"],
Severity: Minor
Found in lib/bcdice/game_system/meikyu_kingdom/item_table.rb and 2 other locations - About 25 mins to fix
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 269..279
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 330..340

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def mk_item_power_table(num)
        table = [
          [1, "〔才覚〕"],
          [2, "〔魅力〕"],
          [3, "〔探索〕"],
Severity: Minor
Found in lib/bcdice/game_system/meikyu_kingdom/item_table.rb and 2 other locations - About 25 mins to fix
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 302..312
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 330..340

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

      def mk_item_attribute_table(num)
        table = [
          [1, "自然の力"],
          [2, "幻夢の力"],
          [3, "星炎の力"],
Severity: Minor
Found in lib/bcdice/game_system/meikyu_kingdom/item_table.rb and 2 other locations - About 25 mins to fix
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 269..279
lib/bcdice/game_system/meikyu_kingdom/item_table.rb on lines 302..312

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 31.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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 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 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 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 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 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 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 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 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 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 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 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 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 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 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