lewisamarshall/emigrate

View on GitHub

Showing 36 of 36 total issues

File __main__.py has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Command line interface for emigrate."""
from .__version__ import __version__
from .Solver import Solver
from .Frame import Frame
from .Sequence import Sequence
Severity: Minor
Found in emigrate/__main__.py - About 3 hrs to fix

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

    @cli.command()
    @click.pass_context
    @click.option('--green', '-g', type=str, default=None)
    @click.option('--red', '-r', type=str, default=None)
    @click.option('--blue', '-b', type=str, default=None)
    Severity: Major
    Found in emigrate/__main__.py and 1 other location - About 2 hrs to fix
    emigrate/__main__.py on lines 197..201

    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

    @cli.command()
    @click.pass_context
    @click.option('--red', '-r', type=str, default=None)
    @click.option('--green', '-g', type=str, default=None)
    @click.option('--blue', '-b', type=str, default=None)
    Severity: Major
    Found in emigrate/__main__.py and 1 other location - About 2 hrs to fix
    emigrate/__main__.py on lines 149..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 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

    Function solve has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def solve(ctx, output, dt, time, io):
        solver = Solver(ctx.obj['frame'])
    
        if io:
            for frame in solver.iterate(output, dt, time):
    Severity: Minor
    Found in emigrate/__main__.py - About 2 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

    SLIP has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SLIP(Fluxer):
    
        """A compact flux solver with numerical dissipation and adaptive grid."""
    
        # #TODO:60 hide internal functions
    Severity: Minor
    Found in emigrate/flux_schemes/SLIP.py - About 2 hrs to fix

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

          def _calc_diffusivity(self):
              """Calculate the diffusivity."""
              self.state.diffusivity = np.array([[ion.diffusivity(self.state.pH)]
                                                for ion in self.state.ions])
      Severity: Major
      Found in emigrate/equilibration_schemes/Fixed.py and 2 other locations - About 1 hr to fix
      emigrate/equilibration_schemes/Fixed.py on lines 34..37
      emigrate/equilibration_schemes/Fixed.py on lines 39..43

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

      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

          def _calc_mobility(self):
              """Calculate the mobility."""
              self.state.mobility = np.array([[ion.mobility(self.state.pH)]
                                             for ion in self.state.ions])
      Severity: Major
      Found in emigrate/equilibration_schemes/Fixed.py and 2 other locations - About 1 hr to fix
      emigrate/equilibration_schemes/Fixed.py on lines 29..32
      emigrate/equilibration_schemes/Fixed.py on lines 39..43

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

      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

          def _calc_molar_conductivity(self):
              """Calculate the conductivity."""
              self.state.molar_conductivity = \
                  np.array([[ion.molar_conductivity(self.state.pH)]
                           for ion in self.state.ions])
      Severity: Major
      Found in emigrate/equilibration_schemes/Fixed.py and 2 other locations - About 1 hr to fix
      emigrate/equilibration_schemes/Fixed.py on lines 29..32
      emigrate/equilibration_schemes/Fixed.py on lines 34..37

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

      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

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

      def construct(ctx, infile, output, io):
          if io:
              for constructor in iter(sys.stdin.readline, ''):
                  constructor = deserialize(constructor)
                  save = False
      Severity: Minor
      Found in emigrate/__main__.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 load has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def load(ctx, path, io):
          """Open an emgrate file and return a serialized frame."""
          ctx.obj['path'] = path
          _, file_extension = os.path.splitext(path)
          if file_extension == '.hdf5':
      Severity: Minor
      Found in emigrate/__main__.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 __setitem__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def __setitem__(self, idx, frame):
              if not isinstance(idx, int):
                  raise IndexError('Sequence index must be an integer.')
      
              if str(idx-1) not in self._frames().keys() and self._frames().keys():
      Severity: Minor
      Found in emigrate/Sequence.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

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

              try:
                  self._fluxer = fluxers[self.flux_mode]
              except:
                  error_string = '{} is not an fluxer.'
                  raise RuntimeError(error_string.format(self.flux_mode))
      Severity: Major
      Found in emigrate/Solver.py and 1 other location - About 1 hr to fix
      emigrate/Solver.py on lines 68..72

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

      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

              try:
                  self._equilibrator = equilibrators[self.equilibrium_mode]
              except:
                  error_string = '{} is not an equilibrator.'
                  raise RuntimeError(error_string.format(self.equilibrium_mode))
      Severity: Major
      Found in emigrate/Solver.py and 1 other location - About 1 hr to fix
      emigrate/Solver.py on lines 81..85

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

      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 output:
                  with open(output, 'w') as loc:
                      loc.write(ctx.obj['frame'].serialize())
      Severity: Minor
      Found in emigrate/__main__.py and 1 other location - About 50 mins to fix
      emigrate/__main__.py on lines 293..295

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

      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 save:
                      with open(save, 'w') as loc:
                          loc.write(ctx.obj['frame'].serialize())
      Severity: Minor
      Found in emigrate/__main__.py and 1 other location - About 50 mins to fix
      emigrate/__main__.py on lines 301..303

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

      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

      Avoid deeply nested control flow statements.
      Open

                          if i == 10:
                              i = 0
                              bar.update(-10)
                          bar.update(1)
      Severity: Major
      Found in emigrate/__main__.py - About 45 mins to fix

        Function solve has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def solve(ctx, output, dt, time, io):
        Severity: Minor
        Found in emigrate/__main__.py - About 35 mins to fix

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

                  if self.method == '6th-Order':
                      internal_function = [1./3., 1., 1./3.]
                      boundary_functions = [[1., 4.], [1./6., 1., 1./2.]]
                      self.A1 = self.construct_matrix(boundary_functions,
                                                      internal_function)
          Severity: Minor
          Found in emigrate/flux_schemes/Differentiate.py and 1 other location - About 35 mins to fix
          emigrate/flux_schemes/Differentiate.py on lines 81..87

          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

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

          def movie(ctx, field, ymax):
              metadata = dict(title='Movie Test', artist='Matplotlib',
                          comment='Movie support!')
              writer = FFMpegWriter(fps=15, metadata=metadata)
          
          
          Severity: Minor
          Found in emigrate/__main__.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 3 locations. Consider refactoring.
          Open

              savename = os.path.splitext(ctx.obj['path'])[0]+'_band.mp4'
          Severity: Minor
          Found in emigrate/__main__.py and 2 other locations - About 35 mins to fix
          emigrate/__main__.py on lines 126..126
          emigrate/__main__.py on lines 142..142

          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

          Severity
          Category
          Status
          Source
          Language