Unidata/MetPy

View on GitHub

Showing 56 of 139 total issues

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]
Severity: Minor
Found in src/metpy/io/gempak.py - About 2 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 _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]
Severity: Minor
Found in src/metpy/io/gempak.py - About 2 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 _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]
Severity: Minor
Found in src/metpy/io/gempak.py - About 2 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 _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]
Severity: Minor
Found in src/metpy/io/gempak.py - About 2 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

IOBuffer has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class IOBuffer:
    """Holds bytes from a buffer to simplify parsing and random access."""

    def __init__(self, source):
        """Initialize the IOBuffer with the source data."""
Severity: Minor
Found in src/metpy/io/_tools.py - About 2 hrs to fix

    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):
    Severity: Minor
    Found in src/metpy/io/gempak.py - About 2 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 __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']
    Severity: Minor
    Found in src/metpy/io/gempak.py - About 2 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 _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.
        """
    Severity: Minor
    Found in src/metpy/io/gempak.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 thickness_hydrostatic has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
    Open

    def thickness_hydrostatic(pressure, temperature, mixing_ratio=None,
                              molecular_weight_ratio=mpconsts.nounit.epsilon, bottom=None,
                              depth=None):
        r"""Calculate the thickness of a layer via the hypsometric equation.
    
    
    Severity: Minor
    Found in src/metpy/calc/thermo.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 _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]
    Severity: Minor
    Found in src/metpy/io/gempak.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 _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,
    Severity: Minor
    Found in src/metpy/io/gempak.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 find_axis_number has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
    Open

        def find_axis_number(self, axis):
            """Return the dimension number of the axis corresponding to the given identifier.
    
            Parameters
            ----------
    Severity: Minor
    Found in src/metpy/xarray.py - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function plot has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
    Open

        def plot(self, plotter, data_dict):
            """Plot a collection of data using this layout for a station plot.
    
            This function iterates through the entire specified layout, pulling the fields named
            in the layout from `data_dict` and plotting them using `plotter` as specified
    Severity: Minor
    Found in src/metpy/plots/station_plot.py - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function advection has 13 arguments (exceeds 10 allowed). Consider refactoring.
    Open

    def advection(
    Severity: Major
    Found in src/metpy/calc/kinematics.py - About 50 mins to fix

      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
      Severity: Major
      Found in src/metpy/io/gempak.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if parts[section]['PRES'][i] != self.prod_desc.missing_float:
                                    qcman.append(parts[section]['PRES'][i])
        
        
        Severity: Major
        Found in src/metpy/io/gempak.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              while not found:
                                  if sounding[var1][iabove] != missing:
                                      found = True
                                  else:
                                      iabove += 1
          Severity: Major
          Found in src/metpy/io/gempak.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if ibit > 32:
                                        ibit -= 32
                                        iword += 1
            
            
            Severity: Major
            Found in src/metpy/io/gempak.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if znxt == self.prod_desc.missing_float:
                                          more = False
              
              
              Severity: Major
              Found in src/metpy/io/gempak.py - About 45 mins to fix

                Function _unpack_packet_special_graphic_symbol has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
                Open

                    def _unpack_packet_special_graphic_symbol(self, code, in_sym_block):
                        type_map = {3: 'Mesocyclone', 11: '3D Correlated Shear', 12: 'TVS',
                                    26: 'ETVS', 13: 'Positive Hail', 14: 'Probable Hail',
                                    15: 'Storm ID', 19: 'HDA', 25: 'STI Circle'}
                        point_feature_map = {1: 'Mesocyclone (ext.)', 3: 'Mesocyclone',
                Severity: Minor
                Found in src/metpy/io/nexrad.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

                Severity
                Category
                Status
                Source
                Language