poliastro/poliastro

View on GitHub
src/poliastro/twobody/orbit.py

Summary

Maintainability
F
4 days
Test Coverage

File orbit.py has 1093 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import List, Union
from warnings import warn

import numpy as np
from astropy import time, units as u
Severity: Major
Found in src/poliastro/twobody/orbit.py - About 2 days to fix

    Orbit has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Orbit(object):
        """Position and velocity of a body with respect to an attractor
        at a given time (epoch).
    
        Regardless of how the Orbit is created, the implicit
    Severity: Minor
    Found in src/poliastro/twobody/orbit.py - About 4 hrs to fix

      Cyclomatic complexity is too high in method heliosynchronous. (15)
      Open

          @classmethod
          def heliosynchronous(
              cls,
              a=None,
              ecc=None,
      Severity: Minor
      Found in src/poliastro/twobody/orbit.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method frozen. (13)
      Open

          @classmethod
          @u.quantity_input(
              alt=u.m, inc=u.rad, argp=u.rad, raan=u.rad, arglat=u.rad, ecc=u.one
          )
          def frozen(
      Severity: Minor
      Found in src/poliastro/twobody/orbit.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method change_attractor. (8)
      Open

          def change_attractor(self, new_attractor, force=False):
              """Changes orbit attractor.
      
              Only changes from attractor to parent or the other way around are allowed.
      
      
      Severity: Minor
      Found in src/poliastro/twobody/orbit.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method geostationary. (7)
      Open

          @classmethod
          @u.quantity_input(angular_velocity=u.rad / u.s, period=u.s, hill_radius=u.m)
          def geostationary(
              cls, attractor, angular_velocity=None, period=None, hill_radius=None
          ):
      Severity: Minor
      Found in src/poliastro/twobody/orbit.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Consider simplifying this complex logical expression.
      Open

                      if (a is None) and (ecc is None) and (inc is None):
                          # We check sufficient number of parameters
                          raise ValueError(
                              "At least two parameters of the set {a, ecc, inc} are required."
                          )
      Severity: Critical
      Found in src/poliastro/twobody/orbit.py - About 1 hr to fix

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

            def heliosynchronous(
                cls,
                a=None,
                ecc=None,
                inc=None,
        Severity: Minor
        Found in src/poliastro/twobody/orbit.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 frozen has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def frozen(
                cls,
                attractor,
                alt,
                inc=None,
        Severity: Minor
        Found in src/poliastro/twobody/orbit.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 change_attractor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def change_attractor(self, new_attractor, force=False):
                """Changes orbit attractor.
        
                Only changes from attractor to parent or the other way around are allowed.
        
        
        Severity: Minor
        Found in src/poliastro/twobody/orbit.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 frozen has 10 arguments (exceeds 9 allowed). Consider refactoring.
        Open

            def frozen(
        Severity: Major
        Found in src/poliastro/twobody/orbit.py - About 35 mins to fix

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

              def propagate(self, value, method=mean_motion, rtol=1e-10, **kwargs):
                  """Propagates an orbit a specified time.
          
                  If value is true anomaly, propagate orbit to this anomaly and return the result.
                  Otherwise, if time is provided, propagate this `Orbit` some `time` and return the result.
          Severity: Minor
          Found in src/poliastro/twobody/orbit.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

          TODO found
          Open

                  # TODO: Generalize for other bodies
          Severity: Minor
          Found in src/poliastro/twobody/orbit.py by fixme

          TODO found
          Open

                      # TODO: The attractor is in fact the Earth-Moon Barycenter
          Severity: Minor
          Found in src/poliastro/twobody/orbit.py by fixme

          TODO found
          Open

                      # TODO: The attractor is not really the Sun, but the Solar System
          Severity: Minor
          Found in src/poliastro/twobody/orbit.py by fixme

          TODO found
          Open

                  # TODO: Perhaps this should be public API as well?
          Severity: Minor
          Found in src/poliastro/twobody/orbit.py by fixme

          There are no issues that match your filters.

          Category
          Status