setokinto/slack-bomber

View on GitHub

Showing 13 of 13 total issues

Function generate_map has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_map(x_size, y_size, person_num):

        # init field by wall and empty
        field_wall = [Object.wall] * y_size
        field_wall_and_emp = [Object.wall] + [Object.empty] * (y_size - 2) + [Object.wall]
Severity: Minor
Found in app/game/field.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 fire_bomb has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def fire_bomb(self, point):
        bomb = field_object(self.bombs, point)
        # Remove bomb for infinite recursion
        put_object_to_field(self.bombs, point, None)

Severity: Minor
Found in app/game/field.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 post_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def post_field(cls, channel, field, new_message=False):

        field_text = ""
        
        # TODO remove this 3 line after implement output person infomation
Severity: Minor
Found in app/game/field_outputter.py - 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

Function fire has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def fire(self, field, point):
        fire_points = []

        for x, y in [[0, -1], [0, 1], [1, 0], [-1, 0]]:
            for i in range(1, self.fire_count + 1):
Severity: Minor
Found in app/game/field.py - 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

Function _proceed_time_each_bomb has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _proceed_time_each_bomb(self, bomb, point, proceeded_time):
        if isinstance(bomb, ProceedObject):
            bomb.proceed_time(proceeded_time)

            if bomb.remain_time <= 0:
Severity: Minor
Found in app/game/field.py - 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 deeply nested control flow statements.
Open

                        if x % 2 == 0:
                            objects[x][y] = Object.wall

                # avoid corner block
                if objects[x][y] is Object.empty and random.randint(0, 4) < 3\
Severity: Major
Found in app/game/field.py - About 45 mins to fix

    Consider simplifying this complex logical expression.
    Open

                    if objects[x][y] is Object.empty and random.randint(0, 4) < 3\
                       and (y + x) > 3\
                       and (x_size - x + y) > 4\
                       and (y_size - y + x) > 4\
                       and (x_size + y_size - x - y) > 5:
    Severity: Major
    Found in app/game/field.py - About 40 mins to fix

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

          def get_field_object(self, point):
      
              obj = field_object(self.objects, point)
              if obj is Object.wall or obj is Object.block:
                  return obj
      Severity: Minor
      Found in app/game/field.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

      Avoid too many return statements within this function.
      Open

              return person_emoji_map[object.num]
      Severity: Major
      Found in app/game/field_outputter.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return object_emoji_map[object]
        Severity: Major
        Found in app/game/field_outputter.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return obj
          Severity: Major
          Found in app/game/field.py - About 30 mins to fix

            Function reaction_handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def reaction_handler(self, user, command):
                    person = self.field.person_by_user(user)
                    if person is None:
                        return
            
            
            Severity: Minor
            Found in app/game/bomber.py - 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

            Function move has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def move(self, person, x, y):
                    if person.dead:
                        return
            
                    dest = person.point.diff(x, y)
            Severity: Minor
            Found in app/game/field.py - 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

            Severity
            Category
            Status
            Source
            Language