krassowski/Anki-Night-Mode

View on GitHub

Showing 14 of 14 total issues

File stylers.py has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from PyQt5.QtCore import Qt
from PyQt5 import QtWidgets

import aqt
from anki.stats import CollectionStats
Severity: Major
Found in night_mode/stylers.py - About 1 day to fix

    File styles.py has 370 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from .config import ConfigValueGetter
    from .internals import css, snake_case, SingletonMetaclass, RequiringMixin
    
    
    class Style(RequiringMixin, metaclass=SingletonMetaclass):
    Severity: Minor
    Found in night_mode/styles.py - About 4 hrs to fix

      Function __init__ has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(cls, name, bases, attributes):
              super().__init__(name, bases, attributes)
      
              # singleton
              cls.instance = None
      Severity: Minor
      Found in night_mode/internals.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

      File actions_and_settings.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from datetime import datetime
      
      from PyQt5.QtCore import QTimer
      from PyQt5.QtGui import QColor
      from PyQt5.QtWidgets import QColorDialog
      Severity: Minor
      Found in night_mode/actions_and_settings.py - About 2 hrs to fix

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

        class InvertLatex(Setting, MenuAction):
            """Toggles latex inversion.
        
            Latex formulas are nothing more than images with class "latex".
            To learn how formulas are inverted check also append_to_styles().
        Severity: Major
        Found in night_mode/actions_and_settings.py and 1 other location - About 2 hrs to fix
        night_mode/actions_and_settings.py on lines 34..49

        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

        class InvertImage(Setting, MenuAction):
            """Toggles image inversion.
        
            To learn how images are inverted check also append_to_styles().
            """
        Severity: Major
        Found in night_mode/actions_and_settings.py and 1 other location - About 2 hrs to fix
        night_mode/actions_and_settings.py on lines 52..64

        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

        Function init_ui has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def init_ui(self, title):
                self.setWindowTitle(title)
        
                btn_close = create_button('Close', self.close)
        
        
        Severity: Minor
        Found in night_mode/mode.py - About 1 hr to fix

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

              def refresh(self, reload=False):
                  """
                  Refresh display by re-enabling night or normal mode,
                  regenerate customizable css strings.
                  """
          Severity: Minor
          Found in night_mode/night_mode.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 _addButton has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def _addButton(self, editor, icon, command, *args, **kwargs):
          Severity: Minor
          Found in night_mode/stylers.py - About 35 mins to fix

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

                def __init__(self, parent, disabled_stylers: set, all_stylers, title=_('Choose what to style'), on_update=None):
            Severity: Minor
            Found in night_mode/selector.py - About 35 mins to fix

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

                  def __init__(self, parent, color=None, on_color_change=None, name='Color', verify_colors=False):
              Severity: Minor
              Found in night_mode/color_map.py - About 35 mins to fix

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

                    def create_action(self, name, text, callback, checkable=False, shortcut=None):
                Severity: Minor
                Found in night_mode/menu.py - About 35 mins to fix

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

                      def init(self, editor, mw, widget, parentWindow, addMode=False):
                  Severity: Minor
                  Found in night_mode/stylers.py - About 35 mins to fix

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

                    def move_args_to_kwargs(original_function, args, kwargs):
                        args = list(args)
                    
                        import inspect
                    
                    
                    Severity: Minor
                    Found in night_mode/internals.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

                    Severity
                    Category
                    Status
                    Source
                    Language