Showing 103 of 178 total issues

File player.py has 512 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: Major
Found in cozy/control/player.py - About 1 day to fix

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

    import webbrowser
    
    import cozy.ext.inject as inject
    from cozy.application_settings import ApplicationSettings
    from cozy.architecture.event_sender import EventSender
    Severity: Minor
    Found in cozy/ui/main_view.py - About 7 hrs to fix

      File titlebar.py has 401 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 5 hrs to fix

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

        class CozyUI(EventSender, 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 5 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

            File mpris.py has 352 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

              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

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

                class Book(Observable, 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

                  BookDetailViewModel has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class BookDetailViewModel(Observable, EventSender):
                      _player: Player = inject.attr(Player)
                      _fs_monitor: FilesystemMonitor = inject.attr("FilesystemMonitor")
                      _offline_cache: OfflineCache = inject.attr(OfflineCache)
                      _settings: Settings = inject.attr(Settings)
                  Severity: Minor
                  Found in cozy/view_model/book_detail_view_model.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

                      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 __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

                        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

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

                          class BookDetailView(Gtk.Box):
                              __gtype_name__ = 'BookDetail'
                          
                              back_button: Gtk.Button = Gtk.Template.Child()
                          
                          
                          Severity: Minor
                          Found in cozy/ui/book_detail_view.py - About 2 hrs to fix

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

                            class LibraryViewModel(Observable, EventSender):
                                _application_settings: ApplicationSettings = inject.attr(ApplicationSettings)
                                _fs_monitor: FilesystemMonitor = inject.attr("FilesystemMonitor")
                                _model = inject.attr(Library)
                                _importer: Importer = inject.attr(Importer)
                            Severity: Minor
                            Found in cozy/view_model/library_view_model.py - About 2 hrs to fix

                              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

                                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, offline_cache: OfflineCache):
                                    """
                                    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