aburrell/aacgmv2

View on GitHub
aacgmv2/wrapper.py

Summary

Maintainability
F
6 days
Test Coverage

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

# Copyright (C) 2019 NRL
# Author: Angeline Burrell
# Disclaimer: This code is under the MIT license, whose details can be found at
# the root in the LICENSE file
#
Severity: Minor
Found in aacgmv2/wrapper.py - About 7 hrs to fix

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

    def convert_latlon_arr(in_lat, in_lon, height, dtime, method_code="G2A"):
        """Convert between geomagnetic coordinates and AACGM coordinates.
    
        Parameters
        ----------
    Severity: Minor
    Found in aacgmv2/wrapper.py - About 4 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 convert_mlt has a Cognitive Complexity of 14 (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 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 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):
        """Set 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

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

    def convert_latlon(in_lat, in_lon, height, dtime, method_code="G2A"):
        """Convert 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_latlon_arr has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

      def convert_latlon(in_lat, in_lon, height, dtime, method_code="G2A"):
      Severity: Minor
      Found in aacgmv2/wrapper.py - About 35 mins to fix

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

        def get_aacgm_coord(glat, glon, height, dtime, method="ALLOWTRACE"):
        Severity: Minor
        Found in aacgmv2/wrapper.py - About 35 mins to fix

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

          def get_aacgm_coord_arr(glat, glon, height, dtime, method="ALLOWTRACE"):
          Severity: Minor
          Found in aacgmv2/wrapper.py - About 35 mins to fix

            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

              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 123..133

              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 136..146

              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 len(arr) == 1:
                          out = c_aacgmv2.inv_mlt_convert(years[0], months[0], days[0],
                                                          hours[0], minutes[0], seconds[0],
                                                          arr[0])
                          out = np.array([out])
              Severity: Major
              Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
              aacgmv2/wrapper.py on lines 664..667

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

              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 len(arr) == 1:
                          out = c_aacgmv2.mlt_convert(years[0], months[0], days[0], hours[0],
                                                      minutes[0], seconds[0], arr[0])
                          out = np.array([out])
              Severity: Major
              Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
              aacgmv2/wrapper.py on lines 654..658

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

              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] or (len(in_lat) == 1 and max_len > 1):
                              in_lat = np.full(shape=(max_len,), fill_value=in_lat)
              Severity: Major
              Found in aacgmv2/wrapper.py and 2 other locations - About 2 hrs to fix
              aacgmv2/wrapper.py on lines 338..339
              aacgmv2/wrapper.py on lines 340..341

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

              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] or (len(in_lon) == 1 and max_len > 1):
                              in_lon = np.full(shape=(max_len,), fill_value=in_lon)
              Severity: Major
              Found in aacgmv2/wrapper.py and 2 other locations - About 2 hrs to fix
              aacgmv2/wrapper.py on lines 336..337
              aacgmv2/wrapper.py on lines 340..341

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

              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] or (len(height) == 1 and max_len > 1):
                              height = np.full(shape=(max_len,), fill_value=height)
              Severity: Major
              Found in aacgmv2/wrapper.py and 2 other locations - About 2 hrs to fix
              aacgmv2/wrapper.py on lines 336..337
              aacgmv2/wrapper.py on lines 338..339

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

              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 (TypeError, RuntimeError) as err:
                      raise RuntimeError("cannot set time for {:}: {:}".format(dtime, err))
              Severity: Major
              Found in aacgmv2/wrapper.py and 1 other location - About 2 hrs to fix
              aacgmv2/wrapper.py on lines 232..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 52.

              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 (TypeError, RuntimeError) as err:
                      raise RuntimeError("cannot set time for {:}: {:}".format(dtime, err))
              Severity: Major
              Found in aacgmv2/wrapper.py and 1 other location - About 2 hrs to fix
              aacgmv2/wrapper.py on lines 379..383

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

              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

              There are no issues that match your filters.

              Category
              Status