JonathonMSmith/growin

View on GitHub
growin/growth_rate.py

Summary

Maintainability
D
1 day
Test Coverage

File growth_rate.py has 483 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Calculation of altitude profiles of flux tube integrated growth rates of the
Rayleigh Taylor instability using SAMI2 output for ion densities, and electron
temperatures

Severity: Minor
Found in growin/growth_rate.py - About 7 hrs to fix

    Function run_growth_calc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def run_growth_calc(sami, coefficients=None, ve01=0):
        '''runs the growth rate calculation for a sami2 run. Requires external
           drift information until exb drifts from sami2 are an archived data prod.
    
        Parameters
    Severity: Minor
    Found in growin/growth_rate.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 run_models has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def run_models(sami, lat, lon, alt, cell, flux_tube, d_str, t_step):
    Severity: Major
    Found in growin/growth_rate.py - About 1 hr to fix

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

      def eval_tubes(sami, exb, t_step=0):
          """calculate the flux tube integrated quantities for each flux tube needed
             for the growth rate calculation
      
          Parameters
      Severity: Minor
      Found in growin/growth_rate.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 sigma_tot has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def sigma_tot(denis, n_n, n_e, B, A, T_e):
      Severity: Minor
      Found in growin/growth_rate.py - About 45 mins to fix

        Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, sami_data, ftl, ft, iyd, d_str, t_step):
        Severity: Minor
        Found in growin/growth_rate.py - About 45 mins to fix

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

                          tube.nu_ef += ftc.nu * ftc.n_e * ftc.len * 10**2
          Severity: Major
          Found in growin/growth_rate.py and 1 other location - About 1 hr to fix
          growin/growth_rate.py on lines 411..411

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

          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

                      tube.R += ftc.r_local * ftc.n_e * ftc.len * 10**2
          Severity: Major
          Found in growin/growth_rate.py and 1 other location - About 1 hr to fix
          growin/growth_rate.py on lines 415..415

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

          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

                  exb += ((a * np.cos((i+1) * t * np.pi / 12))
                        + (b * np.sin((i+1) * t * np.pi / 12)))
          Severity: Major
          Found in growin/growth_rate.py and 1 other location - About 1 hr to fix
          growin/growth_rate.py on lines 486..486

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

          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