setokinto/slack-bomber

View on GitHub
app/game/field.py

Summary

Maintainability
C
1 day
Test Coverage

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 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 obj
      Severity: Major
      Found in app/game/field.py - About 30 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status