Function _merge_sounding
has a Cognitive Complexity of 141 (exceeds 15 allowed). Consider refactoring. Open
def _merge_sounding(self, parts):
"""Merge unmerged sounding data."""
merged = {'STID': parts['STID'],
'STNM': parts['STNM'],
'SLAT': parts['SLAT'],
- Read upRead up
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 gdxarray
has a Cognitive Complexity of 73 (exceeds 15 allowed). Consider refactoring. Open
def gdxarray(self, parameter=None, date_time=None, coordinate=None,
level=None, date_time2=None, level2=None):
"""Select grids and output as list of xarray DataArrays.
Subset the data by parameter values. The default is to not
- Read upRead up
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 _unpack_grid
has a Cognitive Complexity of 71 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_grid(self, packing_type, part):
"""Read raw GEMPAK grid integers and unpack into floats."""
if packing_type == PackingType.none:
lendat = self.data_header_length - part.header_length - 1
- Read upRead up
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 snxarray
has a Cognitive Complexity of 59 (exceeds 15 allowed). Consider refactoring. Open
def snxarray(self, station_id=None, station_number=None,
date_time=None, state=None, country=None):
"""Select soundings and output as list of xarray Datasets.
Subset the data by parameter values. The default is to not
- Read upRead up
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 _key_types
has a Cognitive Complexity of 55 (exceeds 15 allowed). Consider refactoring. Open
def _key_types(self, keys):
"""Determine header information from a set of keys."""
return [(key, '4s', self._decode_strip) if key == 'STID'
else (key, 'i') if key == 'STNM'
else (key, 'i', lambda x: x / 100) if key == 'SLAT'
- Read upRead up
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 _interp_logp_data
has a Cognitive Complexity of 55 (exceeds 15 allowed). Consider refactoring. Open
def _interp_logp_data(sounding, missing=-9999):
"""Interpolate missing sounding data.
This function is similar to the MR_MISS subroutine in GEMPAK.
"""
- Read upRead up
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 __init__
has a Cognitive Complexity of 51 (exceeds 15 allowed). Consider refactoring. Open
def __init__(self, file, *args, **kwargs):
super().__init__(file)
# Row Headers
self._buffer.jump_to(self._start, _word_to_position(self.prod_desc.row_headers_ptr))
- Read upRead up
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 sfjson
has a Cognitive Complexity of 51 (exceeds 15 allowed). Consider refactoring. Open
def sfjson(self, station_id=None, station_number=None,
date_time=None, state=None, country=None,
include_special=False):
"""Select surface stations and output as list of JSON objects.
- Read upRead up
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 __init__
has a Cognitive Complexity of 47 (exceeds 15 allowed). Consider refactoring. Open
def __init__(self, file, *args, **kwargs):
super().__init__(file)
# Row Headers
self._buffer.jump_to(self._start, _word_to_position(self.prod_desc.row_headers_ptr))
- Read upRead up
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 _merge_winds_height
has a Cognitive Complexity of 45 (exceeds 15 allowed). Consider refactoring. Open
def _merge_winds_height(self, merged, parts, nsgw, nasw, istart):
"""Merge wind sections on height surfaces."""
size = len(merged['HGHT'])
psfc = merged['PRES'][0]
zsfc = merged['HGHT'][0]
- Read upRead up
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 _interp_moist_height
has a Cognitive Complexity of 38 (exceeds 15 allowed). Consider refactoring. Open
def _interp_moist_height(sounding, missing=-9999):
"""Interpolate moist hydrostatic height.
This function mimics the functionality of the MR_SCMZ
subroutine in GEMPAK. This the default behavior when
- Read upRead up
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 _interp_logp_height
has a Cognitive Complexity of 36 (exceeds 15 allowed). Consider refactoring. Open
def _interp_logp_height(sounding, missing=-9999):
"""Interpolate height linearly with respect to log p.
This function mimics the functionality of the MR_INTZ
subroutine in GEMPAK.
- Read upRead up
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 _unpack_ship
has a Cognitive Complexity of 29 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_ship(self, sfcno):
"""Unpack ship (moving observation) surface data file."""
stations = []
for irow, icol in sfcno: # irow should always be zero
col_head = self.column_headers[icol]
- Read upRead up
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 _unpack_standard
has a Cognitive Complexity of 29 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_standard(self, sfcno):
"""Unpack a standard surface data file."""
stations = []
for irow, icol in sfcno:
row_head = self.row_headers[irow]
- Read upRead up
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 _unpack_unmerged
has a Cognitive Complexity of 29 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_unmerged(self, sndno):
"""Unpack unmerged sounding data."""
soundings = []
for irow, icol in sndno:
row_head = self.row_headers[irow]
- Read upRead up
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 _unpack_climate
has a Cognitive Complexity of 29 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_climate(self, sfcno):
"""Unpack a climate surface data file."""
stations = []
for irow, icol in sfcno:
col_head = self.column_headers[icol]
- Read upRead up
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 __init__
has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring. Open
def __init__(self, file):
"""Instantiate GempakFile object from file."""
fobj = open_as_needed(file)
with contextlib.closing(fobj):
- Read upRead up
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 __init__
has a Cognitive Complexity of 26 (exceeds 15 allowed). Consider refactoring. Open
def __init__(self, file, *args, **kwargs):
super().__init__(file)
datetime_names = ['GDT1', 'GDT2']
level_names = ['GLV1', 'GLV2']
- Read upRead up
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 _interp_parameters
has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring. Open
def _interp_parameters(vlev, adata, bdata, missing=-9999):
"""General interpolation with respect to log-p.
See the PC_INTP subroutine in GEMPAK.
"""
- Read upRead up
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 _unpack_merged
has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open
def _unpack_merged(self, sndno):
"""Unpack merged sounding data."""
soundings = []
for irow, icol in sndno:
row_head = self.row_headers[irow]
- Read upRead up
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 _merge_mandatory_temps
has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring. Open
def _merge_mandatory_temps(self, merged, parts, section, qcman, bgl, plast):
"""Process and merge mandatory temperature sections."""
num_levels = len(parts[section]['PRES'])
start_level = {
'TTAA': 1,
- Read upRead up
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
Avoid deeply nested control flow statements. Wontfix
if data_ptr:
self._sfinfo.add(
Surface(
irow,
icol,
Avoid deeply nested control flow statements. Open
if var2 is not None:
sounding[var2][i] = outdata[var2]
i += 1
Avoid deeply nested control flow statements. Open
if (self.grid_meta_int.missing_flag and idat == imiss):
grid[j, i] = self.prod_desc.missing_float
else:
if first:
grid[j, i] = self.grid_meta_real.reference
Avoid deeply nested control flow statements. Open
if parts[section]['PRES'][i] != self.prod_desc.missing_float:
qcman.append(parts[section]['PRES'][i])
Avoid deeply nested control flow statements. Open
for param, val in sounding.items():
if (param in ['PRES', 'TEMP', 'DWPT',
'DRCT', 'SPED', 'HGHT']):
adata[param] = val[i - 1]
bdata[param] = val[iabove]
Avoid deeply nested control flow statements. Open
if ibit > 32:
ibit -= 32
iword += 1
Avoid deeply nested control flow statements. Wontfix
if data_ptr:
self._sfinfo.add(
Surface(
irow,
icol,
Avoid deeply nested control flow statements. Open
if znxt == self.prod_desc.missing_float:
more = False
Avoid deeply nested control flow statements. Open
if jshft > 0:
jshft -= 32
idat2 = self._fortran_ishift(packed_buffer[iword + 1], jshft)
idat |= idat2
Avoid deeply nested control flow statements. Open
while not found:
if sounding[var1][iabove] != missing:
found = True
else:
iabove += 1
Function _merge_tropopause_data
has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring. Open
def _merge_tropopause_data(self, merged, parts, section, pbot):
"""Process and merge tropopause sections."""
for itrp, press in enumerate(parts[section]['PRES']):
press = abs(press)
if self.prod_desc.missing_float not in [
- Read upRead up
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
Remove this commented out code. Open
# integer_meta_fmt = [('bits', 'i'), ('missing_flag', 'i'), ('kxky', 'i')]
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
# grid_start = self._buffer.set_mark()
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
# integer_meta_fmt = [('iuscal', 'i'), ('kx', 'i'),
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
# grid_start = self._buffer.set_mark()
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Remove this commented out code. Open
# parts = self._buffer.set_mark()
- Read upRead up
- Exclude checks
Programmers should not comment out code as it bloats programs and reduces readability.
Unused code should be deleted and can be retrieved from source control history if required.
See
- MISRA C:2004, 2.4 - Sections of code should not be "commented out".
- MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
- MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
- MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"
Either merge this branch with the identical one on line "266" or change one of the implementations. Invalid
continue
- Read upRead up
- Exclude checks
Having two branches in the same if
structure with the same implementation is at best duplicate code, and at worst a coding error. If
the same logic is truly needed for both instances, then they should be combined.
Noncompliant Code Example
if 0 <= a < 10: do_the_thing() elif 10 <= a < 20: do_the_other_thing() elif 20 <= a < 50: do_the_thing() # Noncompliant; duplicates first condition else: do_the_rest() b = 4 if a > 12 else 4
Compliant Solution
if (0 <= a < 10) or (20 <= a < 50): do_the_thing() elif 10 <= a < 20: do_the_other_thing() else: do_the_rest() b = 4
or
if 0 <= a < 10: do_the_thing() elif 10 <= a < 20: do_the_other_thing() elif 20 <= a < 50: do_the_third_thing() else: do_the_rest() b = 8 if a > 12 else 4