hugoruscitti/pilas

View on GitHub
pilasengine/interprete/editor.py

Summary

Maintainability
F
3 days
Test Coverage

File editor.py has 469 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: Minor
Found in pilasengine/interprete/editor.py - About 7 hrs to fix

    Editor has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Editor(editor_base.EditorBase):
        """Representa el editor de texto que aparece en el panel derecho.
    
        El editor soporta autocompletado de código y resaltado de sintáxis.
        """
    Severity: Minor
    Found in pilasengine/interprete/editor.py - About 3 hrs to fix

      Function keyPressEvent has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def keyPressEvent(self, event):
              "Atiene el evento de pulsación de tecla."
              self._cambios_sin_guardar = True
      
              # Permite usar tab como seleccionador de la palabra actual
      Severity: Minor
      Found in pilasengine/interprete/editor.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

      Function __init__ has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, main=None, interpreter_locals=None, consola_lanas=None, ventana_interprete=None, *args):
              QWidget.__init__(self, *args)
              self.setupUi(self)
              self.setLayout(self.vertical_layout)
              self.ruta_del_archivo_actual = None
      Severity: Minor
      Found in pilasengine/interprete/editor.py - About 1 hr to fix

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

            def abrir_archivo_del_proyecto(self, nombre_de_archivo):
                if self.tiene_cambios_sin_guardar():
                    if self.mensaje_guardar_cambios_abrir():
                        if not self.guardar_contenido_con_dialogo():
                            return
        Severity: Minor
        Found in pilasengine/interprete/editor.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, main=None, interpreter_locals=None, consola_lanas=None, ventana_interprete=None, *args):
        Severity: Minor
        Found in pilasengine/interprete/editor.py - About 45 mins to fix

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

              def abrir_archivo_con_dialogo(self):
                  if self.tiene_cambios_sin_guardar():
                      if self.mensaje_guardar_cambios_abrir():
                          if not self.guardar_contenido_con_dialogo():
                              return
          Severity: Minor
          Found in pilasengine/interprete/editor.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 ejecutar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def ejecutar(self):
                  ruta_personalizada = os.path.dirname(self.ruta_del_archivo_actual)
                  #print "ejecutando texto desde widget editor"
                  texto = self.obtener_contenido()
                  texto = "from __future__ import print_function\n" + texto
          Severity: Minor
          Found in pilasengine/interprete/editor.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

          Avoid too many return statements within this function.
          Open

                      return self.insertPlainText(whitespace)
          Severity: Major
          Found in pilasengine/interprete/editor.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return QTextEdit.keyPressEvent(self, event)
            Severity: Major
            Found in pilasengine/interprete/editor.py - About 30 mins to fix

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

                  def actualizar_el_listado_de_archivos(self):
                      self.selector_archivos.clear()
              
                      if self.editor.es_archivo_iniciar_sin_guardar():
                          self.selector_archivos.addItem(u"archivo sin título ...")
              Severity: Minor
              Found in pilasengine/interprete/editor.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

                      if event.key() in [Qt.Key_Tab]:
                          if self.completer and self.completer.popup().isVisible():
                              event.ignore()
                              nuevo_evento = QKeyEvent(QKeyEvent.KeyPress, Qt.Key_Return, Qt.NoModifier)
                              try:
              Severity: Major
              Found in pilasengine/interprete/editor.py and 1 other location - About 5 hrs to fix
              pilasengine/interprete/lanas.py on lines 308..317

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

              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

                      for x in contenido.split('\n'):
                          if "__file__" in x:
                              contenido = contenido.replace(x, "# livecoding: " + x + "\n")
              Severity: Minor
              Found in pilasengine/interprete/editor.py and 1 other location - About 40 mins to fix
              pilasengine/__init__.py on lines 314..315

              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 _get_position_in_block(self):
                      tc = self.textCursor()
                      position = tc.positionInBlock() - 1
                      return position
              Severity: Minor
              Found in pilasengine/interprete/editor.py and 1 other location - About 35 mins to fix
              pilasengine/interprete/lanas.py on lines 261..264

              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