Showing 96 of 167 total issues

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

class MediaControllerBig(Gtk.Box):
    __gtype_name__ = "MediaControllerBig"

    seek_bar: SeekBar = Gtk.Template.Child()

Severity: Minor
Found in cozy/ui/media_controller_big.py - About 2 hrs to fix

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

    class LibraryView:
        _view_model: LibraryViewModel = inject.attr(LibraryViewModel)
    
        def __init__(self, builder: Builder):
            self._builder = builder
    Severity: Minor
    Found in cozy/ui/library_view.py - About 2 hrs to fix

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

      class Track(Chapter):
          def __init__(self, db: SqliteDatabase, track: TrackModel):
              super().__init__()
              self._db: SqliteDatabase = db
              self.id: int = track.id
      Severity: Minor
      Found in cozy/model/track.py - About 2 hrs to fix

        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

        Function _prepare_track_db_objects has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def _prepare_track_db_objects(self, media_files: Set[MediaFile]) -> Set[TrackInsertRequest]:
                book_db_objects: Set[BookModel] = set()
        
                for media_file in media_files:
                    if not media_file:
        Severity: Minor
        Found in cozy/model/database_importer.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 Get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def Get(self, interface, property_name):
                if property_name in ["CanQuit", "CanRaise", "CanSeek",
                                     "CanControl", "HasRatingsExtension"]:
                    return GLib.Variant("b", True)
                elif property_name == "HasTrackList":
        Severity: Minor
        Found in cozy/control/mpris.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 display_book_filter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def display_book_filter(self, book_element: BookElement):
                book = book_element.book
                author = book.author
                reader = book.reader
        
        
        Severity: Minor
        Found in cozy/view_model/library_view_model.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 _filter_unchanged_files has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _filter_unchanged_files(self, files: List[str]) -> List[str]:
                """Filter all files that are already imported and that have not changed from a list of paths."""
                imported_files = self._library.files
        
                for file in files:
        Severity: Minor
        Found in cozy/media/importer.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 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def __init__(self, parent, db_id, path, external, default=False):
                super(Gtk.ListBoxRow, self).__init__()
                self.ui = cozy.ui.main_view.CozyUI()
                self.db_id = db_id
                self.path = path
        Severity: Minor
        Found in cozy/ui/widgets/storage_list_box_row.py - About 1 hr to fix

          Function remove has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove(self, book: Book):
                  """
                  Remove all tracks of the given book from the cache.
                  """
                  self._stop_processing()
          Severity: Minor
          Found in cozy/control/offline_cache.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 _update_db_9 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def _update_db_9(db):
              log.info("Migrating to DB Version 9...")
          
              models = generate_models(db)
          
          
          Severity: Minor
          Found in cozy/control/db_updater.py - About 1 hr to fix

            Function __init_actions has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def __init_actions(self):
                    """
                    Init all app actions.
                    """
                    self.accel = Gtk.AccelGroup()
            Severity: Minor
            Found in cozy/ui/main_view.py - About 1 hr to fix

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

                  def __init__(self, gtk_app, main_window_builder, main_window):
                      self.gtk_app = gtk_app
                      self.main_window: CozyUI = main_window
                      self.main_window_builder = main_window_builder
              
              
              Severity: Minor
              Found in cozy/app_controller.py - About 1 hr to fix

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

                    def __init__(self, chapter: Chapter):
                        self.selected = False
                        self.chapter: Chapter = chapter
                
                        super().__init__()
                Severity: Minor
                Found in cozy/ui/chapter_element.py - About 1 hr to fix

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

                      def _on_player_event(self, event, message):
                          if event == "play" or event == "pause":
                              if self.book:
                                  self._notify("playing")
                          elif event == "position":
                  Severity: Minor
                  Found in cozy/view_model/playback_control_view_model.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 _execute_import has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _execute_import(self, files_to_scan: List[str]) -> (Set[str], Set[str]):
                          new_or_changed_files = set()
                          undetected_files = set()
                  
                          self._files_count = self._count_files_to_scan()
                  Severity: Minor
                  Found in cozy/media/importer.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 _on_button_press_event has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _on_button_press_event(self, _, event):
                          if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
                              if self.context_menu is None:
                                  self.context_menu = self._create_context_menu()
                              self.context_menu.popup(
                  Severity: Minor
                  Found in cozy/ui/widgets/book_element.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 configure_inject has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def configure_inject(self, binder):
                          binder.bind_to_provider(SqliteDatabase, get_db)
                          binder.bind("MainWindow", self.main_window)
                          binder.bind("GtkApp", self.gtk_app)
                          binder.bind("MainWindowBuilder", self.main_window_builder)
                  Severity: Minor
                  Found in cozy/app_controller.py - About 1 hr to fix

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

                        def __init__(self, book_name: str, author: str, reader: str, disk: int, cover: bytes, path: str, modified: int,
                    Severity: Major
                    Found in cozy/media/media_file.py - About 1 hr to fix

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

                          def _get_m4b_chapters(self, mutagen_tags: MP4) -> List[Chapter]:
                              chapters = []
                      
                              if not mutagen_tags.chapters or len(mutagen_tags.chapters) == 0:
                                  return self._get_single_chapter()
                      Severity: Minor
                      Found in cozy/media/tag_reader.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

                      Severity
                      Category
                      Status
                      Source
                      Language