ssokolow/quicktile

View on GitHub
quicktile/wm.py

Summary

Maintainability
C
1 day
Test Coverage

File wm.py has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Wrapper around libwnck for interacting with the window manager"""

__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__license__ = "GNU GPL 2.0 or later"

Severity: Minor
Found in quicktile/wm.py - About 4 hrs to fix

    Cyclomatic complexity is too high in method reposition. (8)
    Open

        def reposition(self,  # pylint: disable=too-many-arguments
                win: Wnck.Window,
                geom: Optional[Rectangle] = None,
                monitor: Rectangle = Rectangle(0, 0, 0, 0),
                keep_maximize: bool = False,
    Severity: Minor
    Found in quicktile/wm.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in method get_workspace. (6)
    Open

        def get_workspace(self,
                    window: Wnck.Window = None,
                    direction: Union[Wnck.MotionDirection, int] = None,
                    wrap_around: bool = True,
                          ) -> Optional[Wnck.Workspace]:
    Severity: Minor
    Found in quicktile/wm.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Cyclomatic complexity is too high in function persist_maximization. (6)
    Wontfix

    @contextmanager
    def persist_maximization(win: Wnck.Window, keep_maximize: bool = True):
        """Context manager to persist maximization state after a call to
        :any:`WindowManager.reposition`.
    
    
    Severity: Minor
    Found in quicktile/wm.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

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

        def reposition(self,  # pylint: disable=too-many-arguments
                win: Wnck.Window,
                geom: Optional[Rectangle] = None,
                monitor: Rectangle = Rectangle(0, 0, 0, 0),
                keep_maximize: bool = False,
    Severity: Minor
    Found in quicktile/wm.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 _gather_struts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def _gather_struts(self):
            """Gather all toplevel _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL values"""
            struts = []
            for wid in [self.x_root.id] + list(self.get_property(
                    self.x_root.id, '_NET_CLIENT_LIST', Xatom.WINDOW, [])):
    Severity: Minor
    Found in quicktile/wm.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 reposition has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def reposition(self,  # pylint: disable=too-many-arguments
    Severity: Minor
    Found in quicktile/wm.py - About 45 mins to fix

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

          def update_geometry_cache(self):
              """Update the internal cache of monitor & panel shapes by querying
              them from the desktop, either using ``_GTK_WORKAREAS_D0`` or by
              running and processing them into a
              :class:`quicktile.util.UsableRegion`.
      Severity: Minor
      Found in quicktile/wm.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 set_property has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_property(self,  # pylint: disable=too-many-arguments
      Severity: Minor
      Found in quicktile/wm.py - About 45 mins to fix

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

            def get_workspace(self,
                        window: Wnck.Window = None,
                        direction: Union[Wnck.MotionDirection, int] = None,
                        wrap_around: bool = True,
                              ) -> Optional[Wnck.Workspace]:
        Severity: Minor
        Found in quicktile/wm.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 persist_maximization has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def persist_maximization(win: Wnck.Window, keep_maximize: bool = True):
            """Context manager to persist maximization state after a call to
            :any:`WindowManager.reposition`.
        
            :param win: The window to operate on.
        Severity: Minor
        Found in quicktile/wm.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 get_relevant_windows has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_relevant_windows(self, workspace: Wnck.Workspace
                                     ) -> Iterable[Wnck.Window]:
                """Wrapper for :meth:`Wnck.Screen.get_windows` that filters out windows
                of type :any:`Wnck.WindowType.DESKTOP` or :any:`Wnck.WindowType.DOCK`.
        
        
        Severity: Minor
        Found in quicktile/wm.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

        TODO found
        Open

                # TODO: Decide how to support having different struts on different
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                    # TODO: Look into using python-xlib to match x_root use
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Unit test this
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Hook monitor-added and monitor-removed and regenerate this
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Hook changes to strut reservations and regenerate this
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                            # TODO: Unit test this fallback
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: How do I retrieve the root window from a given one?
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Verify that python-xlib will call XFree for us when appropriate
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Support customizations to exclude things like my Conky window
        Severity: Minor
        Found in quicktile/wm.py by fixme

        XXX found
        Open

            # XXX: Move `if not window` into a decorator and use it everywhere?
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                .. TODO:: Verify that my ``empty`` argument to :meth:`get_property`
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Make this remember the original position and re-derive from it
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                # TODO: Set an `onerror` handler and at least log an error to console
        Severity: Minor
        Found in quicktile/wm.py by fixme

        TODO found
        Open

                    # TODO: Deduplicate with the wrapping code in commands.py
        Severity: Minor
        Found in quicktile/wm.py by fixme

        There are no issues that match your filters.

        Category
        Status