avaframe/AvaFrame

View on GitHub
avaframe/com1DFA/particleTools.py

Summary

Maintainability
F
4 days
Test Coverage
F
58%

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

"""
    Tools for handling particles, splitting, merging and tracking.
"""

# Load modules
Severity: Major
Found in avaframe/com1DFA/particleTools.py - About 1 day to fix

    Function placeParticles has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    def placeParticles(hCell, aCell, indx, indy, csz, massPerPart, nPPK, rng, cfg, ratioArea):
        """ Create particles in given cell
    
        Compute number of particles to create in a given cell.
        Place particles in cell according to the chosen pattern (random semirandom
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.py - About 5 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 mergeParticleDict has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def mergeParticleDict(particles1, particles2):
        """Merge two particles dictionary
    
        Parameters
        ----------
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 getTrackedParticlesProperties has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def getTrackedParticlesProperties(particlesList, nPartTracked, properties):
        '''Get the desired properties for the tracked particles
    
        Parameters
        ----------
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 savePartToCsv has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def savePartToCsv(particleProperties, dictList, outDir):
        """ Save each particle dictionary from a list to a csv file;
            works also for one dictionary instead of list
    
            Parameters
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 addParticles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def addParticles(particles, nAdd, ind, mNew, xNew, yNew, zNew):
        """ add particles
    
        Parameters
        ----------
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 removePart has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def removePart(particles, mask, nRemove, reasonString='', snowSlide=0):
        """ remove given particles
    
        Parameters
        ----------
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 mergePartArea has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def mergePartArea(particles, cfg, dem):
        """merge small particles
    
        merge particles to avoid too many particles within the kernel radius.
        place the new merge particle between the two old ones. The new position and velocity are the
    Severity: Minor
    Found in avaframe/com1DFA/particleTools.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 placeParticles has 10 arguments (exceeds 6 allowed). Consider refactoring.
    Open

    def placeParticles(hCell, aCell, indx, indy, csz, massPerPart, nPPK, rng, cfg, ratioArea):
    Severity: Major
    Found in avaframe/com1DFA/particleTools.py - About 1 hr to fix

      Function reshapeParticlesDicts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def reshapeParticlesDicts(particlesList, propertyList):
          """ reshape particlesList from one dict per time step with all particle properties for each particle,
              to one dict with an array of property values for all time steps for each particle
              shape: nx x ny; nx time steps, ny number of particles
      
      
      Severity: Minor
      Found in avaframe/com1DFA/particleTools.py - About 55 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 getSplitPartPosition has 9 arguments (exceeds 6 allowed). Consider refactoring.
      Open

      def getSplitPartPosition(cfg, particles, aPart, Nx, Ny, Nz, csz, nSplit, ind):
      Severity: Major
      Found in avaframe/com1DFA/particleTools.py - About 50 mins to fix

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

        def addParticles(particles, nAdd, ind, mNew, xNew, yNew, zNew):
        Severity: Major
        Found in avaframe/com1DFA/particleTools.py - About 35 mins to fix

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

              yNew = y[ind] + cos * e1y + sin * e2y
          Severity: Major
          Found in avaframe/com1DFA/particleTools.py and 2 other locations - About 45 mins to fix
          avaframe/com1DFA/particleTools.py on lines 606..606
          avaframe/com1DFA/particleTools.py on lines 608..608

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

              zNew = z[ind] + cos * e1z + sin * e2z
          Severity: Major
          Found in avaframe/com1DFA/particleTools.py and 2 other locations - About 45 mins to fix
          avaframe/com1DFA/particleTools.py on lines 606..606
          avaframe/com1DFA/particleTools.py on lines 607..607

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

              xNew = x[ind] + cos * e1x + sin * e2x
          Severity: Major
          Found in avaframe/com1DFA/particleTools.py and 2 other locations - About 45 mins to fix
          avaframe/com1DFA/particleTools.py on lines 607..607
          avaframe/com1DFA/particleTools.py on lines 608..608

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

                  index = [ind for ind, parent in enumerate(particles['parentID']) if parent in particles2Track]
          Severity: Minor
          Found in avaframe/com1DFA/particleTools.py and 1 other location - About 40 mins to fix
          avaframe/in3Utils/fileHandlerUtils.py on lines 226..226

          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

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

                  if jMin * hTri < indy * csz:
                      jMin = jMin + 1
          Severity: Minor
          Found in avaframe/com1DFA/particleTools.py and 1 other location - About 35 mins to fix
          avaframe/com1DFA/particleTools.py on lines 182..183

          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

                  if iTemp * sTri < indx * csz:
                      iTemp = iTemp + 1
          Severity: Minor
          Found in avaframe/com1DFA/particleTools.py and 1 other location - About 35 mins to fix
          avaframe/com1DFA/particleTools.py on lines 152..153

          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

          There are no issues that match your filters.

          Category
          Status