# cmeeren/aacgmv2

aacgmv2/wrapper.py

### Summary

F
6 days

#### File `wrapper.py` has 508 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
#``````
Found in aacgmv2/wrapper.py - About 1 day to fix

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

``````def convert_latlon_arr(in_lat, in_lon, height, dtime, method_code="G2A",
**kwargs):
"""Converts between geomagnetic coordinates and AACGM coordinates.

Parameters``````
Found in aacgmv2/wrapper.py - About 6 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"

#### 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
------------``````
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"

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

``````def convert_latlon(in_lat, in_lon, height, dtime, method_code="G2A", **kwargs):
"""Converts between geomagnetic coordinates and AACGM coordinates

Parameters
------------``````
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"

#### 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
-----------``````
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"

#### Function `convert_latlon` has 6 arguments (exceeds 4 allowed). Consider refactoring. Open

``def convert_latlon(in_lat, in_lon, height, dtime, method_code="G2A", **kwargs):``
Found in aacgmv2/wrapper.py - About 45 mins to fix

#### Function `convert_latlon_arr` has 6 arguments (exceeds 4 allowed). Consider refactoring. Open

``def convert_latlon_arr(in_lat, in_lon, height, dtime, method_code="G2A",``
Found in aacgmv2/wrapper.py - About 45 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"):``
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"):``
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,``
Found in aacgmv2/wrapper.py - About 35 mins to fix

#### 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``````
Found in aacgmv2/wrapper.py and 1 other location - About 4 hrs to fix
aacgmv2/wrapper.py on lines 141..151

## 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

#### 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``````
Found in aacgmv2/wrapper.py and 1 other location - About 4 hrs to fix
aacgmv2/wrapper.py on lines 128..138

## 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

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

``````    for kw in kwargs.keys():
if kw not in ['code']:
raise TypeError('unexpected keyword argument [{:s}]'.format(kw))
else:
method_code = kwargs[kw]``````
Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
aacgmv2/wrapper.py on lines 312..319

## 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 70.

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

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

``````    for kw in kwargs.keys():
if kw not in ['code']:
raise TypeError('unexpected keyword argument [{:s}]'.format(kw))
else:
method_code = kwargs[kw]``````
Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
aacgmv2/wrapper.py on lines 195..202

## 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 70.

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

#### 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 as terr:
raise TypeError("unable to set time for {:}: {:}".format(dtime, terr))``````
Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
aacgmv2/wrapper.py on lines 238..245

## 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 69.

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

#### 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 as terr:
raise TypeError("unable to set time for {:}: {:}".format(dtime, terr))``````
Found in aacgmv2/wrapper.py and 1 other location - About 3 hrs to fix
aacgmv2/wrapper.py on lines 398..405

## 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 69.

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

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

``````            out = c_aacgmv2.mlt_convert(years[0], months[0], days[0], hours[0],
minutes[0], seconds[0], arr[0])``````
Found in aacgmv2/wrapper.py and 1 other location - About 2 hrs to fix
aacgmv2/wrapper.py on lines 660..663

## 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 59.

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

#### 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])``````
Found in aacgmv2/wrapper.py and 1 other location - About 2 hrs to fix
aacgmv2/wrapper.py on lines 670..671

## 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 59.

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