EventGhost/EventGhost

View on GitHub
eg/WinApi/SendKeys.py

Summary

Maintainability
D
3 days
Test Coverage

File SendKeys.py has 482 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/SendKeys.py - About 7 hrs to fix

    Function ParseText has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    def ParseText(text):
        """
        Translates a string to a key sequence.
        """
        data = []
    Severity: Minor
    Found in eg/WinApi/SendKeys.py - About 6 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 SendRawCodes2 has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def SendRawCodes2(self, keyData, hwnd, mode):
            """
            Uses PostMessage and SetKeyboardState to emulate the the virtual
            keycode. Can send to a specified window handle.
            """
    Severity: Minor
    Found in eg/WinApi/SendKeys.py - About 4 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 __call__ has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, hwnd, keystrokeString, useAlternateMethod=False, mode=2):
            keyData = ParseText(keystrokeString)
            if keyData:
                needGetFocus = False
                sendToFront = False
    Severity: Minor
    Found in eg/WinApi/SendKeys.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 SendRawCodes1 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def SendRawCodes1(self, keyData, mode):
            """
            Uses the SendInput-API function to send the virtual keycode.
            Can only send to the frontmost window.
            """
    Severity: Minor
    Found in eg/WinApi/SendKeys.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

    Avoid deeply nested control flow statements.
    Open

                        if word not in VK_KEYS:
                            try:
                                res = unicode(eval(key, {}, eg.globals.__dict__))
                            except:
                                res = key
    Severity: Major
    Found in eg/WinApi/SendKeys.py - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status