tlsfuzzer/tlslite-ng

View on GitHub
tlslite/utils/codec.py

Summary

Maintainability
C
1 day
Test Coverage
C
74%

File codec.py has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Author: Trevor Perrin
# See the LICENSE file for legal information regarding use of this file.

"""Classes for reading/writing binary data (such as TLS records)."""

Severity: Minor
Found in tlslite/utils/codec.py - About 4 hrs to fix

    Function addVarTupleSeq has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def addVarTupleSeq(self, seq, length, lengthLength):
            """
            Add a variable length list of same-sized element tuples.
    
            Note that all tuples must have the same size.
    Severity: Minor
    Found in tlslite/utils/codec.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 addVarSeq has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def addVarSeq(self, seq, length, lengthLength):
                """
                Add a bounded list of same-sized values
    
                Create a list of specific length with all items being of the same
    Severity: Minor
    Found in tlslite/utils/codec.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 add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def add(self, x, length):
                """
                Add a single positive integer value x, encode it in length bytes
    
                Encode positive iteger x in big-endian format using length bytes,
    Severity: Minor
    Found in tlslite/utils/codec.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 addVarSeq has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def addVarSeq(self, seq, length, lengthLength):
                """
                Add a bounded list of same-sized values
    
                Create a list of specific length with all items being of the same
    Severity: Minor
    Found in tlslite/utils/codec.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

    TODO found
    Open

        TODO: don't use an exception used by language parser to indicate errors
    Severity: Minor
    Found in tlslite/utils/codec.py by fixme

    Ambiguous variable name 'l'
    Open

            l = [0] * lengthList
    Severity: Minor
    Found in tlslite/utils/codec.py by pep8

    Never use the characters 'l', 'O', or 'I' as variable names.

    In some fonts, these characters are indistinguishable from the
    numerals one and zero. When tempted to use 'l', use 'L' instead.
    
    Okay: L = 0
    Okay: o = 123
    Okay: i = 42
    E741: l = 0
    E741: O = 123
    E741: I = 42
    
    Variables can be bound in several other contexts, including class
    and function definitions, 'global' and 'nonlocal' statements,
    exception handlers, and 'with' and 'for' statements.
    In addition, we have a special handling for function parameters.
    
    Okay: except AttributeError as o:
    Okay: with lock as L:
    Okay: foo(l=12)
    Okay: for a in foo(l=12):
    E741: except AttributeError as O:
    E741: with lock as l:
    E741: global I
    E741: nonlocal l
    E741: def foo(l):
    E741: def foo(l=12):
    E741: l = foo(l=12)
    E741: for l in range(10):
    E742: class I(object):
    E743: def l(x):

    Whitespace before ':'
    Open

            ret = self.bytes[self.index : end]
    Severity: Minor
    Found in tlslite/utils/codec.py by pep8

    Avoid extraneous whitespace.

    Avoid extraneous whitespace in these situations:
    - Immediately inside parentheses, brackets or braces.
    - Immediately before a comma, semicolon, or colon.
    
    Okay: spam(ham[1], {eggs: 2})
    E201: spam( ham[1], {eggs: 2})
    E201: spam(ham[ 1], {eggs: 2})
    E201: spam(ham[1], { eggs: 2})
    E202: spam(ham[1], {eggs: 2} )
    E202: spam(ham[1 ], {eggs: 2})
    E202: spam(ham[1], {eggs: 2 })
    
    E203: if x == 4: print x, y; x, y = y , x
    E203: if x == 4: print x, y ; x, y = y, x
    E203: if x == 4 : print x, y; x, y = y, x

    Ambiguous variable name 'l'
    Open

            l = [0] * lengthList
    Severity: Minor
    Found in tlslite/utils/codec.py by pep8

    Never use the characters 'l', 'O', or 'I' as variable names.

    In some fonts, these characters are indistinguishable from the
    numerals one and zero. When tempted to use 'l', use 'L' instead.
    
    Okay: L = 0
    Okay: o = 123
    Okay: i = 42
    E741: l = 0
    E741: O = 123
    E741: I = 42
    
    Variables can be bound in several other contexts, including class
    and function definitions, 'global' and 'nonlocal' statements,
    exception handlers, and 'with' and 'for' statements.
    In addition, we have a special handling for function parameters.
    
    Okay: except AttributeError as o:
    Okay: with lock as L:
    Okay: foo(l=12)
    Okay: for a in foo(l=12):
    E741: except AttributeError as O:
    E741: with lock as l:
    E741: global I
    E741: nonlocal l
    E741: def foo(l):
    E741: def foo(l=12):
    E741: l = foo(l=12)
    E741: for l in range(10):
    E742: class I(object):
    E743: def l(x):

    There are no issues that match your filters.

    Category
    Status