EventGhost/EventGhost

View on GitHub
eg/WinApi/Utils.py

Summary

Maintainability
D
1 day
Test Coverage

File Utils.py has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# This file is part of EventGhost.
# Copyright © 2005-2020 EventGhost Project <http://www.eventghost.net/>
#
Severity: Minor
Found in eg/WinApi/Utils.py - About 5 hrs to fix

    Function GetHwndIcon has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def GetHwndIcon(hWnd):
        """
        Get a wx.Icon from a window through its hwnd window handle
        """
        hIcon = DWORD()
    Severity: Minor
    Found in eg/WinApi/Utils.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 BestWindowFromPoint has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def BestWindowFromPoint(point):
        x, y = point
        foundWindow = WindowFromPoint(POINT(x, y))
    
        hWnds = GetWindowChildsList(GetAncestor(foundWindow, GA_ROOT), True)
    Severity: Minor
    Found in eg/WinApi/Utils.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 KillProcess has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def KillProcess(pid = None, processName = None, hwnd = None, signal = 0, restart = False):
        if pid:
            pass
        elif processName:
            pids = GetPids(processName = processName)
    Severity: Minor
    Found in eg/WinApi/Utils.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 GetHwnds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def GetHwnds(pid = None, processName = None):
        if pid:
            pass
        elif processName:
            pids = GetPids(processName = processName)
    Severity: Minor
    Found in eg/WinApi/Utils.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 PySendMessageTimeout has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def PySendMessageTimeout(
    Severity: Minor
    Found in eg/WinApi/Utils.py - About 45 mins to fix

      Function KillProcess has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def KillProcess(pid = None, processName = None, hwnd = None, signal = 0, restart = False):
      Severity: Minor
      Found in eg/WinApi/Utils.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                return False
        Severity: Major
        Found in eg/WinApi/Utils.py - About 30 mins to fix

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

          def BringHwndToFront(hWnd, invalidate=True):
              if hWnd is None:
                  return
              hWnd = GetAncestor(hWnd, GA_ROOT)
              if not IsWindow(hWnd):
          Severity: Minor
          Found in eg/WinApi/Utils.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

          There are no issues that match your filters.

          Category
          Status