ActivityWatch/aw-watcher-window

View on GitHub

Showing 5 of 5 total issues

Function get_window_name has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def get_window_name(window: Window) -> str:
    """ After some annoying debugging I resorted to pretty much copying selfspy.
        Source: https://github.com/gurgeh/selfspy/blob/8a34597f81000b3a1be12f8cde092a40604e49cf/selfspy/sniff_x.py#L165 """
    try:
        d = window.get_full_property(NET_WM_NAME, UTF8_STRING)
Severity: Minor
Found in aw_watcher_window/xlib.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 heartbeat_loop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def heartbeat_loop(client, bucket_id, poll_time, exclude_title=False):
    while True:
        if os.getppid() == 1:
            logger.info("window-watcher stopped because parent process died")
            break
Severity: Minor
Found in aw_watcher_window/main.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_window_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_window_class(window: Window) -> str:
    cls = None

    try:
        cls = window.get_wm_class()
Severity: Minor
Found in aw_watcher_window/xlib.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

Avoid too many return statements within this function.
Open

                return d.value.encode('utf8').decode('utf8', 'ignore')
Severity: Major
Found in aw_watcher_window/xlib.py - About 30 mins to fix

    Function get_active_window_id has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_active_window_id():
        lines = xprop_root().split("\n")
        match="_NET_ACTIVE_WINDOW(WINDOW)"
        result = None
        for line in lines:
    Severity: Minor
    Found in aw_watcher_window/xprop.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

    Severity
    Category
    Status
    Source
    Language