Showing 103 of 184 total issues

File main_view.py has 516 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import webbrowser

import cozy.ext.inject as inject
from cozy.application_settings import ApplicationSettings

Severity: Major
Found in cozy/ui/main_view.py - About 1 day to fix

    File player.py has 471 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import threading
    import time
    
    import cozy.ext.inject as inject
    from gi.repository import Gst, GLib
    Severity: Minor
    Found in cozy/control/player.py - About 7 hrs to fix

      CozyUI has 44 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class CozyUI(metaclass=Singleton):
          """
          CozyUI is the main ui class.
          """
          # The book that is currently loaded in the player
      Severity: Minor
      Found in cozy/ui/main_view.py - About 6 hrs to fix

        File titlebar.py has 416 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import cozy.control.player as player
        import cozy.tools as tools
        import cozy.ui
        from cozy.application_settings import ApplicationSettings
        from cozy.control.artwork_cache import ArtworkCache
        Severity: Minor
        Found in cozy/ui/titlebar.py - About 6 hrs to fix

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

          """
          Python dependency injection framework.
          
          Usage:
          - Create an optional configuration::
          Severity: Minor
          Found in cozy/ext/inject/__init__.py - About 4 hrs to fix

            Titlebar has 34 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Titlebar:
                """
                This class contains all titlebar logic.
                """
                _application_settings: ApplicationSettings = inject.attr(ApplicationSettings)
            Severity: Minor
            Found in cozy/ui/titlebar.py - About 4 hrs to fix

              File mpris.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              # Forked from https://github.com/gnumdk/lollypop/blob/master/lollypop/mpris.py
              # copyright (c) 2014-2017 Cedric Bellegarde <cedric.bellegarde@adishatz.org>
              # copyright (c) 2016 Gaurav Narula
              # copyright (c) 2016 Felipe Borges <felipeborges@gnome.org>
              # copyright (c) 2013 Arnel A. Borja <kyoushuu@yahoo.com>
              Severity: Minor
              Found in cozy/control/mpris.py - About 4 hrs to fix

                Book has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Book(EventSender):
                    _chapters: List[Chapter] = None
                    _settings: Settings = inject.attr(Settings)
                
                    def __init__(self, db: SqliteDatabase, id: int):
                Severity: Minor
                Found in cozy/model/book.py - About 3 hrs to fix

                  File settings.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  from threading import Thread
                  import logging
                  import gi
                  
                  from cozy.control.db import remove_tracks_with_path
                  Severity: Minor
                  Found in cozy/ui/settings.py - About 2 hrs to fix

                    File book_overview.py has 285 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    from gi.repository import Gtk, Gdk, Gst
                    
                    import cozy.tools as tools
                    import cozy.control.player as player
                    import cozy.ui
                    Severity: Minor
                    Found in cozy/ui/book_overview.py - About 2 hrs to fix

                      Function _process_queue has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def _process_queue(self):
                              log.info("Startet processing queue")
                              self.filecopy_cancel = Gio.Cancellable()
                      
                              self._fill_queue_from_db()
                      Severity: Minor
                      Found in cozy/control/offline_cache.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

                      MPRIS has 24 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class MPRIS(Server):
                          """
                          <!DOCTYPE node PUBLIC
                          "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
                      Severity: Minor
                      Found in cozy/control/mpris.py - About 2 hrs to fix

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

                        def init_db():
                            tmp_db = None
                        
                            _connect_db(_db)
                        
                        
                        Severity: Minor
                        Found in cozy/control/db.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 set_book has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def set_book(self, book):
                                """
                                Display the given book in the book overview.
                                """
                                if self.book and self.book.id == book.id:
                        Severity: Minor
                        Found in cozy/ui/book_overview.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 __call__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __call__(self, func: Callable[..., Union[Awaitable[T], T]]) -> Callable[..., Union[Awaitable[T], T]]:
                                if sys.version_info.major == 2:
                                    arg_names = inspect.getargspec(func).args
                                else:
                                    arg_names = inspect.getfullargspec(func).args
                        Severity: Minor
                        Found in cozy/ext/inject/__init__.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

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

                        class Settings(EventSender):
                            """
                            This class contains all logic for cozys preferences.
                            """
                            _glib_settings: Gio.Settings = inject.attr(Gio.Settings)
                        Severity: Minor
                        Found in cozy/ui/settings.py - About 2 hrs to fix

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

                          class ApplicationSettings(EventSender):
                              _settings: Gio.Settings = inject.attr(Gio.Settings)
                          
                              def __init__(self):
                                  super().__init__()
                          Severity: Minor
                          Found in cozy/application_settings.py - About 2 hrs to fix

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

                                def __on_storage_changed(self, event, message):
                                    if (event == "storage-online" and not super().get_sensitive()) or event == "external-storage-removed":
                                        if message in self.book.chapters[0].file:
                                            super().set_sensitive(True)
                                            self.box.set_tooltip_text(self.ONLINE_TOOLTIP_TEXT)
                            Severity: Minor
                            Found in cozy/ui/book_element.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 load_last_book has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def load_last_book(filesystem_monitor: FilesystemMonitor):
                                """
                                Load the last played book into the player.
                                """
                                global __current_track
                            Severity: Minor
                            Found in cozy/control/player.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 _load_pixbuf_from_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _load_pixbuf_from_file(self, book):
                                    """
                                    Try to load the artwork from a book from image files.
                                    :param book: The book to load the artwork from.
                                    :return: Artwork as pixbuf object.
                            Severity: Minor
                            Found in cozy/control/artwork_cache.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

                            Severity
                            Category
                            Status
                            Source
                            Language