hugoruscitti/pilas

View on GitHub
pilasengine/__init__.py

Summary

Maintainability
F
4 days
Test Coverage

File __init__.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- encoding: utf-8 -*-
# pilas engine: un motor para hacer videojuegos
#
# Copyright 2010-2014 - Hugo Ruscitti
# License: LGPLv3 (see http://www.gnu.org/licenses/lgpl.html)
Severity: Major
Found in pilasengine/__init__.py - About 1 day to fix

    Pilas has 55 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Pilas(object):
        """Representa el area de juego de pilas, el componente principal.
    
        El objeto pilas se inicializa cuando llamamos a la funciĆ³n
        ``pilasengine.iniciar()``. El objeto que se retorna es un
    Severity: Major
    Found in pilasengine/__init__.py - About 7 hrs to fix

      Function reiniciar has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def reiniciar(self, ancho=640, alto=480, titulo='pilas-engine',
                        con_aceleracion=None, habilitar_mensajes_log=False,
                        x=None, y=None, capturar_errores=True,
                        pantalla_completa=False):
              """Genera nuevamente la ventana del videojuego."""
      Severity: Minor
      Found in pilasengine/__init__.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 __init__ has 11 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, ancho=640, alto=480, titulo='pilas-engine',
      Severity: Major
      Found in pilasengine/__init__.py - About 1 hr to fix

        Function iniciar has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def iniciar(ancho=640, alto=480, titulo='pilas-engine', capturar_errores=True,
        Severity: Major
        Found in pilasengine/__init__.py - About 1 hr to fix

          Function reiniciar has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def reiniciar(self, ancho=640, alto=480, titulo='pilas-engine',
                            con_aceleracion=None, habilitar_mensajes_log=False,
                            x=None, y=None, capturar_errores=True,
                            pantalla_completa=False):
                  """Genera nuevamente la ventana del videojuego."""
          Severity: Minor
          Found in pilasengine/__init__.py - About 1 hr to fix

            Function reiniciar has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def reiniciar(self, ancho=640, alto=480, titulo='pilas-engine',
            Severity: Major
            Found in pilasengine/__init__.py - About 1 hr to fix

              Function ejecutar has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def ejecutar(self):
                      """Muestra la ventana y mantiene el programa en ejecuciĆ³n."""
                      if not self._iniciado_desde_asistente:
                          if self.widget.pantalla_completa:
                              self.widget.showFullScreen()
              Severity: Minor
              Found in pilasengine/__init__.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __init__(self, ancho=640, alto=480, titulo='pilas-engine',
                               con_aceleracion=None, capturar_errores=True,
                               habilitar_mensajes_log=False, x=None, y=None,
                               modo_test=False,
                               pantalla_completa=False, cargar_plugins=False):
              Severity: Minor
              Found in pilasengine/__init__.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 _modificar_codigo_para_reiniciar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _modificar_codigo_para_reiniciar(self, contenido):
                      import re
                      contenido = re.sub('coding\s*:\s*', '', contenido)
                      contenido = contenido.replace('pilas = pilasengine.iniciar', 'pilas.reiniciar')
                      contenido = contenido.replace('pilas.ejecutar', '#pilas.ejecutar')
              Severity: Minor
              Found in pilasengine/__init__.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

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

                  def ejecutar_archivo(nombre):
                      try:
                          imp.load_source("__main__", nombre)
                      except Exception, e:
                          terminar_con_error("Error al ejecutar " + nombre + ":\n" + str(e))
              Severity: Major
              Found in pilasengine/__init__.py and 1 other location - About 2 hrs to fix
              extras/cargador_para_windows/pilas-engine.py on lines 26..30

              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

                  def terminar_con_error(mensaje):
                      _ = QtGui.QApplication(sys.argv)
                      error = QtGui.QMessageBox()
                      error.critical(None, "Uh, algo anda mal...", mensaje)
                      sys.exit(1)
              Severity: Major
              Found in pilasengine/__init__.py and 1 other location - About 1 hr to fix
              extras/cargador_para_windows/pilas-engine.py on lines 32..36

              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

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

                      try:
                          codigo = inspect.getsource(objeto.__class__)
                      except TypeError:
                          try:
                              codigo = inspect.getsource(objeto)
              Severity: Major
              Found in pilasengine/__init__.py and 1 other location - About 1 hr to fix
              pilas/utils.py on lines 360..366

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

              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 "__file__" in x:
                              contenido = contenido.replace(x, "# livecoding: " + x + "\n")
              Severity: Minor
              Found in pilasengine/__init__.py and 1 other location - About 40 mins to fix
              pilasengine/interprete/editor.py on lines 613..615

              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

                  def deshabilitar_sonido(self, estado=True):
                      if estado:
                          self.sonidos.deshabilitar()
                      else:
                          self.sonidos.habilitar()
              Severity: Minor
              Found in pilasengine/__init__.py and 1 other location - About 30 mins to fix
              pilasengine/__init__.py on lines 561..565

              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

                      self.log("Reiniciando pilas con los parametros", str({"ancho": ancho,
                                                                  "alto": alto,
                                                                  "titulo": titulo,
                                                                  "con_aceleracion": con_aceleracion,
                                                                  "capturar_errores": capturar_errores,
              Severity: Minor
              Found in pilasengine/__init__.py and 1 other location - About 30 mins to fix
              pilasengine/__init__.py on lines 87..94

              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

                      self.log("Iniciando pilas con los parametros", str({"ancho": ancho,
                                                                          "alto": alto,
                                                                          "titulo": titulo,
                                                                          "con_aceleracion": con_aceleracion,
                                                                          "capturar_errores": capturar_errores,
              Severity: Minor
              Found in pilasengine/__init__.py and 1 other location - About 30 mins to fix
              pilasengine/__init__.py on lines 176..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 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

                  def deshabilitar_musica(self, estado=True):
                      if estado:
                          self.musica.deshabilitar()
                      else:
                          self.musica.habilitar()
              Severity: Minor
              Found in pilasengine/__init__.py and 1 other location - About 30 mins to fix
              pilasengine/__init__.py on lines 567..571

              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