USDA-ARS-NWRC/smrf

View on GitHub

Showing 113 of 134 total issues

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

    if isinstance(mu_r, np.ndarray):
        if np.any(mu_r < -1.0) or np.any(mu_r > 1.0):
            raise ValueError("rotate, mu_r array is not between -1 and +1")
    else:
        if mu_r < -1.0 or mu_r > 1.0:
Severity: Minor
Found in smrf/envphys/sunang.py and 1 other location - About 40 mins to fix
smrf/envphys/sunang.py on lines 353..355

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

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 __init__ has 7 arguments (exceeds 6 allowed). Consider refactoring.
Open

    def __init__(self, mx, my, mz, GridX, GridY, GridZ, config):
Severity: Major
Found in smrf/spatial/kriging.py - About 35 mins to fix

    Function __init__ has 7 arguments (exceeds 6 allowed). Consider refactoring.
    Open

        def __init__(self, mx, my, mz, GridX, GridY, GridZ, config):
    Severity: Major
    Found in smrf/spatial/dk/dk.py - About 35 mins to fix

      Function tracking_by_basin has 7 arguments (exceeds 6 allowed). Consider refactoring.
      Open

      def tracking_by_basin(precipitation, time, storm_lst, time_steps_since_precip,
      Severity: Major
      Found in smrf/envphys/storms.py - About 35 mins to fix

        Function distribute has 7 arguments (exceeds 6 allowed). Consider refactoring.
        Open

            def distribute(self, date_time, cloud_factor, illum_ang, cosz, azimuth,
        Severity: Major
        Found in smrf/distribute/solar.py - About 35 mins to fix

          Function toporad has 7 arguments (exceeds 6 allowed). Consider refactoring.
          Open

          def toporad(beam, diffuse, illum_angle, sky_view_factor, terrain_config_factor,
          Severity: Major
          Found in smrf/envphys/solar/toporad.py - About 35 mins to fix

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

                        elif self.config['distribution'] == 'kriging':
                            # generic kriging
                            self.kriging = kriging.KRIGE(
                                self.mx, self.my, self.mz, topo.X,
                                topo.Y,
            Severity: Minor
            Found in smrf/distribute/image_data.py and 1 other location - About 35 mins to fix
            smrf/distribute/image_data.py on lines 180..185

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

            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 catchment_ratios has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
            Open

            def catchment_ratios(ws, gauge_type, snowing):
                """
                Point models for catchment ratios of the
                """
            
            
            Severity: Minor
            Found in smrf/envphys/precip.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 ephemeris has a Cognitive Complexity of 10 (exceeds 8 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: Minor
            Found in smrf/envphys/sunang.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

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

                        elif self.config['distribution'] == 'dk':
                            # detrended kriging
                            self.dk = dk.DK(
                                self.mx, self.my, self.mz, topo.X, topo.Y,
                                topo.dem,
            Severity: Minor
            Found in smrf/distribute/image_data.py and 1 other location - About 35 mins to fix
            smrf/distribute/image_data.py on lines 197..203

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

            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

                            d_h = np.sqrt(np.power(x[i] - x[h[j]], 2) +
                                          np.power(y[i] - y[h[j]], 2))
            Severity: Minor
            Found in smrf/utils/wind/model.py and 1 other location - About 30 mins to fix
            smrf/utils/wind/model.py on lines 412..412

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

            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

                    grid_intercept = grid_interpolate_deconstructed(
                        self.tri,
                        df.intercept.values[:],
                        (self.GridX, self.GridY),
            Severity: Minor
            Found in smrf/spatial/grid.py and 1 other location - About 30 mins to fix
            smrf/spatial/grid.py on lines 151..154

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

            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

                    grid_slope = grid_interpolate_deconstructed(
                        self.tri,
                        df.slope.values[:],
                        (self.GridX, self.GridY),
            Severity: Minor
            Found in smrf/spatial/grid.py and 1 other location - About 30 mins to fix
            smrf/spatial/grid.py on lines 157..160

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

            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

            Severity
            Category
            Status
            Source
            Language