bcdice/BCDice

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

Summary

Maintainability
F
5 days
Test Coverage

File HeroScale.rb has 762 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Class HeroScale has 50 methods (exceeds 20 allowed). Consider refactoring.
    Open

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

      Method fate_monster has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def fate_monster(_natural_result, order)
              modified_result = []
              if order.length > 9 && order[2] =~ /^\d+$/ && order[3] =~ /^\d+$/ && order[4] =~ /^\d+$/ && order[5] =~ /^\d+$/ && order[6] =~ /^\d+$/ && order[7] =~ /^\d+$/ && order[8] =~ /^\d+$/ && order[9] =~ /^\d+$/
                if order[2].to_i > 0
                  modified_result.concat(@randomizer.roll_barabara(order[2].to_i, 2))
      Severity: Minor
      Found in lib/bcdice/game_system/HeroScale.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

      Consider simplifying this complex logical expression.
      Open

              if order.length > 9 && order[2] =~ /^\d+$/ && order[3] =~ /^\d+$/ && order[4] =~ /^\d+$/ && order[5] =~ /^\d+$/ && order[6] =~ /^\d+$/ && order[7] =~ /^\d+$/ && order[8] =~ /^\d+$/ && order[9] =~ /^\d+$/
                if order[2].to_i > 0
                  modified_result.concat(@randomizer.roll_barabara(order[2].to_i, 2))
                end
                if order[3].to_i > 0
      Severity: Critical
      Found in lib/bcdice/game_system/HeroScale.rb - About 1 hr to fix

        Method fate_monster has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def fate_monster(_natural_result, order)
                modified_result = []
                if order.length > 9 && order[2] =~ /^\d+$/ && order[3] =~ /^\d+$/ && order[4] =~ /^\d+$/ && order[5] =~ /^\d+$/ && order[6] =~ /^\d+$/ && order[7] =~ /^\d+$/ && order[8] =~ /^\d+$/ && order[9] =~ /^\d+$/
                  if order[2].to_i > 0
                    modified_result.concat(@randomizer.roll_barabara(order[2].to_i, 2))
        Severity: Minor
        Found in lib/bcdice/game_system/HeroScale.rb - About 1 hr to fix

          Method select_origin has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def select_origin(command)
                  order = command.split(",")
          
                  case order[0]
                  when "5HS4"
          Severity: Minor
          Found in lib/bcdice/game_system/HeroScale.rb - About 1 hr to fix

            Method origin_omnipotent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def origin_omnipotent(order)
                    natural_result = @randomizer.roll_barabara(3, 12)
            
                    case order[1]
                    when "G"
            Severity: Minor
            Found in lib/bcdice/game_system/HeroScale.rb - About 1 hr to fix

              Method fate_science has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def fate_science(natural_result, order)
                      subtotal = results_multiplication(natural_result)
                      if order.length > 2 && order[2] =~ /^\d+$/
                        if order[2].to_i < 1024
                          total = subtotal + order[2].to_i
              Severity: Minor
              Found in lib/bcdice/game_system/HeroScale.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

              Avoid too many return statements within this method.
              Open

                        return origin_unique(order)
              Severity: Major
              Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return origin_omnipotent(order)
                Severity: Major
                Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return message
                  Severity: Major
                  Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return origin_absorption(order)
                    Severity: Major
                    Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

                                  return origin_stranger(order)
                        Severity: Major
                        Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                    return origin_normal()
                          Severity: Major
                          Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                      return origin_karma(order)
                            Severity: Major
                            Found in lib/bcdice/game_system/HeroScale.rb - About 30 mins to fix

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

                                    def fate_treasure(natural_result, order)
                                      modified_result = natural_result.dup
                                      subtotal = results_multiplication(natural_result)
                                      total = subtotal
                                      if order.length > 2 && order[2] =~ /^\d+$/
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.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

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

                                        if order.length > 2 && order[1] =~ /^\d+$/ && order[2] =~ /^\d+$/
                                          modified_result = natural_result.dup
                                          modified_result <<  order[1].to_i
                                          modified_result <<  order[2].to_i
                                          total = results_multiplication(modified_result)
                              Severity: Major
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 1 hr to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 262..270

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

                                      if order.length > 3 && order[2] =~ /^\d+$/ && order[3] =~ /^\d+$/
                                        modified_result = natural_result.dup
                                        modified_result <<  order[2].to_i
                                        modified_result <<  order[3].to_i
                                        total = results_multiplication(modified_result)
                              Severity: Major
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 1 hr to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 247..255

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

                                    def origin_protection(order)
                                      natural_result = @randomizer.roll_barabara(4, 6)
                                      case order[1]
                                      when "R"
                                        message = fate_reversal(natural_result)
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 55 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 313..326

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

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

                                    def origin_curse(order)
                                      natural_result = @randomizer.roll_barabara(2, 20)
                                      case order[1]
                                      when "R"
                                        message = fate_ruin(natural_result)
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 55 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 174..187

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

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

                                    def fate_ordeal(natural_result)
                                      modified_result = []
                                      natural_result.each do |result|
                                        if result < 9
                                          result = 9
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 55 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 760..771

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

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

                                    def fate_anguish(natural_result)
                                      modified_result = []
                                      natural_result.each do |result|
                                        if result < 7
                                          result = 7
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 55 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 774..785

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

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

                                    def fate_holy(natural_result)
                                      modified_result = []
                                      natural_result.each do |result|
                                        modified_result << result + 1
                                      end
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 45 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 696..704

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

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

                                    def fate_god(natural_result)
                                      modified_result = []
                                      natural_result.each do |result|
                                        modified_result << result + 3
                                      end
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 45 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 707..715

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

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

                                    def fate_destruction(natural_result)
                                      modified_result = natural_result.dup
                                      modified_result << @randomizer.roll_once(12)
                                      subtotal = results_multiplication(natural_result)
                                      total = results_multiplication(modified_result) - 300
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 40 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 475..481

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

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

                                    def fate_oblivion(natural_result)
                                      modified_result = natural_result.dup
                                      modified_result << @randomizer.roll_once(60)
                                      subtotal = results_multiplication(natural_result)
                                      total = results_multiplication(modified_result) / 2
                              Severity: Minor
                              Found in lib/bcdice/game_system/HeroScale.rb and 1 other location - About 40 mins to fix
                              lib/bcdice/game_system/HeroScale.rb on lines 751..757

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

                              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