avaframe/AvaFrame

View on GitHub
avaframe/com1DFA/deriveParameterSet.py

Summary

Maintainability
F
3 days
Test Coverage
C
79%

File deriveParameterSet.py has 640 lines of code (exceeds 300 allowed). Consider refactoring.
Invalid

"""
    Create dictionary for parameter variations
"""

import logging
Severity: Major
Found in avaframe/com1DFA/deriveParameterSet.py - About 1 day to fix

    Function splitVariationToArraySteps has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    def splitVariationToArraySteps(value, key, fullCfg):
        """ split variation in percent to create a list of factors to set parameter value for variations
            or if a rangeVariation is given in absolute values
            or if distVariation create an info string on how the distribution can be build
            (e.g. of format typeOfDistribution$numberOfSteps$ci95value$ci95$support and append the step
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

    Function getVariationDict has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def getVariationDict(avaDir, fullCfg, modDict):
        """ Create a dictionary with all the parameters that shall be varied from the standard configuration;
            ONLY accounts for variations in section GENERAL and INPUT/releaseScenario
    
            Parameters
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

    Function checkThicknessSettings has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    def checkThicknessSettings(cfg, thName):
        """ check if thickness setting format is correct
    
            Parameters
            ------------
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

    Function setThicknessValueFromVariation has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def setThicknessValueFromVariation(key, cfg, simType, row):
        """ set thickness value for thickness parameter for all features if multiple according to
            desired variation
    
            Parameters
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

    Function getThicknessValue has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    def getThicknessValue(cfg, inputSimFiles, fName, thType):
        """ set thickness values according to settings chosen and add info to cfg
            if thFromShp = True - add in INPUT section thickness and id info and ci95
            if thFromShp = False - check format of thickness value in GENERAL section
    
    
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

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

    def appendShpThickness(cfg):
        """ append thickness values to GENERAL section if read from shp and not varied
    
            Parameters
            -----------
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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 validateVarDict has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def validateVarDict(variationDict, standardCfg):
        """ Check if all parameters in variationDict exist in default configuration and
            are provided in the correct format
    
            Parameters
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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 setVariationForAllFeatures has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def setVariationForAllFeatures(cfg, key, thType, varType, variationFactor):
        """ set thickness value for all features according to varType variation
    
            Parameters
            ----------
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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 checkResType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def checkResType(fullCfg, section, key, value):
        """ Check if the resTypes asked for exist
        Warns the user if some do not, removes them from the resType list and
        updates the cfg
    
    
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.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

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

                    if value not in variations:
                        log.info('%s: %s (default value was: %s)' % (value, modDict[sec][value][0], modDict[sec][value][1]))
    Severity: Major
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 2 hrs to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 85..86

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

    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 sec != section:
                    log.info('%s: %s (default value was: %s)' % (value, modDict[sec][value][0], modDict[sec][value][1]))
    Severity: Major
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 2 hrs to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 88..89

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

    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

                cfg['GENERAL'][thNameId] = str(float(thicknessList[count]) + variationFactor)
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 55 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 570..570

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

                cfg['GENERAL'][thNameId] = str(float(thicknessList[count]) + fromCiVal)
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 55 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 576..576

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

                cfg['GENERAL'][thNameId] = distValues[int(distInfo[0])]
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 35 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 508..508

    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

                    cfg['GENERAL'][thType] = distValues[int(distInfo[0])]
    Severity: Minor
    Found in avaframe/com1DFA/deriveParameterSet.py and 1 other location - About 35 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 582..582

    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 4 locations. Consider refactoring.
    Invalid

        if sum(flagsList) > 1:
            message = 'Only one variation type is allowed - check %s and %s, %s' % (thRV, thPV, thRCiV)
            log.error(message)
            raise AssertionError(message)
    Severity: Major
    Found in avaframe/com1DFA/deriveParameterSet.py and 3 other locations - About 30 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 326..330
    avaframe/com1DFA/deriveParameterSet.py on lines 342..345
    avaframe/in1Data/computeFromDistribution.py on lines 21..24

    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 4 locations. Consider refactoring.
    Invalid

            if cfg['GENERAL'].getboolean(thFile) and (cfg['GENERAL'].getboolean(thFlag) != False or cfg['GENERAL'][thName] != ''):
                message = ('If %s is set to True - it is not allowed to set %s to True or provide a value in %s' %
                           (thFile, thFlag, thName))
                log.error(message)
                raise AssertionError(message)
    Severity: Major
    Found in avaframe/com1DFA/deriveParameterSet.py and 3 other locations - About 30 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 337..340
    avaframe/com1DFA/deriveParameterSet.py on lines 342..345
    avaframe/in1Data/computeFromDistribution.py on lines 21..24

    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 4 locations. Consider refactoring.
    Invalid

        if cfg['GENERAL'].getboolean(thFile) and (sum(flagsList) > 0):
            message = 'RelThFromFile is True - no variation allowed: check %s, %s or %s' % (thRV, thPV, thRCiV)
            log.error(message)
            raise AssertionError(message)
    Severity: Major
    Found in avaframe/com1DFA/deriveParameterSet.py and 3 other locations - About 30 mins to fix
    avaframe/com1DFA/deriveParameterSet.py on lines 326..330
    avaframe/com1DFA/deriveParameterSet.py on lines 337..340
    avaframe/in1Data/computeFromDistribution.py on lines 21..24

    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

    There are no issues that match your filters.

    Category
    Status