Unidata/MetPy

View on GitHub

Showing 56 of 141 total issues

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

    Avoid deeply nested control flow statements.
    Open

                            if jshft > 0:
                                jshft -= 32
                                idat2 = self._fortran_ishift(packed_buffer[iword + 1], jshft)
                                idat |= idat2
    
    
    Severity: Major
    Found in src/metpy/io/gempak.py - About 45 mins to fix

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

          def _decode_msg31(self, msg_hdr):
              msg_start = self._buffer.set_mark()
              data_hdr = self._buffer.read_struct(self.msg31_data_hdr_fmt)
              if data_hdr.compression:
                  log.warning('Compressed message 31 not supported!')
      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

      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

        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

        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

          Function interpolate_to_grid has 12 arguments (exceeds 10 allowed). Consider refactoring.
          Open

          def interpolate_to_grid(x, y, z, interp_type='linear', hres=50000,
          Severity: Major
          Found in src/metpy/interpolate/grid.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

              Consider simplifying this complex logical expression.
              Open

                  if 'OVC' in tree.skyc.text or 'VV' in tree.skyc.text:
                      cloudcover = 8
                  elif 'BKN' in tree.skyc.text:
                      cloudcover = 6
                  elif 'SCT' in tree.skyc.text:
              Severity: Major
              Found in src/metpy/io/metar.py - About 40 mins to fix

                Function angle_to_direction has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                Open

                def angle_to_direction(input_angle, full=False, level=3):
                    """Convert the meteorological angle to directional text.
                
                    Works for angles greater than or equal to 360 (360 -> N | 405 -> NE)
                    and rounds to the nearest angle (355 -> N | 404 -> NNE)
                Severity: Minor
                Found in src/metpy/calc/tools.py - About 35 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 lfc has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                Open

                def lfc(pressure, temperature, dewpoint, parcel_temperature_profile=None, dewpoint_start=None,
                        which='top'):
                    r"""Calculate the level of free convection (LFC).
                
                    This works by finding the first intersection of the ideal parcel path and
                Severity: Minor
                Found in src/metpy/calc/thermo.py - About 35 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 get_layer has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                Open

                def get_layer(pressure, *args, height=None, bottom=None, depth=None, interpolate=True):
                    r"""Return an atmospheric layer from upper air data with the requested bottom and depth.
                
                    This function will subset an upper air dataset to contain only the specified layer. The
                    bottom of the layer can be specified with a pressure or height above the surface
                Severity: Minor
                Found in src/metpy/calc/tools.py - About 35 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 wx_code_to_numeric has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
                Open

                def wx_code_to_numeric(codes):
                    """Determine the numeric weather symbol value from METAR code text.
                
                    A robust method to identifies the numeric value for plotting the correct symbol from a
                    decoded METAR current weather group. The METAR codes should be strings with no missing
                Severity: Minor
                Found in src/metpy/plots/wx_symbols.py - About 35 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 _check_argument_units has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
                Open

                def _check_argument_units(args, defaults, dimensionality):
                    """Yield arguments with improper dimensionality."""
                    for arg, val in args.items():
                        # Get the needed dimensionality (for printing) as well as cached, parsed version
                        # for this argument.
                Severity: Minor
                Found in src/metpy/units.py - About 25 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 _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 [
                Severity: Minor
                Found in src/metpy/io/gempak.py - About 25 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 griddata has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
                Open

                    def griddata(self):
                        """Return the internal cached data."""
                        if getattr(self, '_griddata_u', None) is None:
                
                            if not self.field[0]:
                Severity: Minor
                Found in src/metpy/plots/declarative.py - About 25 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