matteoferla/DnD-battler

View on GitHub

Showing 30 of 30 total issues

Function _initialise has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

    def _initialise(self, **settings):
        """
        Preface.
        Character creation in DnD_battler is rather painful. Here due to missing it is even more complex.
        Also, creature, character and monster are used interchangably here unfortunately, which will be fixed one day.
Severity: Minor
Found in DnD_battler/creature/junk/_initialise.py - About 1 day 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

Function _fill_from_preset has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def _fill_from_preset(self, name:str):
        """
        Legacy... It might stop working due to code changes.
        :param name: the name of creature.
        :return: the stored creature.
Severity: Minor
Found in DnD_battler/creature/junk/_fillers.py - About 4 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

Function _sanitise_settings_for_abilities has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def _sanitise_settings_for_abilities(self, settings) -> dict:
        settings = {k.lower(): v for k, v in settings.items()}
        # ---------- set blanks ----------------------------------------------------------------------------------------
        blank_abilities = {ab: None for ab in self.ability_names}
        # ability_bonuses
Severity: Minor
Found in DnD_battler/creature/_init_abilities.py - 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

Function clean_settings has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_settings(self, dirtydex: dict) -> dict:
        """
        Sanify the settings

        :return: a cleaned dictionary
Severity: Minor
Found in DnD_battler/creature/junk/_initialise.py - About 2 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

Function apply_settings has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def apply_settings(self, **settings):
        settings = {k.lower(): v for k, v in settings.items()}
        # -------------- assign fluff values ---------------------------------------------------------------------------
        for key in ('name', 'base', 'type', 'alignment'):
            if key in settings:
Severity: Minor
Found in DnD_battler/creature/_adv_base.py - About 2 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

Function describe has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def describe(self, html_formatting:bool=False) -> str:
        badgify = lambda i: f'<span class="badge">{i}</span>'
        if html_formatting:
            # it is bootstrap 3 in Jupyter notebook, but with jupyter themes it looks weird.
            # class="list-group" and class="list-group-item"
Severity: Minor
Found in DnD_battler/encounter/_base.py - About 2 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

Function predict has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def predict(self, html_formatting: bool = False) -> str:
        def safediv(a, b, default=0):
            try:
                return a / b
            except:
Severity: Minor
Found in DnD_battler/encounter/_action.py - 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

Function act has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def act(self):
        if not self.arena.find('alive enemy'):
            raise Victory()
        # BONUS ACTION
        # heal  -healing word, a bonus action.
Severity: Minor
Found in DnD_battler/creature/_action.py - 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

Function __init__ has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def __init__(self):
        self.name = 'unnamed'
        self.base = 'none'    # human bandit
        self.type = 'unknown' # aberation, humanoid
        self.size = Size('medium')
Severity: Minor
Found in DnD_battler/creature/_base.py - About 1 hr to fix

    Function from_notation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def from_notation(cls, notation: str, **kargs) -> Dice:
            """
            2d6+2 to Dice
    
            :param notation: 2d6+2
    Severity: Minor
    Found in DnD_battler/dice/dice.py - 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

    Function __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, wildcard, **kwargs):
            """
            Creature object creation. A lot of paramaters make a creature so a lot of assumptions are made (see __init__`).
    
            :param wildcard: the name of the creature.
    Severity: Minor
    Found in DnD_battler/creature/junk/_adv_base.py - 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

    Function _initialise has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _initialise(self, **settings):
            """
            Preface.
            Character creation in DnD_battler is rather painful. Here due to missing it is even more complex.
            Also, creature, character and monster are used interchangably here unfortunately, which will be fixed one day.
    Severity: Minor
    Found in DnD_battler/creature/junk/_initialise.py - About 1 hr to fix

      Function parse_attacks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_attacks(self,
                            attacks: Optional[List[Union[dict, Action, AttackRoll]]] = None,
                            **others) -> Action:
              """
              A multiattack is a curious case where a creature can do multiple attacks as a single action.
      Severity: Minor
      Found in DnD_battler/creature/_level.py - 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

      Function remove has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove(self, moriturus):
              """
              Removes a creature and resets and rechecks
              :param moriturus: The creature name to be dropped
              :return: self
      Severity: Minor
      Found in DnD_battler/encounter/_base.py - About 45 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

      Function base_roll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def base_roll(self, advantage:Optional[int]=None, avg=None, success_on_crit=True):
              """
              returns the roll without the bonuses.
              RAW in 5e, a crit on an ability roll is not a given success,
      
      
      Severity: Minor
      Found in DnD_battler/dice/ability_die.py - About 45 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

      Function set_ac has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_ac(self,
      Severity: Minor
      Found in DnD_battler/creature/_level.py - About 35 mins to fix

        Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self,
        Severity: Minor
        Found in DnD_battler/dice/xdice.py - About 35 mins to fix

          Function parse_attack has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_attack(self, attack: Union[None, Action, dict, list]) -> Action:
                  if attack is None:  # nothing to be done.
                      return None
                  elif isinstance(attack, Action):
                      return attack  # already an action.
          Severity: Minor
          Found in DnD_battler/creature/_level.py - 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

          Function generate_character_sheet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def generate_character_sheet(self) -> str:
                  """
                  An markdown character sheet.
                  
                  :return: a string
          Severity: Minor
          Found in DnD_battler/creature/_utils.py - 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

          Function set_ability_die has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_ability_die(self, ability_name: str, score: Optional[int] = None, bonus: Optional[int] = None):
                  ability_die = self[ability_name]
                  # print(ability_name, ability_die.score, score, ability_die.bonus, bonus)
                  assert isinstance(ability_die, AbilityDie), f'The die for {ability_name} is not a die, but {type(ability_die)}'
                  assert ability_name in self.ability_names, f'{ability_name} is not in {self.ability_names}'
          Severity: Minor
          Found in DnD_battler/creature/_init_abilities.py - 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

          Severity
          Category
          Status
          Source
          Language