bcdice/BCDice

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

Summary

Maintainability
B
4 hrs
Test Coverage
A
99%

Method eval_game_system_specific_command has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

      def eval_game_system_specific_command(command)
        command = command.upcase

        if (table = self.class::TABLES[command])
          table.roll(@randomizer)
Severity: Minor
Found in lib/bcdice/game_system/StellarKnights.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 translate_tables has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def translate_tables(locale)
          {
            "TT" => DiceTable::D66GridTable.from_i18n("StellarKnights.tables.TT", locale),
            "STA" => DiceTable::Table.from_i18n("StellarKnights.tables.STA", locale),
            "STB" => DiceTable::D66OneThirdTable.from_i18n("StellarKnights.tables.STB", locale),
Severity: Minor
Found in lib/bcdice/game_system/StellarKnights.rb - About 1 hr to fix

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

          def resolute_action(num_dices, defence, dice_change_text)
            dices = @randomizer.roll_barabara(num_dices, 6).sort
            dice_text = dices.join(",")
    
            output = "(#{remake_command(num_dices, defence, dice_change_text)}) > #{dice_text}"
    Severity: Minor
    Found in lib/bcdice/game_system/StellarKnights.rb - About 1 hr to fix

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

            def resolute_action(num_dices, defence, dice_change_text)
              dices = @randomizer.roll_barabara(num_dices, 6).sort
              dice_text = dices.join(",")
      
              output = "(#{remake_command(num_dices, defence, dice_change_text)}) > #{dice_text}"
      Severity: Minor
      Found in lib/bcdice/game_system/StellarKnights.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

      There are no issues that match your filters.

      Category
      Status