pysat/pysatMissions

View on GitHub

Showing 60 of 76 total issues

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

try:
    import apexpy
except ImportError as ierr:
    pysat.logger.warning(" ".join(["apexpy module could not be imported.",
                                   "apexpy interface won't work.",
Severity: Major
Found in pysatMissions/methods/magcoord.py and 1 other location - About 1 hr to fix
pysatMissions/methods/magcoord.py on lines 14..19

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 38.

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 project_ecef_vector_onto_sc has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def project_ecef_vector_onto_sc(inst, x_label, y_label, z_label,
Severity: Major
Found in pysatMissions/methods/spacecraft.py - About 1 hr to fix

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

        meta['Epoch'] = {
            meta.labels.units: 'Milliseconds since 1970-1-1',
            meta.labels.notes: 'UTC time at middle of geophysical measurement.',
            meta.labels.desc: 'UTC seconds',
            meta.labels.name: 'Time index in milliseconds'}
    Severity: Major
    Found in pysatMissions/instruments/missions_skyfield.py and 2 other locations - About 55 mins to fix
    pysatMissions/instruments/missions_ephem.py on lines 240..244
    pysatMissions/instruments/missions_sgp4.py on lines 265..269

    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 37.

    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 load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):
        """Generate position of satellite in ECI co-ordinates.
    Severity: Minor
    Found in pysatMissions/instruments/missions_sgp4.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

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

            assert np.all(self.testInst['sc_zhat_ecef_y']
                          == -self.testInst['position_ecef_y'])
    Severity: Major
    Found in pysatMissions/tests/test_methods_spacecraft.py and 2 other locations - About 45 mins to fix
    pysatMissions/tests/test_methods_spacecraft.py on lines 116..117
    pysatMissions/tests/test_methods_spacecraft.py on lines 120..121

    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 package_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def package_check(package_name):
        """Throw a warning if optional package is not installed.
    
        Some systems are having issues installing OMMBV and apexpy.
        This allows these packages to be optionally installed.
    Severity: Minor
    Found in pysatMissions/utils/_core.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

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

            assert np.all(self.testInst['sc_zhat_ecef_x']
                          == -self.testInst['position_ecef_x'])
    Severity: Major
    Found in pysatMissions/tests/test_methods_spacecraft.py and 2 other locations - About 45 mins to fix
    pysatMissions/tests/test_methods_spacecraft.py on lines 118..119
    pysatMissions/tests/test_methods_spacecraft.py on lines 120..121

    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 load has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):
        """Generate position of satellite in ECI co-ordinates.
    Severity: Minor
    Found in pysatMissions/instruments/missions_skyfield.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

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

            assert np.all(self.testInst['sc_zhat_ecef_z']
                          == -self.testInst['position_ecef_z'])
    Severity: Major
    Found in pysatMissions/tests/test_methods_spacecraft.py and 2 other locations - About 45 mins to fix
    pysatMissions/tests/test_methods_spacecraft.py on lines 116..117
    pysatMissions/tests/test_methods_spacecraft.py on lines 118..119

    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

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

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):
    Severity: Minor
    Found in pysatMissions/instruments/missions_skyfield.py and 1 other location - About 40 mins to fix
    pysatMissions/instruments/missions_sgp4.py on lines 78..81

    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 34.

    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

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

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):
    Severity: Minor
    Found in pysatMissions/instruments/missions_sgp4.py and 1 other location - About 40 mins to fix
    pysatMissions/instruments/missions_skyfield.py on lines 77..80

    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 34.

    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 'skyfield' in inst['inst_module'].name:
            instruments['sgp4'].append(inst)
    Severity: Minor
    Found in pysatMissions/tests/test_instruments.py and 1 other location - About 35 mins to fix
    pysatMissions/tests/test_instruments.py on lines 39..40

    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 33.

    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 'sgp4' in inst['inst_module'].name:
            instruments['sgp4'].append(inst)
    Severity: Minor
    Found in pysatMissions/tests/test_instruments.py and 1 other location - About 35 mins to fix
    pysatMissions/tests/test_instruments.py on lines 41..42

    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 33.

    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 _check_orbital_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _check_orbital_params(kwargs):
        """Check that a complete set of unconflicted orbital parameters exist.
    
        Parameters
        ----------
    Severity: Minor
    Found in pysatMissions/instruments/methods/orbits.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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
             tle1=None, tle2=None, num_samples=None, cadence='1S'):
        """Generate position of satellite in both geographic and ECEF co-ordinates.
    
        Note
    Severity: Minor
    Found in pysatMissions/instruments/missions_ephem.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 "project_ecef_vector_onto_sc" has 8 parameters, which is greater than the 7 authorized.
    Open

    def project_ecef_vector_onto_sc(inst, x_label, y_label, z_label,
                                    new_x_label, new_y_label, new_z_label,
                                    meta=None):

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    def do_something(param1, param2, param3, param4, param5):
        ...
    

    Compliant Solution

    def do_something(param1, param2, param3, param4):
        ...
    

    Function "load" has 10 parameters, which is greater than the 7 authorized.
    Open

    def load(fnames, tag=None, inst_id=None, obs_long=0., obs_lat=0., obs_alt=0.,
             tle1=None, tle2=None, num_samples=None, cadence='1S'):

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    def do_something(param1, param2, param3, param4, param5):
        ...
    

    Compliant Solution

    def do_something(param1, param2, param3, param4):
        ...
    

    Remove the code after this "raise".
    Open

                raise NameError('A sensible error has occurred')

    Jump statements (return, break, continue, and raise) move control flow out of the current code block. Typically, any statements in a block that come after a jump are simply wasted keystrokes lying in wait to confuse the unwary.

    Noncompliant Code Example

    def fun(a):
      i = 10
      return i + a       # Noncompliant
      i += 1             # this is never executed
    

    Compliant Solution

    def fun(a):
      i = 10
      return i + a
    

    See

    • MISRA C:2004, 14.1 - There shall be no unreachable code
    • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
    • MISRA C++:2008, 0-1-9 - There shall be no dead code
    • MISRA C:2012, 2.1 - A project shall not contain unreachable code
    • MISRA C:2012, 2.2 - There shall be no dead code
    • MITRE, CWE-561 - Dead Code
    • CERT, MSC56-J. - Detect and remove superfluous code and values
    • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
    • CERT, MSC07-CPP. - Detect and remove dead code

    Function "load" has 16 parameters, which is greater than the 7 authorized.
    Open

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    def do_something(param1, param2, param3, param4, param5):
        ...
    

    Compliant Solution

    def do_something(param1, param2, param3, param4):
        ...
    

    Function "load" has 16 parameters, which is greater than the 7 authorized.
    Open

    def load(fnames, tag=None, inst_id=None, tle1=None, tle2=None,
             alt_periapsis=None, alt_apoapsis=None,
             inclination=None, raan=0., arg_periapsis=0., mean_anomaly=0.,
             epoch=None, bstar=0., one_orbit=False, num_samples=None, cadence='1S'):

    A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

    Noncompliant Code Example

    With a maximum number of 4 parameters:

    def do_something(param1, param2, param3, param4, param5):
        ...
    

    Compliant Solution

    def do_something(param1, param2, param3, param4):
        ...
    
    Severity
    Category
    Status
    Source
    Language