Varbin/pep272-encryption

View on GitHub
src/pep272_encryption/__init__.py

Summary

Maintainability
B
5 hrs
Test Coverage
A
96%

File __init__.py has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!python3
"""\
This module creates PEP-272 cipher object classes for building block ciphers
in python.

Severity: Minor
Found in src/pep272_encryption/__init__.py - About 2 hrs to fix

    Function _create_keystream has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _create_keystream(self):
            "Creates a keystream (generator object) for OFB or CTR mode."
            if self.mode not in (MODE_OFB, MODE_CTR):
                # Coverage somehow does not work here
                return  # pragma: no cover
    Severity: Minor
    Found in src/pep272_encryption/__init__.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 encrypt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def encrypt(self, string):
            """Encrypt data with the key and the parameters set at initialization.
    
            The cipher object is stateful; encryption of a long block
            of data can be broken up in two or more calls to `encrypt()`.
    Severity: Minor
    Found in src/pep272_encryption/__init__.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 decrypt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def decrypt(self, string):
            """Decrypt data with the key and the parameters set at initialization.
    
            The cipher object is stateful; decryption of a long block
            of data can be broken up in two or more calls to `decrypt()`.
    Severity: Minor
    Found in src/pep272_encryption/__init__.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 _check_iv has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_iv(self):
            if self._status is None:
                raise TypeError("For CBC, CFB, PGP and OFB mode an IV is "
                                "required.")
            if len(self._status) != self.block_size and self.mode != MODE_PGP:
    Severity: Minor
    Found in src/pep272_encryption/__init__.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