bcdice/BCDice

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

Summary

Maintainability
D
1 day
Test Coverage
A
96%

File Warhammer4.rb has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module BCDice
  module GameSystem
    class Warhammer4 < Base
      # ゲームシステムの識別子
      ID = 'Warhammer4'
Severity: Minor
Found in lib/bcdice/game_system/Warhammer4.rb - About 2 hrs to fix

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

          def result_detail(sl, total, target)
            if sl == 0
              if total <= 5
                '小成功'
              elsif total >= 96
    Severity: Minor
    Found in lib/bcdice/game_system/Warhammer4.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 result_1d100 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def result_1d100(total, _dice_total, cmp_op, target)
            return Result.nothing if target == '?'
            return nil unless cmp_op == :<=
    
            t10 = total / 10
    Severity: Minor
    Found in lib/bcdice/game_system/Warhammer4.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 result_detail has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def result_detail(sl, total, target)
            if sl == 0
              if total <= 5
                '小成功'
              elsif total >= 96
    Severity: Minor
    Found in lib/bcdice/game_system/Warhammer4.rb - About 1 hr to fix

      Method result_1d100 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def result_1d100(total, _dice_total, cmp_op, target)
              return Result.nothing if target == '?'
              return nil unless cmp_op == :<=
      
              t10 = total / 10
      Severity: Minor
      Found in lib/bcdice/game_system/Warhammer4.rb - About 1 hr to fix

        Method additional_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def additional_result(total, target_number)
                tens, ones = split_d100(total)
                if (total > target_number) || (total > 95) # 自動失敗時のファンブル処理も
                  if ones == tens
                    "ファンブル"
        Severity: Minor
        Found in lib/bcdice/game_system/Warhammer4.rb - About 35 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

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

                "A" => CriticalTable.new(
                  "腕部CT表",
                  [
                    [10, '腕痺れ:耐久値-1:手に持っているものを落としてしまう。'],
                    [20, '小さな裂傷:耐久値-1:「出血状態」1つを得る。'],
        Severity: Major
        Found in lib/bcdice/game_system/Warhammer4.rb and 3 other locations - About 1 hr to fix
        lib/bcdice/game_system/Warhammer4.rb on lines 148..171
        lib/bcdice/game_system/Warhammer4.rb on lines 198..221
        lib/bcdice/game_system/Warhammer4.rb on lines 223..246

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

        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 4 locations. Consider refactoring.
        Open

                "B" => CriticalTable.new(
                  "胴体CT表",
                  [
                    [10, 'ただのかすり傷だって!:耐久値-1:「出血状態」1つを得る。'],
                    [20, 'みぞおちへの一打:耐久値-1:「朦朧状態」1つを得る。「容易(+40)」な〈肉体抵抗〉テストを行い、失敗したなら「伏せ状態」になる。'],
        Severity: Major
        Found in lib/bcdice/game_system/Warhammer4.rb and 3 other locations - About 1 hr to fix
        lib/bcdice/game_system/Warhammer4.rb on lines 148..171
        lib/bcdice/game_system/Warhammer4.rb on lines 173..196
        lib/bcdice/game_system/Warhammer4.rb on lines 223..246

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

        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 4 locations. Consider refactoring.
        Open

                "H" => CriticalTable.new(
                  "頭部CT表",
                  [
                    [10, '勲章となる傷:耐久値-1:「出血状態」1つを得る。社交系テストSL+1(累積なし)。'],
                    [20, '小さな裂傷:耐久値-1:「出血状態」1つを得る。'],
        Severity: Major
        Found in lib/bcdice/game_system/Warhammer4.rb and 3 other locations - About 1 hr to fix
        lib/bcdice/game_system/Warhammer4.rb on lines 173..196
        lib/bcdice/game_system/Warhammer4.rb on lines 198..221
        lib/bcdice/game_system/Warhammer4.rb on lines 223..246

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

        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 4 locations. Consider refactoring.
        Open

                "L" => CriticalTable.new(
                  "脚部CT表",
                  [
                    [10, '爪先をぶつける:耐久値-1:「普通(+20)」の〈肉体抵抗〉テストを行い、失敗したなら次のターンの終了時まで【敏捷力】に関するテストに-10。'],
                    [20, '足首の捻挫:耐久値-1:以降1d10ラウンドに渡って【敏捷力】に関連するテストに-10。'],
        Severity: Major
        Found in lib/bcdice/game_system/Warhammer4.rb and 3 other locations - About 1 hr to fix
        lib/bcdice/game_system/Warhammer4.rb on lines 148..171
        lib/bcdice/game_system/Warhammer4.rb on lines 173..196
        lib/bcdice/game_system/Warhammer4.rb on lines 198..221

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

        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

                "WHFT" => DiceTable::RangeTable.new(
                  "やっちまった!表",
                  "1D100",
                  [
                    [1..20, '君は自分の体の一部に当ててしまった。「耐久度」1点を失う。'],
        Severity: Minor
        Found in lib/bcdice/game_system/Warhammer4.rb and 2 other locations - About 20 mins to fix
        lib/bcdice/game_system/KemonoNoMori.rb on lines 112..123
        lib/bcdice/game_system/Yggdrasill.rb on lines 432..443

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

        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

        There are no issues that match your filters.

        Category
        Status