avaframe/AvaFrame

View on GitHub

Showing 909 of 937 total issues

File com1DFA.py has 2154 lines of code (exceeds 300 allowed). Consider refactoring.
Confirmed

"""
    Main functions for python DFA kernel
"""

import copy
Severity: Major
Found in avaframe/com1DFA/com1DFA.py - About 5 days to fix

    File geoTrans.py has 1459 lines of code (exceeds 300 allowed). Consider refactoring.
    Open

    """ Opperations and transformations of rasters and lines
    """
    
    import logging
    import math
    Severity: Major
    Found in avaframe/in3Utils/geoTrans.py - About 3 days to fix

      File outAna1Plots.py has 1299 lines of code (exceeds 300 allowed). Consider refactoring.
      Open

      # imports
      import numpy as np
      import pandas as pds
      import matplotlib.pyplot as plt
      import matplotlib.patches as patches
      Severity: Major
      Found in avaframe/out3Plot/outAna1Plots.py - About 3 days to fix

        File outAIMEC.py has 1111 lines of code (exceeds 300 allowed). Consider refactoring.
        Open

        """
            Plotting and saving AIMEC results
        
            This file is part of Avaframe.
        """
        Severity: Major
        Found in avaframe/out3Plot/outAIMEC.py - About 2 days to fix

          File aimecTools.py has 1098 lines of code (exceeds 300 allowed). Consider refactoring.
          Open

          """
              Main logic for AIMEC post processing
          """
          
          import logging
          Severity: Major
          Found in avaframe/ana3AIMEC/aimecTools.py - About 2 days to fix

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

                    if cfg['TOPO'].getboolean('topoAdd'):
                        zv = zv + cExtent*c0*(1. - np.sqrt(np.abs(1. - (np.square(yv) / (cExtent**2)))))*mask
                        mask = np.zeros(np.shape(yv))
                        mask[np.where(abs(yv) >= cExtent)] = 1
                        zv = zv + cExtent*c0*mask
            Severity: Major
            Found in avaframe/in3Utils/generateTopo.py and 2 other locations - About 2 days to fix
            avaframe/in3Utils/generateTopo.py on lines 258..265
            avaframe/in3Utils/generateTopo.py on lines 331..338

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

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

                    if cfg['TOPO'].getboolean('topoAdd'):
                        superChannel = superChannel + cExtent*c0*(1. - np.sqrt(np.abs(1. - (np.square(y) / (cExtent**2)))))*mask
                        # outside of the channel, add layer of channel thickness
                        mask = np.zeros(np.shape(y))
                        mask[np.where(abs(y) >= cExtent)] = 1
            Severity: Major
            Found in avaframe/in3Utils/generateTopo.py and 2 other locations - About 2 days to fix
            avaframe/in3Utils/generateTopo.py on lines 111..117
            avaframe/in3Utils/generateTopo.py on lines 258..265

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

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

                    if cfg['TOPO'].getboolean('topoAdd'):
                        zv = zv + cExtent*c0*(1. - np.sqrt(np.abs(1. - (np.square(y) / (cExtent**2)))))*mask
                        # outside of the channel, add layer of channel thickness
                        mask = np.zeros(np.shape(y))
                        mask[np.where(abs(y) >= cExtent)] = 1
            Severity: Major
            Found in avaframe/in3Utils/generateTopo.py and 2 other locations - About 2 days to fix
            avaframe/in3Utils/generateTopo.py on lines 111..117
            avaframe/in3Utils/generateTopo.py on lines 331..338

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

            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 simiSolTest.py has 863 lines of code (exceeds 300 allowed). Consider refactoring.
            Open

            """
            Similarity solution module
            
            This module contains functions that compute the similarity solution
            for a gliding avalanche on a inclined plane according to similarity solution from :
            Severity: Major
            Found in avaframe/ana1Tests/simiSolTest.py - About 1 day to fix

              File particleTools.py has 759 lines of code (exceeds 300 allowed). Consider refactoring.
              Open

              """
                  Tools for handling particles, splitting, merging and tracking.
              """
              
              # Load modules
              Severity: Major
              Found in avaframe/com1DFA/particleTools.py - About 1 day to fix

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

                        ax21.plot([row['%s_LineStart' % nameEvent]+row['%s_LineDist' % nameEvent][0],
                            row['%s_LineStart' % nameEvent]+row['%s_LineDist' % nameEvent][-1]],
                            [row['%s_Line' % nameEvent].coords[0][2],row['%s_Line' % nameEvent].coords[-1][2]],
                            '--', color='lightgray', linewidth=4, alpha=1., label='beta line [%.1f°]' % row['%s_Angle' % nameEvent])
                Severity: Major
                Found in avaframe/out3Plot/amaPlots.py and 1 other location - About 1 day to fix
                avaframe/out3Plot/amaPlots.py on lines 98..102

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

                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

                        ax21.plot([row['%s_LineStart' % nameEvent]+row['%s_LineDist' % nameEvent][0],
                            row['%s_LineStart' % nameEvent]+row['%s_LineDist' % nameEvent][-1]],
                            [row['%s_Line' % nameEvent].coords[0][2],
                            row['%s_Line' % nameEvent].coords[-1][2]], '--', color='gray', linewidth=3, alpha=1,
                            label='theta line [%.1f°]' % row['%s_Angle' % nameEvent])
                Severity: Major
                Found in avaframe/out3Plot/amaPlots.py and 1 other location - About 1 day to fix
                avaframe/out3Plot/amaPlots.py on lines 88..91

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

                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 outDistanceTimeAnalysis.py has 711 lines of code (exceeds 300 allowed). Consider refactoring.
                Open

                """ functions to plot range-time diagrams """
                
                import numpy as np
                from matplotlib import pyplot as plt
                import logging
                Severity: Major
                Found in avaframe/out3Plot/outDistanceTimeAnalysis.py - About 1 day to fix

                  File plotUtils.py has 674 lines of code (exceeds 300 allowed). Consider refactoring.
                  Open

                  """
                      Plot settings for output figures
                  
                      This file is part of Avaframe.
                  """
                  Severity: Major
                  Found in avaframe/out3Plot/plotUtils.py - About 1 day to fix

                    Function writeReportFile has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def writeReportFile(reportD, pfile):
                        """ Create markdown report with blocks, tables, list according to type key
                    
                            Parameters
                            ----------
                    Severity: Minor
                    Found in avaframe/log2Report/generateReport.py - About 1 day 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 probAna.py has 667 lines of code (exceeds 300 allowed). Consider refactoring.
                    Open

                    """
                    
                    This is a simple function for computing a probability map of all peak files of one parameter that
                    exceed a particular threshold
                    
                    
                    Severity: Major
                    Found in avaframe/ana4Stats/probAna.py - About 1 day to fix

                      File getInput.py has 635 lines of code (exceeds 300 allowed). Consider refactoring.
                      Open

                      """
                          Fetch input data for avalanche simulations
                      """
                      
                      import logging
                      Severity: Major
                      Found in avaframe/in1Data/getInput.py - About 1 day to fix

                        Function plotContoursTransformed has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def plotContoursTransformed(contourDict, pathDict, rasterTransfo, cfgSetup, inputsDF):
                            """ plot contour lines of all transformed fields
                                colorcode contour lines with first parameter in varParList if not type string of value
                        
                                Parameters
                        Severity: Minor
                        Found in avaframe/out3Plot/outAIMEC.py - About 1 day 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 SHP2Array has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def SHP2Array(infile, defname=None):
                            """ Read shapefile and convert it to a python dictionary
                        
                            The dictionary contains the name of the paths in the shape file, the np array with
                            the coordinates of the feature points (all stacked in the same array)
                        Severity: Minor
                        Found in avaframe/in2Trans/shpConversion.py - About 1 day 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 com1DFAOrigMain has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def com1DFAOrigMain(cfg, avaDir):
                            """ Run main model
                        
                            This will compute a dense flow avalanche
                        
                        
                        Severity: Minor
                        Found in avaframe/com1DFAOrig/com1DFAOrig.py - About 1 day 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