ActivityWatch/aw-watcher-window

View on GitHub
aw_watcher_window/xlib.py

Summary

Maintainability
A
2 hrs
Test Coverage

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

    There are no issues that match your filters.

    Category
    Status