avaframe/AvaFrame

View on GitHub
avaframe/ana4Stats/probAna.py

Summary

Maintainability
F
4 days
Test Coverage
A
91%

File probAna.py has 673 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

    Function updateCfgRange has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def updateCfgRange(cfg, cfgProb, varName, varDict):
        """ update cfg with a range for parameters in cfgProb
    
            Parameters
            -----------
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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

    Function probAnalysis has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def probAnalysis(avaDir, cfg, module, parametersDict='', inputDir='', probConf='', simDFActual=''):
        """ Compute probability map of a given set of simulation result exceeding a particular threshold and save to outDir
    
            Parameters
            ----------
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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 createSampleWithVariationForThParameters has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def createSampleWithVariationForThParameters(avaDir, cfgProb, cfgStart, varParList, valVariationValue, varType, thReadFromShp):
        """ Create a sample of parameters for a desired parameter variation,
            and fetch thickness values from shp file and perform variation for each feature within
            shapefile but treating the features of one shapefile as not-independent
    
    
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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 createCfgFiles has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def createCfgFiles(paramValuesDList, comMod, cfg, cfgPath=''):
        """ create all config files required to run com Module from parameter variations using paramValues
    
            Parameters
            -----------
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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 cfgFilesGlobalApproach has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def cfgFilesGlobalApproach(avaDir, cfgProb, modName, outDir):
        """ create configuration files with all parameter variations - drawn from full sample
            for performing sims with modName comModule
    
            Parameters
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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

    Function makeDictFromVars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def makeDictFromVars(cfg):
        """ create a dictionary with info on parameter variation for all parameter in
            varParList
    
            Parameters
    Severity: Minor
    Found in avaframe/ana4Stats/probAna.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

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

    def probAnalysis(avaDir, cfg, module, parametersDict='', inputDir='', probConf='', simDFActual=''):
    Severity: Major
    Found in avaframe/ana4Stats/probAna.py - About 35 mins to fix

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

      def createSampleWithVariationForThParameters(avaDir, cfgProb, cfgStart, varParList, valVariationValue, varType, thReadFromShp):
      Severity: Major
      Found in avaframe/ana4Stats/probAna.py - About 35 mins to fix

        Function checkParameterSettings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def checkParameterSettings(cfg, varParList):
            """ check if parameter settings in comMod configuration do not inlcude variation for parameters to be varied
        
                Parameters
                -----------
        Severity: Minor
        Found in avaframe/ana4Stats/probAna.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 fetchThThicknessLists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def fetchThThicknessLists(varPar, inputSimFiles, releaseFile, ciRequired=False):
            """ fetch the desired thickness shp file info on thickness, id and ci values
                of all available features in shp file
        
                Parameters
        Severity: Minor
        Found in avaframe/ana4Stats/probAna.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

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

                lowerBounds[fullVarType == 'range'] = (varValList[fullVarType == 'range'] -
                        fullValVar[fullVarType == 'range'])
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 1 hr to fix
        avaframe/ana4Stats/probAna.py on lines 716..717

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

        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

                lowerBounds[fullVarType == 'rangefromci'] = (varValList[fullVarType == 'rangefromci'] -
                        ciValues[fullVarType == 'rangefromci'])
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 1 hr to fix
        avaframe/ana4Stats/probAna.py on lines 711..712

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

        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

                upperBounds[fullVarType == 'rangefromci'] = (varValList[fullVarType == 'rangefromci'] +
                        ciValues[fullVarType == 'rangefromci'])
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 1 hr to fix
        avaframe/ana4Stats/probAna.py on lines 713..714

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

        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

                upperBounds[fullVarType == 'range'] = (varValList[fullVarType == 'range'] +
                        fullValVar[fullVarType == 'range'])
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 1 hr to fix
        avaframe/ana4Stats/probAna.py on lines 718..719

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

        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

                if any(chars in cfg['GENERAL'][varPar] for chars in ['|', '$', ':']):
                    message = ('Only one reference value is allowed for %s: but %s is given' %
                        (varPar, cfg['GENERAL'][varPar]))
                    log.error(message)
                    raise AssertionError(message)
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 1 hr to fix
        avaframe/com1DFA/checkCfg.py on lines 131..134

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

        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

                upperBounds[fullVarType == 'percent'] = (varValList[fullVarType == 'percent'] +
                    varValList[fullVarType == 'percent'] * (fullValVar[fullVarType == 'percent'] / 100.))
        Severity: Minor
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 55 mins to fix
        avaframe/ana4Stats/probAna.py on lines 706..707

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

        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

                lowerBounds[fullVarType == 'percent'] = (varValList[fullVarType == 'percent'] -
                    varValList[fullVarType == 'percent'] * (fullValVar[fullVarType == 'percent'] / 100.))
        Severity: Minor
        Found in avaframe/ana4Stats/probAna.py and 1 other location - About 55 mins to fix
        avaframe/ana4Stats/probAna.py on lines 708..709

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

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

                cfgDist = cfgUtils.getModuleConfig(cP, fileOverride='', modInfo=False, toPrint=False,
                                                   onlyDefault=cfgProb['in1Data_computeFromDistribution_override'].getboolean('defaultConfig'))
        Severity: Major
        Found in avaframe/ana4Stats/probAna.py and 5 other locations - About 50 mins to fix
        avaframe/com3Hybrid/com3Hybrid.py on lines 57..58
        avaframe/com3Hybrid/com3Hybrid.py on lines 64..65
        avaframe/com3Hybrid/com3Hybrid.py on lines 70..71
        avaframe/com5SnowSlide/com5SnowSlide.py on lines 36..41
        avaframe/com6RockAvalanche/com6RockAvalanche.py on lines 34..39

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

        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

        There are no issues that match your filters.

        Category
        Status