ActivityWatch/aw-watcher-window

View on GitHub

Showing 10 of 10 total issues

Function heartbeat_loop has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def heartbeat_loop(client, bucket_id, poll_time, strategy, exclude_title=False, exclude_titles=[]):
    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 3 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 get_window_name has a Cognitive Complexity of 15 (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 10 (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 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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    args = parse_args()

    if sys.platform.startswith("linux") and (
        "DISPLAY" not in os.environ or not os.environ["DISPLAY"]
Severity: Minor
Found in aw_watcher_window/main.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 heartbeat_loop has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def heartbeat_loop(client, bucket_id, poll_time, strategy, exclude_title=False, exclude_titles=[]):
Severity: Minor
Found in aw_watcher_window/main.py - About 45 mins to fix

    Avoid too many return statements within this function.
    Open

        return cls
    Severity: Major
    Found in aw_watcher_window/xlib.py - About 30 mins to fix

      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

        Avoid too many return statements within this function.
        Open

                        return d.value.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

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

          def get_current_window(strategy: Optional[str] = None) -> Optional[dict]:
              """
              :raises FatalError: if a fatal error occurs (e.g. unsupported platform, X server closed)
              """
          
          
          Severity: Minor
          Found in aw_watcher_window/lib.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