Showing 96 of 167 total issues

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

    def __on_storage_box_changed(self, widget, row):
        """
        Disable/enable toolbar buttons
        """
        row = self.storage_list_box.get_selected_row()
Severity: Minor
Found in cozy/ui/settings.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 get_album_art_path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_album_art_path(self, book, size):
        query = ArtworkCacheModel.select().where(ArtworkCacheModel.book == book.id)
        if query.exists():
            try:
                uuid = query.first().uuid
Severity: Minor
Found in cozy/control/artwork_cache.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 clean_books has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def clean_books():
    """
    Remove all books that have no tracks
    """
    for book in Book.select():
Severity: Minor
Found in cozy/control/db.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 on_method_call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def on_method_call(self,
                       connection,
                       sender,
                       object_path,
                       interface_name,
Severity: Minor
Found in cozy/control/mpris.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 _update_view_model_view has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _update_view_model_view(self, _, __):
        page = self._main_stack.props.visible_child_name
        library_folded = self._library_leaflet.props.folded
        library_page = self._library_leaflet.props.visible_child_name

Severity: Minor
Found in cozy/ui/app_view.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 on_method_call has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def on_method_call(self,
Severity: Major
Found in cozy/control/mpris.py - About 50 mins to fix

    Function __on_drag_data_received has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __on_drag_data_received(self, widget, context, x, y, selection, target_type, timestamp):
    Severity: Major
    Found in cozy/ui/main_view.py - About 50 mins to fix

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

          def is_external(self, directory: str) -> bool:
              mounts: List[Gio.Mount] = self.volume_monitor.get_mounts()
      
              for mount in mounts:
                  root = mount.get_root()
      Severity: Minor
      Found in cozy/control/filesystem_monitor.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 _handle_system_power_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_system_power_event(self):
              platform = tools.system_platform()
              command = ""
      
              if self.system_power_control == SystemPowerControl.SHUTDOWN:
      Severity: Minor
      Found in cozy/view_model/sleep_timer_view_model.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 _on_chapter_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _on_chapter_event(self, event: str, chapter: Chapter):
              if event == "chapter-deleted":
                  try:
                      self.chapters.remove(chapter)
                  except ValueError:
      Severity: Minor
      Found in cozy/model/book.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 _load_chapter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _load_chapter(self, chapter: Chapter):
              file_changed = False
      
              if not self._book:
                  log.error("There is no book loaded but there should be.")
      Severity: Minor
      Found in cozy/media/player.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 _on_gst_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _on_gst_message(self, _, message: Gst.Message):
              t = message.type
              if t == Gst.MessageType.BUFFERING:
                  if message.percentage < 100:
                      self._player.set_state(Gst.State.PAUSED)
      Severity: Minor
      Found in cozy/media/gst_player.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, parent, db_id, path, external, default=False):
      Severity: Minor
      Found in cozy/ui/widgets/storage_list_box_row.py - About 35 mins to fix

        Function _copy_file has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _copy_file(self, source_path: str, dest_path: str):
                log.info("Copy file {} to {}".format(source_path, dest_path))
        
                source = Gio.File.new_for_path(source_path)
                destination = Gio.File.new_for_path(dest_path)
        Severity: Minor
        Found in cozy/media/files.py - About 35 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 _on_gst_player_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _on_gst_player_event(self, event: str, message):
                if event == "file-finished":
                    self._next_chapter()
                elif event == "resource-not-found":
                    self._handle_file_not_found()
        Severity: Minor
        Found in cozy/media/player.py - About 35 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 _on_player_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def _on_player_event(self, event, message):
                if event == "play":
                    book = message
        
                    if book:
        Severity: Minor
        Found in cozy/view_model/library_view_model.py - About 35 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 __on_storage_changed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def __on_storage_changed(self, event, message):
                if event == "storage-offline":
                    self.append_text(gettext('{storage} is offline.').format(storage=message))
                if event == "storage-online":
                    for label in self.warning_container.get_children():
        Severity: Minor
        Found in cozy/ui/warnings.py - About 35 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 report has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def report(component: str, type: LogLevel, message: str, exception: Exception):
            if ENABLE != 'true':
                return
        
            app_settings = inject.instance(ApplicationSettings)
        Severity: Minor
        Found in cozy/report/report_to_loki.py - About 35 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 GetAll has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def GetAll(self, interface):
                ret = {}
                if interface == self.__MPRIS_IFACE:
                    for property_name in ["CanQuit",
                                          "CanRaise",
        Severity: Minor
        Found in cozy/control/mpris.py - About 35 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 remove_all_for_storage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def remove_all_for_storage(self, storage_path):
                """
                """
                for element in OfflineCacheModel.select().join(File).where(
                        storage_path in OfflineCacheModel.original_file.path):
        Severity: Minor
        Found in cozy/control/offline_cache.py - About 35 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