avaframe/AvaFrame

View on GitHub
avaframe/ana1Tests/simiSolTest.py

Summary

Maintainability
F
4 days
Test Coverage
B
83%

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

    Function mainSimilaritySol has 44 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

    def mainSimilaritySol(simiSolCfg):
        """Compute similarity solution
        Parameters
        -----------
        simiSolCfg: pathlib path
    Severity: Minor
    Found in avaframe/ana1Tests/simiSolTest.py - About 1 hr to fix

      Function getSimiSolParameters has 35 lines of code (exceeds 30 allowed). Consider refactoring.
      Open

      def getSimiSolParameters(solSimi, header, indTime, cfgSimi, Hini, gravAcc):
          """get flow thickness, flow velocity and center location of flow mass of similarity solution
          for required time step
      
          Parameters
      Severity: Minor
      Found in avaframe/ana1Tests/simiSolTest.py - About 1 hr to fix

        Function getReleaseThickness has 34 lines of code (exceeds 30 allowed). Consider refactoring.
        Invalid

        def getReleaseThickness(avaDir, cfg, demFile):
            """Define release thickness for the similarity solution test
        
            Release area is defined as an elipse or main radius Lx and Ly.
            Release thickness has a parabolic shape from relTh in the
        Severity: Minor
        Found in avaframe/ana1Tests/simiSolTest.py - About 1 hr to fix

          Function analyzeResults has 10 arguments (exceeds 6 allowed). Consider refactoring.
          Open

          def analyzeResults(
          Severity: Major
          Found in avaframe/ana1Tests/simiSolTest.py - About 1 hr to fix

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

            def computeEarthPressCoeff(x, earthPressureCoefficients):
                """Computes the earth pressure coefficients function of sng of f and g
                i.e depending on if we are in the active or passive case
            
                Parameters
            Severity: Minor
            Found in avaframe/ana1Tests/simiSolTest.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 analyzeResults has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def analyzeResults(
                avalancheDir,
                fieldsList,
                timeList,
                solSimi,
            Severity: Minor
            Found in avaframe/ana1Tests/simiSolTest.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 computeH has 8 arguments (exceeds 6 allowed). Consider refactoring.
            Open

            def computeH(solSimi, x1, y1, i, L_x, L_y, H, AminusC):
            Severity: Major
            Found in avaframe/ana1Tests/simiSolTest.py - About 45 mins to fix

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

              def Ffunction(t, x, earthPressureCoefficients, zeta, delta, eps_x, eps_y):
              Severity: Major
              Found in avaframe/ana1Tests/simiSolTest.py - About 35 mins to fix

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

                def calcEarlySol(t, earthPressureCoefficients, x_0, zeta, delta, eps_x, eps_y):
                Severity: Major
                Found in avaframe/ana1Tests/simiSolTest.py - About 35 mins to fix

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

                  def computeU(solSimi, x1, y1, i, L_x, U, AminusC):
                  Severity: Major
                  Found in avaframe/ana1Tests/simiSolTest.py - About 35 mins to fix

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

                    def postProcessSimiSol(avalancheDir, cfgMain, cfgSimi, simDF, solSimi, outDirTest):
                        """loop on all DFA simulations and compare then to the anlytic solution
                    
                        Parameters
                        -----------
                    Severity: Minor
                    Found in avaframe/ana1Tests/simiSolTest.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

                            vhNumerical = {
                                "fx": hNumerical * field["Vx"],
                                "fy": hNumerical * field["Vy"],
                                "fz": hNumerical * field["Vz"],
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 805..808

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

                    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

                            vhSimi = {
                                "fx": hSimi * simiDict["vxSimi"],
                                "fy": hSimi * simiDict["vySimi"],
                                "fz": hSimi * simiDict["vzSimi"],
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 810..813

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

                    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 cfgSimi["SIMISOL"].getboolean("relativError"):
                                hErrorL2Array[count] = hErrorL2Rel
                                hErrorLMaxArray[count] = hErrorLmaxRel
                                vhErrorL2Array[count] = vhErrorL2Rel
                                vhErrorLMaxArray[count] = vhErrorLmaxRel
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/damBreak.py on lines 262..266

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

                    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

                                ind_t = min(
                                    np.searchsorted(timeList, tSave),
                                    min(len(timeList) - 1, len(fieldsList) - 1),
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 5 other locations - About 1 hr to fix
                    avaframe/ana1Tests/damBreak.py on lines 158..158
                    avaframe/ana1Tests/damBreak.py on lines 282..282
                    avaframe/ana1Tests/simiSolTest.py on lines 868..869
                    avaframe/out3Plot/outAna1Plots.py on lines 295..295
                    avaframe/out3Plot/outAna1Plots.py on lines 640..640

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

                    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

                        indT = min(
                            np.searchsorted(timeList, tSave), min(len(timeList) - 1, len(fieldsList) - 1)
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 5 other locations - About 1 hr to fix
                    avaframe/ana1Tests/damBreak.py on lines 158..158
                    avaframe/ana1Tests/damBreak.py on lines 282..282
                    avaframe/ana1Tests/simiSolTest.py on lines 676..678
                    avaframe/out3Plot/outAna1Plots.py on lines 295..295
                    avaframe/out3Plot/outAna1Plots.py on lines 640..640

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

                    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 f_p >= 0:
                                K_y = earthPressureCoefficients[2]
                            else:
                                log.info("ky passive")
                                K_y = earthPressureCoefficients[3]
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 207..211

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

                    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 f_p >= 0:
                                K_y = earthPressureCoefficients[4]
                            else:
                                log.info("ky passive")
                                K_y = earthPressureCoefficients[5]
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 199..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 42.

                    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

                        root2 = np.sqrt((1.0 - kx) * (1.0 - kx) + 4.0 * tan2delta)
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 164..164

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

                    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

                        root2 = np.sqrt((1.0 - kx) * (1.0 - kx) + 4.0 * tan2delta)
                    Severity: Major
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 1 hr to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 169..169

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

                    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

                            + (x1 / L_x - AminusC / 2 * (timeAdim[i]) ** 2) * g_p_sol[i] / g_sol[i]
                    Severity: Minor
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 55 mins to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 445..445

                    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

                        x1 = -((x1 / L_x - AminusC / 2 * (timeAdim[i]) ** 2) ** 2) / (g_sol[i]) ** 2
                    Severity: Minor
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 55 mins to fix
                    avaframe/ana1Tests/simiSolTest.py on lines 481..481

                    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

                            fieldsList, fieldHeader, timeList = com1DFA.readFields(
                                avalancheDir,
                                ["FT", "FV", "Vx", "Vy", "Vz"],
                    Severity: Minor
                    Found in avaframe/ana1Tests/simiSolTest.py and 1 other location - About 30 mins to fix
                    avaframe/ana1Tests/damBreak.py on lines 150..150

                    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