USDA-ARS-NWRC/smrf

View on GitHub

Showing 113 of 134 total issues

File model_framework.py has 574 lines of code (exceeds 300 allowed). Consider refactoring.
Open

"""
The module :mod:`~smrf.framework.model_framework` contains functions and
classes that act as a major wrapper to the underlying packages and modules
contained with SMRF. A class instance of
:class:`~smrf.framework.model_framework.SMRF` is initialized with a
Severity: Major
Found in smrf/framework/model_framework.py - About 1 day to fix

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

            for m in matching:
                ms = m.split('_')
                if type(self.config[m]) == list:
                    v[ms[1]] = float(self.config[m][0])
                else:
    Severity: Major
    Found in smrf/distribute/wind/winstral.py and 1 other location - About 6 hrs to fix
    smrf/distribute/precipitation.py on lines 227..233

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

    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

                    if m != 'winstral_veg_default':
                        ms = m.split('_')
                        # v[ms[1]] = float(self.config[m])
                        if type(self.config[m]) == list:
                            v[ms[1]] = float(self.config[m][0])
    Severity: Major
    Found in smrf/distribute/precipitation.py and 1 other location - About 6 hrs to fix
    smrf/distribute/wind/winstral.py on lines 108..113

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

    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 3 locations. Consider refactoring.
    Open

            if flag == 1 and pv[0] < 0:
                pv = np.array([0, 0])
            elif (flag == -1 and pv[0] > 0):
                pv = np.array([0, 0])
    Severity: Major
    Found in smrf/spatial/grid.py and 2 other locations - About 4 hrs to fix
    smrf/spatial/idw.py on lines 124..127
    smrf/spatial/kriging.py on lines 126..129

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

    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 3 locations. Consider refactoring.
    Open

            if flag == 1 and pv[0] < 0:
                pv = np.array([0, 0])
            elif (flag == -1 and pv[0] > 0):
                pv = np.array([0, 0])
    Severity: Major
    Found in smrf/spatial/idw.py and 2 other locations - About 4 hrs to fix
    smrf/spatial/grid.py on lines 192..195
    smrf/spatial/kriging.py on lines 126..129

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

    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 3 locations. Consider refactoring.
    Open

            if flag == 1 and pv[0] < 0:
                pv = np.array([0, 0])
            elif (flag == -1 and pv[0] > 0):
                pv = np.array([0, 0])
    Severity: Major
    Found in smrf/spatial/kriging.py and 2 other locations - About 4 hrs to fix
    smrf/spatial/grid.py on lines 192..195
    smrf/spatial/idw.py on lines 124..127

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

    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

    File solar.py has 411 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    from smrf.distribute import image_data
    from smrf.envphys.constants import IR_WAVELENGTHS, VISIBLE_WAVELENGTHS
    from smrf.envphys.solar import cloud, toporad, vegetation
    from smrf.utils import utils
    
    
    Severity: Minor
    Found in smrf/distribute/solar.py - About 4 hrs to fix

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

      def isint(x):
          '''Test if value is an integer'''
          if isinstance(x, float) or isinstance(x, basestring) and '.' in x:
              return False
          try:
      Severity: Major
      Found in smrf/utils/io.py and 1 other location - About 4 hrs to fix
      smrf/utils/io.py on lines 12..22

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

      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

      def isbool(x):
          '''Test if str is an bolean'''
          if isinstance(x, float) or isinstance(x, basestring) and '.' in x:
              return False
          try:
      Severity: Major
      Found in smrf/utils/io.py and 1 other location - About 4 hrs to fix
      smrf/utils/io.py on lines 35..45

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

      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

      File precipitation.py has 404 lines of code (exceeds 300 allowed). Consider refactoring.
      Open

      import netCDF4 as nc
      import numpy as np
      
      from smrf.distribute import image_data
      from smrf.envphys import precip, Snow, storms
      Severity: Minor
      Found in smrf/distribute/precipitation.py - About 4 hrs to fix

        Function stationMaxus has a Cognitive Complexity of 32 (exceeds 8 allowed). Consider refactoring.
        Open

            def stationMaxus(self, data_speed, data_direction):
                """
                Determine the maxus value at the station given the wind direction.
                Can specify the enhancemet for each station or use the default, along
                with whether or not the station is on a peak which will ensure that
        Severity: Minor
        Found in smrf/distribute/wind/winstral.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

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

                        ad[i, j] = np.sqrt((mx[i] - mx[j])**2 + (my[i] - my[j])**2)
        Severity: Major
        Found in smrf/spatial/dk/dk.py and 1 other location - About 4 hrs to fix
        smrf/spatial/dk/dk.py on lines 114..114

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

        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

                        ad[j, i] = np.sqrt((mx[i] - mx[j])**2 + (my[i] - my[j])**2)
        Severity: Major
        Found in smrf/spatial/dk/dk.py and 1 other location - About 4 hrs to fix
        smrf/spatial/dk/dk.py on lines 113..113

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

        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

        Function ephemeris has 88 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

        def ephemeris(dt):
            """
            Calculates radius vector, declination, and apparent longitude
            of sun, as function of the given date and time.
        
        
        Severity: Major
        Found in smrf/envphys/sunang.py - About 3 hrs to fix

          Function initialize has a Cognitive Complexity of 26 (exceeds 8 allowed). Consider refactoring.
          Open

              def initialize(self, topo, data, date_time=None):
          
                  self._logger.debug('Initializing distribute.precip')
          
                  self.date_time = date_time
          Severity: Minor
          Found in smrf/distribute/precipitation.py - About 3 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

          File utils.py has 344 lines of code (exceeds 300 allowed). Consider refactoring.
          Open

          import copy
          import os
          import random
          import sys
          from datetime import datetime
          Severity: Minor
          Found in smrf/utils/utils.py - About 3 hrs to fix

            File model.py has 339 lines of code (exceeds 300 allowed). Consider refactoring.
            Open

            from __future__ import print_function
            
            import os
            # import matplotlib.pyplot as plt
            # import progressbar
            Severity: Minor
            Found in smrf/utils/wind/model.py - About 2 hrs to fix

              Function tracking_by_station has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
              Open

              def tracking_by_station(precip, mass_thresh=0.01, steps_thresh=3):
                  """
                  Processes the vector station data prior to the data being distributed
              
                  Args:
              Severity: Minor
              Found in smrf/envphys/storms.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

              File sunang.py has 323 lines of code (exceeds 300 allowed). Consider refactoring.
              Open

              import logging
              from math import asin, atan, cos, fmod, sin, sqrt, tan
              
              import numpy as np
              import pytz
              Severity: Minor
              Found in smrf/envphys/sunang.py - About 2 hrs to fix

                Function put has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
                Open

                    def put(self, item, block=True, timeout=None):
                        """Put an item into the queue.
                
                        If optional args 'block' is true and 'timeout' is None (the default),
                        block if necessary until a free slot is available. If 'timeout' is
                Severity: Minor
                Found in smrf/utils/queue.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

                Severity
                Category
                Status
                Source
                Language