aburrell/aacgmv2

View on GitHub

Showing 23 of 23 total issues

File wrapper.py has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""Pythonic wrappers for AACGM-V2 C functions.

Functions
--------------
Severity: Minor
Found in aacgmv2/wrapper.py - About 5 hrs to fix

    Function convert_latlon_arr has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert_latlon_arr(in_lat, in_lon, height, dtime, code="G2A"):
        """Converts between geomagnetic coordinates and AACGM coordinates.
    
        Parameters
        ------------
    Severity: Minor
    Found in aacgmv2/wrapper.py - About 5 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

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

        if igrf_file is not False:
            # Use the default value, if one was not supplied (allow None to
            # comply with depricated behaviour)
            if igrf_file is True or igrf_file is None:
                igrf_file = aacgmv2.IGRF_COEFFS
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 4 hrs to fix
    aacgmv2/wrapper.py on lines 42..52

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

    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 coeff_prefix is not False:
            # Use the default value, if one was not supplied (allow None to
            # comply with depricated behaviour)
            if coeff_prefix is True or coeff_prefix is None:
                coeff_prefix = aacgmv2.AACGM_v2_DAT_PREFIX
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 4 hrs to fix
    aacgmv2/wrapper.py on lines 55..65

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

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

    def set_coeff_path(igrf_file=False, coeff_prefix=False):
        """Sets the IGRF_COEFF and AACGMV_V2_DAT_PREFIX environment variables.
    
        Parameters
        -----------
    Severity: Minor
    Found in aacgmv2/wrapper.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

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

        try:
            c_aacgmv2.set_datetime(dtime.year, dtime.month, dtime.day, dtime.hour,
                                   dtime.minute, dtime.second)
        except:
            raise RuntimeError("unable to set time for {:}".format(dtime))
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 1 hr to fix
    aacgmv2/wrapper.py on lines 289..293

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

    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

        try:
            c_aacgmv2.set_datetime(dtime.year, dtime.month, dtime.day, dtime.hour,
                                   dtime.minute, dtime.second)
        except:
            raise RuntimeError("unable to set time for {:}".format(dtime))
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 1 hr to fix
    aacgmv2/wrapper.py on lines 150..154

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

    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

            if(np.nanmax(height) > 2000 and code.find("TRACE") < 0 and
               code.find("ALLOWTRACE") < 0 and code.find("BADIDEA") < 0):
                estr = 'coefficients are not valid for altitudes above 2000 km. You'
                estr += ' must either use field-line tracing (trace=True '
                estr += 'or allowtrace=True) or indicate you know this '
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 1 hr to fix
    aacgmv2/wrapper.py on lines 124..131

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

    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

            if(height > 2000 and code.find("TRACE") < 0 and
               code.find("ALLOWTRACE") < 0 and code.find("BADIDEA") < 0):
                estr = 'coefficients are not valid for altitudes above 2000 km. You'
                estr += ' must either use field-line tracing (trace=True '
                estr += 'or allowtrace=True) or indicate you know this '
    Severity: Major
    Found in aacgmv2/wrapper.py and 1 other location - About 1 hr to fix
    aacgmv2/wrapper.py on lines 262..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 43.

    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 main has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        """Entry point for the script"""
    
        desc = 'Converts between geographical coordinates, AACGM-v2, and MLT'
        parser = argparse.ArgumentParser(description=desc)
    Severity: Minor
    Found in aacgmv2/__main__.py - About 1 hr to fix

      Function convert has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def convert(lat, lon, alt, date=None, a2g=False, trace=False, allowtrace=False,
      Severity: Major
      Found in aacgmv2/deprecated.py - About 1 hr to fix

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

        if 'AACGM_v2_DAT_PREFIX' in _os.environ.keys():
            stderr.write("resetting environment variable AACGM_v2_DAT_PREFIX in " +
                         "python script\n")
            reset_warn = True
        Severity: Minor
        Found in aacgmv2/__init__.py and 1 other location - About 50 mins to fix
        aacgmv2/__init__.py on lines 57..60

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

        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 'IGRF_COEFFS' in _os.environ.keys():
            stderr.write("resetting environment variable IGRF_COEFFS in python "
                         + "script\n")
            reset_warn = True
        Severity: Minor
        Found in aacgmv2/__init__.py and 1 other location - About 50 mins to fix
        aacgmv2/__init__.py on lines 63..66

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

        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 3 locations. Consider refactoring.
        Open

                    if not test_array[2]:
                        height = np.ones(shape=arr_shape, dtype=float) * height
        Severity: Major
        Found in aacgmv2/wrapper.py and 2 other locations - About 50 mins to fix
        aacgmv2/wrapper.py on lines 222..223
        aacgmv2/wrapper.py on lines 224..225

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

        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 3 locations. Consider refactoring.
        Open

                    if not test_array[0]:
                        in_lat = np.ones(shape=arr_shape, dtype=float) * in_lat
        Severity: Major
        Found in aacgmv2/wrapper.py and 2 other locations - About 50 mins to fix
        aacgmv2/wrapper.py on lines 224..225
        aacgmv2/wrapper.py on lines 226..227

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

        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 3 locations. Consider refactoring.
        Open

                    if not test_array[1]:
                        in_lon = np.ones(shape=arr_shape, dtype=float) * in_lon
        Severity: Major
        Found in aacgmv2/wrapper.py and 2 other locations - About 50 mins to fix
        aacgmv2/wrapper.py on lines 222..223
        aacgmv2/wrapper.py on lines 226..227

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

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

        def convert_mlt(arr, dtime, m2a=False):
            """Converts between magnetic local time (MLT) and AACGM-v2 longitude
        
            Parameters
            ------------
        Severity: Minor
        Found in aacgmv2/wrapper.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 convert_latlon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def convert_latlon(in_lat, in_lon, height, dtime, code="G2A"):
            """Converts between geomagnetic coordinates and AACGM coordinates
        
            Parameters
            ------------
        Severity: Minor
        Found in aacgmv2/wrapper.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 convert_bool_to_bit has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def convert_bool_to_bit(a2g=False, trace=False, allowtrace=False,
        Severity: Minor
        Found in aacgmv2/wrapper.py - About 35 mins to fix

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

          def convert_latlon_arr(in_lat, in_lon, height, dtime, code="G2A"):
          Severity: Minor
          Found in aacgmv2/wrapper.py - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language