lily-seabreeze/sappho

View on GitHub

Showing 27 of 27 total issues

File particle.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Particle system definitions.

There's a few basic concepts here.  Note that all functions affecting physics,
emission, launch, and display are implemented as classes with a `__call__`
magic method, but could just as easily be pure functions since no extra info
Severity: Major
Found in sappho/particle.py - About 1 day to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if new_rect.centery > layer_size[1]:
            new_rect.centery -= layer_size[1]
        elif new_rect.centery < 0:
            new_rect.centery += layer_size[1]
    Severity: Major
    Found in demo/demo.py and 1 other location - About 2 hrs to fix
    demo/demo.py on lines 238..241

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 61.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if new_rect.centerx > layer_size[0]:
            new_rect.centerx -= layer_size[0]
        elif new_rect.centerx < 0:
            new_rect.centerx += layer_size[0]
    Severity: Major
    Found in demo/demo.py and 1 other location - About 2 hrs to fix
    demo/demo.py on lines 233..236

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 61.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File tiles.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # TODO: module level docstring
    """Tile engine; tile map, tilesheet system.
    
    Has impassability support.
    
    
    Severity: Minor
    Found in sappho/tiles.py - About 2 hrs to fix

      File animate.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Painless animated sprites which are pygame.sprite.Sprite objects.
      
      Animated sprites from GIF, and all YOU have to know is to `update_state`!
      You just have to call `update_state` once per loop with the timedelta:
      
      
      Severity: Minor
      Found in sappho/animate.py - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if goal_x > sprite.rect.left:
                x_increment = 1
            elif goal_x < sprite.rect.left:
                x_increment = -1
            else:
        Severity: Major
        Found in sappho/collide.py and 1 other location - About 1 hr to fix
        sappho/collide.py on lines 144..149

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            if goal_y > sprite.rect.top:
                y_increment = 1
            elif goal_y < sprite.rect.top:
                y_increment = -1
            else:
        Severity: Major
        Found in sappho/collide.py and 1 other location - About 1 hr to fix
        sappho/collide.py on lines 137..142

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 45.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        def move_as_close_as_possible(sprite, destination, sprite_group):
            """Return how close sprite can go to destination without collision,
            along with the first sprite blocking its progress (if any).
        
            "Position" herein will always refer to a position
        Severity: Minor
        Found in sappho/collide.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def __call__(self, dt):
                """How many particles to emit in `dt` seconds.
        
                Arguments:
                    dt: Elapsed time in seconds.
        Severity: Minor
        Found in sappho/particle.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 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(
        Severity: Major
        Found in sappho/particle.py - About 50 mins to fix

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

              def update(self, camera, wall_collision_group, layer_size, timedelta):
                  self.sprite.update(timedelta)
          
                  if self.x_speed == 0 and self.y_speed == 0:
                      return None
          Severity: Minor
          Found in demo/demo.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, x, y, dx=0, dy=0, life=0, species=None):
          Severity: Minor
          Found in sappho/particle.py - About 45 mins to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    if new_view_rect.bottom > camera.source_resolution[1]:
                        new_view_rect.bottom = camera.source_resolution[1]
            Severity: Minor
            Found in sappho/camera.py and 1 other location - About 45 mins to fix
            sappho/camera.py on lines 103..104

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                def __init__(self, duration, color, center, x_speed, y_speed, size):
            Severity: Minor
            Found in demo/demo.py - About 45 mins to fix

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

                  def __init__(self, x=0, y=0, dx=0, dy=0, life=0, jitter=None):
              Severity: Minor
              Found in sappho/particle.py - About 45 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        if new_view_rect.right > camera.source_resolution[0]:
                            new_view_rect.right = camera.source_resolution[0]
                Severity: Minor
                Found in sappho/camera.py and 1 other location - About 45 mins to fix
                sappho/camera.py on lines 100..101

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 35.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                    def update(self, wall_list, layer_size, asteroid_list, player_bullet_list, timedelta):
                Severity: Minor
                Found in demo/demo.py - About 35 mins to fix

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

                      def __init__(self, image, origin, tints,
                  Severity: Minor
                  Found in sappho/particle.py - About 35 mins to fix

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

                        def __init__(self, x=0, y=0, dx=0, dy=0, life=0):
                    Severity: Minor
                    Found in sappho/particle.py - About 35 mins to fix

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

                          def add_if_below_threshold(cls, player, asteroid_list, at_least_x_existing):
                      
                              if len(asteroid_list) < at_least_x_existing:
                                  plus_or_minus_x = random.choice([1, -1])
                                  new_asteroid_x = player.sprite.rect.top - (cls.SPAWN_DISTANCE_FROM_PLAYER * plus_or_minus_x)
                      Severity: Minor
                      Found in demo/demo.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