bcdice/BCDice

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

Summary

Maintainability
D
2 days
Test Coverage
B
88%

Method getSW2_0_RatingTable has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def getSW2_0_RatingTable
        rate_sw2_0 = [
          # 0
          '*,0,0,0,1,2,2,3,3,4,4',
          '*,0,0,0,1,2,3,3,3,4,4',
Severity: Major
Found in lib/bcdice/game_system/SwordWorld.rb - About 4 hrs to fix

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

          def getResultText(rating_total, command, diceResults, diceResultTotals,
                            rateResults, dice_total, round)
            sequence = []
    
            sequence.push("2D:[#{diceResults.join(' ')}]=#{diceResultTotals.join(',')}")
    Severity: Minor
    Found in lib/bcdice/game_system/SwordWorld.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 rating has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

          def rating(string) # レーティング表
            debug("rating string", string)
            command = rating_parser.parse(string)
    
            unless command
    Severity: Minor
    Found in lib/bcdice/game_system/SwordWorld.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

    File SwordWorld.rb has 307 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "bcdice/base"
    require "bcdice/game_system/sword_world/rating_parser"
    
    module BCDice
      module GameSystem
    Severity: Minor
    Found in lib/bcdice/game_system/SwordWorld.rb - About 3 hrs to fix

      Method rating has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def rating(string) # レーティング表
              debug("rating string", string)
              command = rating_parser.parse(string)
      
              unless command
      Severity: Major
      Found in lib/bcdice/game_system/SwordWorld.rb - About 2 hrs to fix

        Method getResultText has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def getResultText(rating_total, command, diceResults, diceResultTotals,
                                rateResults, dice_total, round)
                sequence = []
        
                sequence.push("2D:[#{diceResults.join(' ')}]=#{diceResultTotals.join(',')}")
        Severity: Major
        Found in lib/bcdice/game_system/SwordWorld.rb - About 2 hrs to fix

          Method getNewRates has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def getNewRates(rate_sw2_0)
                  rate_3 = []
                  rate_4 = []
                  rate_5 = []
                  rate_6 = []
          Severity: Minor
          Found in lib/bcdice/game_system/SwordWorld.rb - About 1 hr to fix

            Method getResultText has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def getResultText(rating_total, command, diceResults, diceResultTotals,
                                    rateResults, dice_total, round)
            Severity: Major
            Found in lib/bcdice/game_system/SwordWorld.rb - About 50 mins to fix

              Method result_2d6 has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def result_2d6(total, dice_total, _dice_list, cmp_op, target)
              Severity: Minor
              Found in lib/bcdice/game_system/SwordWorld.rb - About 35 mins to fix

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

                      def result_2d6(total, dice_total, _dice_list, cmp_op, target)
                        if dice_total >= 12
                          Result.critical(translate('SwordWorld.critical'))
                        elsif dice_total <= 2
                          Result.fumble(translate('SwordWorld.fumble'))
                Severity: Minor
                Found in lib/bcdice/game_system/SwordWorld.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

                There are no issues that match your filters.

                Category
                Status