avaframe/AvaFrame

View on GitHub
avaframe/out3Plot/plotUtils.py

Summary

Maintainability
F
5 days
Test Coverage
A
91%

File plotUtils.py has 833 lines of code (exceeds 300 allowed). Consider refactoring.
Open

"""
    Plot settings for output figures

    This file is part of Avaframe.
"""
Severity: Major
Found in avaframe/out3Plot/plotUtils.py - About 1 day to fix

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

    def makeColorMap(colormapDict, levMin, levMax, continuous=False):
        """Get colormap for plot
    
        get the colormap, norm, levels... for ploting results
    
    
    Severity: Minor
    Found in avaframe/out3Plot/plotUtils.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function constrainPlotsToData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def constrainPlotsToData(inputData, cellSize, extentOption=False, constrainedData=False, buffer=""):
        """constrain input raster dataset to where there is data plus buffer zone
    
        Parameters
        -----------
    Severity: Minor
    Found in avaframe/out3Plot/plotUtils.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 putAvaNameOnPlot has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def putAvaNameOnPlot(ax, avaDir, date=True, color="k", fontsize=None):
        """
        Puts the date and avalanche name (or a list of ava names) in the lower left corner of the given
        matplotlib axes, if date=False only avalanche name is put
    
    
    Severity: Minor
    Found in avaframe/out3Plot/plotUtils.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 fetchContourCoords has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def fetchContourCoords(xGrid, yGrid, data, level):
        """fetch contour line coordinates
    
        Parameters
        -----------
    Severity: Minor
    Found in avaframe/out3Plot/plotUtils.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 addColorBar has 9 arguments (exceeds 6 allowed). Consider refactoring.
    Open

    def addColorBar(
    Severity: Major
    Found in avaframe/out3Plot/plotUtils.py - About 50 mins to fix

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

      def NonUnifIm(ax, x, y, z, xlab, ylab, **kwargs):
      Severity: Major
      Found in avaframe/out3Plot/plotUtils.py - About 35 mins to fix

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

        def addHillShadeContours(
        Severity: Major
        Found in avaframe/out3Plot/plotUtils.py - About 35 mins to fix

          Function addColorBar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def addColorBar(
              im,
              ax2,
              ticks,
              myUnit,
          Severity: Minor
          Found in avaframe/out3Plot/plotUtils.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 3 locations. Consider refactoring.
          Open

              extentCellCorners = [
                  colsMinPlot - 0.5 * cellSize,
                  colsMaxPlot + 0.5 * cellSize,
                  rowsMinPlot - 0.5 * cellSize,
                  rowsMaxPlot + 0.5 * cellSize,
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 2 other locations - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 1069..1073
          avaframe/out3Plot/statsPlots.py on lines 382..382

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

          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

              extentCellCorners = [
                  colsMinPlot - 0.5 * cellSize,
                  colsMaxPlot + 0.5 * cellSize,
                  rowsMinPlot - 0.5 * cellSize,
                  rowsMaxPlot + 0.5 * cellSize,
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 2 other locations - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 1014..1018
          avaframe/out3Plot/statsPlots.py on lines 382..382

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

          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 constrainedData:
                      dataConstrained = inputData[rowsMin : rowsMax + 1, colsMin : colsMax + 1]
                      return rowsMinPlot, rowsMaxPlot, colsMinPlot, colsMaxPlot, dataConstrained
                  else:
                      return rowsMinPlot, rowsMaxPlot, colsMinPlot, colsMaxPlot
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 476..491

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

          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 extentOption:
                  rowsMinPlot = rowsMin * cellSize
                  rowsMaxPlot = rowsMax * cellSize
                  colsMinPlot = colsMin * cellSize
                  colsMaxPlot = colsMax * cellSize
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 481..485

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

          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

                          contourDictXY["line%s_%d" % (level, labelID)]["x"].append(
                              contourP.get_paths()[0].vertices[ind, 0]
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 910..911

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

          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

                          contourDictXY["line%s_%d" % (level, labelID)]["y"].append(
                              contourP.get_paths()[0].vertices[ind, 1]
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 2 hrs to fix
          avaframe/out3Plot/plotUtils.py on lines 907..908

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

          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

              extentFlagX = np.isclose(((extentPlot[1] - extentPlot[0]) / cellSize), data.shape[1])
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 1 hr to fix
          avaframe/out3Plot/plotUtils.py on lines 933..933

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

          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

              extentFlagY = np.isclose(((extentPlot[3] - extentPlot[2]) / cellSize), data.shape[0])
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 1 hr to fix
          avaframe/out3Plot/plotUtils.py on lines 932..932

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

          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

                  rowsMax = min(np.amax(ind[0]) + plotBuffer, inputData.shape[0] - 1)
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 1 hr to fix
          avaframe/out3Plot/plotUtils.py on lines 467..467

          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

                  colsMax = min(np.amax(ind[1]) + plotBuffer, inputData.shape[1] - 1)
          Severity: Major
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 1 hr to fix
          avaframe/out3Plot/plotUtils.py on lines 465..465

          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

              dataCut = data[
                  max(0, nrowsMin - rangePlot) : min(data.shape[0], nrowsMin + rangePlot),
          Severity: Minor
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 45 mins to fix
          avaframe/out3Plot/plotUtils.py on lines 674..676

          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

                      cmapSC, _, _, normSC = makeColorMap(cmapVar, np.amin(colorSC), np.amax(colorSC), continuous=True)
          Severity: Minor
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 30 mins to fix
          avaframe/out3Plot/plotUtils.py on lines 769..770

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

                      cmapSC, _, ticksSC, normSC = makeColorMap(
                          cmapVar, np.nanmin(colorSC), np.nanmax(colorSC), continuous=True
          Severity: Minor
          Found in avaframe/out3Plot/plotUtils.py and 1 other location - About 30 mins to fix
          avaframe/out3Plot/plotUtils.py on lines 764..764

          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