avaframe/AvaFrame

View on GitHub
avaframe/ana5Utils/DFAPathGeneration.py

Summary

Maintainability
F
3 days
Test Coverage
C
72%

File DFAPathGeneration.py has 534 lines of code (exceeds 300 allowed). Consider refactoring.
Open

"""
    Tools for generating an avalanche path from a DFA simulation
"""

# Load modules
Severity: Major
Found in avaframe/ana5Utils/DFAPathGeneration.py - About 7 hrs to fix

    Function extendProfileBottom has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def extendProfileBottom(cfg, dem, profile):
        """ extend the DFA path at the bottom (runout area)
    
        Find the direction in which to extend considering the last point of the profile
        and a few previous ones but discarding the ones that are too close
    Severity: Minor
    Found in avaframe/ana5Utils/DFAPathGeneration.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 getDFAPathFromPart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def getDFAPathFromPart(particlesList, addVelocityInfo=False):
        """ compute mass averaged path from particles
    
        Also returns the averaged velocity and kinetic energy associated
        If addVelocityInfo is True, information about velocity and kinetic energy is computed
    Severity: Minor
    Found in avaframe/ana5Utils/DFAPathGeneration.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 generateAveragePath has 7 arguments (exceeds 6 allowed). Consider refactoring.
    Open

    def generateAveragePath(avalancheDir, pathFromPart, simName, dem, addVelocityInfo=False, flagAvaDir=True,
    Severity: Major
    Found in avaframe/ana5Utils/DFAPathGeneration.py - About 35 mins to fix

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

      def getDFAPathFromField(fieldsList, fieldHeader, dem):
          """ compute mass averaged path from fields
      
          Also returns the averaged velocity and kinetic energy associated
          The dem and fieldsList (FT, FV and FM) need to have identical dimentions and cell size.
      Severity: Minor
      Found in avaframe/ana5Utils/DFAPathGeneration.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 saveSplitAndPath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def saveSplitAndPath(avalancheDir, simDFrow, splitPoint, avaProfileMass, dem):
          """
          Save avaPath and split point to directory
      
          Parameters
      Severity: Minor
      Found in avaframe/ana5Utils/DFAPathGeneration.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

          zPara = parabolicFit['a']*sNew*sNew+parabolicFit['b']*sNew+parabolicFit['c']
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 1 other location - About 2 hrs to fix
      avaframe/out3Plot/outCom3Plots.py on lines 122..122

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

      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

          for prop in propList:
              avaProfileMass[prop] = np.empty((0, 1))
              avaProfileMass[prop + 'std'] = np.empty((0, 1))
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 1 other location - About 2 hrs to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 124..126

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

      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

          for prop in propList:
              avaProfileMass[prop] = np.empty((0, 1))
              avaProfileMass[prop + 'std'] = np.empty((0, 1))
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 1 other location - About 2 hrs to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 194..196

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

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

                  gamma = factExt * sLast / np.sqrt(vDirX**2 + vDirY**2)
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 2 other locations - About 1 hr to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 386..386
      avaframe/ana5Utils/DFAPathGeneration.py on lines 422..422

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

              gamma = factExt * sLast / np.sqrt(vDirX**2 + vDirY**2)
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 2 other locations - About 1 hr to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 404..404
      avaframe/ana5Utils/DFAPathGeneration.py on lines 422..422

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

                  gamma = factExt * sLast / np.sqrt(vDirX**2 + vDirY**2)
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 2 other locations - About 1 hr to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 386..386
      avaframe/ana5Utils/DFAPathGeneration.py on lines 404..404

      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

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

          avaProfileMass['x'] = avaProfileMass['x'] + dem['originalHeader']['xllcenter']
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 5 other locations - About 45 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 601..601
      avaframe/ana5Utils/DFAPathGeneration.py on lines 602..602
      avaframe/ana5Utils/DFAPathGeneration.py on lines 604..604
      avaframe/com3Hybrid/com3Hybrid.py on lines 107..107
      avaframe/com3Hybrid/com3Hybrid.py on lines 108..108

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

      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

          avaProfileMass['y'] = avaProfileMass['y'] + dem['originalHeader']['yllcenter']
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 5 other locations - About 45 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 601..601
      avaframe/ana5Utils/DFAPathGeneration.py on lines 602..602
      avaframe/ana5Utils/DFAPathGeneration.py on lines 603..603
      avaframe/com3Hybrid/com3Hybrid.py on lines 107..107
      avaframe/com3Hybrid/com3Hybrid.py on lines 108..108

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

      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

              splitPoint['x'] = splitPoint['x'] + dem['originalHeader']['xllcenter']
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 5 other locations - About 45 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 602..602
      avaframe/ana5Utils/DFAPathGeneration.py on lines 603..603
      avaframe/ana5Utils/DFAPathGeneration.py on lines 604..604
      avaframe/com3Hybrid/com3Hybrid.py on lines 107..107
      avaframe/com3Hybrid/com3Hybrid.py on lines 108..108

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

      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

              splitPoint['y'] = splitPoint['y'] + dem['originalHeader']['yllcenter']
      Severity: Major
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 5 other locations - About 45 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 601..601
      avaframe/ana5Utils/DFAPathGeneration.py on lines 603..603
      avaframe/ana5Utils/DFAPathGeneration.py on lines 604..604
      avaframe/com3Hybrid/com3Hybrid.py on lines 107..107
      avaframe/com3Hybrid/com3Hybrid.py on lines 108..108

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

      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 addVelocityInfo:
                  avaProfileMass['totEKin'] = np.append(avaProfileMass['totEKin'], np.nansum(kineticEneArray))
      Severity: Minor
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 1 other location - About 40 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 145..146

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 34.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  if addVelocityInfo:
                      avaProfileMass['totEKin'] = np.append(avaProfileMass['totEKin'], np.nansum(kineticEneArray))
      Severity: Minor
      Found in avaframe/ana5Utils/DFAPathGeneration.py and 1 other location - About 40 mins to fix
      avaframe/ana5Utils/DFAPathGeneration.py on lines 216..217

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 34.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status