EventGhost/EventGhost

View on GitHub
eg/WinApi/serial/serialutil.py

Summary

Maintainability
D
2 days
Test Coverage

File serialutil.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#! python
#Python Serial Port Extension for Win32, Linux, BSD, Jython
#see __init__.py
#
#(C) 2001-2003 Chris Liechti <cliechti@gmx.net>
Severity: Minor
Found in eg/WinApi/serial/serialutil.py - About 4 hrs to fix

    SerialBase has 27 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class SerialBase(FileLike):
        """Serial port base class. Provides __init__ function and properties to
           get/set port settings."""
        #default values, may be overriden in subclasses that do not support all values
        BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600,
    Severity: Minor
    Found in eg/WinApi/serial/serialutil.py - About 3 hrs to fix

      Function __init__ has 24 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self,
      Severity: Major
      Found in eg/WinApi/serial/serialutil.py - About 3 hrs to fix

        Function readline has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def readline(self, size=None, eol='\n'):
                """read a line which is terminated with end-of-line (eol) character
                ('\n' by default) or until timeout"""
                line = ''
                while 1:
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.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 readlines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def readlines(self, sizehint=None, eol='\n'):
                """read a list of lines, until timeout
                sizehint is ignored"""
                if self.timeout is None:
                    raise ValueError("Serial port MUST have enabled timeout for this function!")
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.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

        Function setPort has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def setPort(self, port):
                """
                Change the port. The attribute portstr is set to a string that
                contains the name of the port.
                """
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.py - About 35 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 setTimeout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def setTimeout(self, timeout):
                """
                Change timeout setting.
                """
                if timeout is not None:
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.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 setWriteTimeout has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def setWriteTimeout(self, timeout):
                """
                Change timeout setting.
                """
                if timeout is not None:
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.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

        TODO found
        Open

            #TODO: these are not realy needed as the is the BAUDRATES etc attribute...
        Severity: Minor
        Found in eg/WinApi/serial/serialutil.py by fixme

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def setTimeout(self, timeout):
                """
                Change timeout setting.
                """
                if timeout is not None:
        Severity: Major
        Found in eg/WinApi/serial/serialutil.py and 1 other location - About 3 hrs to fix
        eg/WinApi/serial/serialutil.py on lines 350..364

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 92.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def setWriteTimeout(self, timeout):
                """
                Change timeout setting.
                """
                if timeout is not None:
        Severity: Major
        Found in eg/WinApi/serial/serialutil.py and 1 other location - About 3 hrs to fix
        eg/WinApi/serial/serialutil.py on lines 334..348

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 92.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status