Varbin/pep272-encryption

View on GitHub

Showing 9 of 9 total issues

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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, nonce=None, initial_value=0, suffix=None,
                     iv=None, IV=None, block_size=None, endian="big",
                     wrap_around=False):
            try:
                self.endian = _endian_dict[endian.lower()]
    Severity: Minor
    Found in src/pep272_encryption/util.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 _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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, nonce=None, initial_value=0, suffix=None,
    Severity: Major
    Found in src/pep272_encryption/util.py - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                      if not name.endswith("WHEEL") and not name.endswith("RECORD"):
                          print(f"Copying {name}")
                          buffer = inf.read(name)
                          record_data[name] = (wheel_hash(buffer),
                                                        len(buffer))
      Severity: Major
      Found in .github/_replace_tags_in_wheel.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if not line.startswith("Tag: "):
                            wheel_out += line + "\n"
                    for tag in tags:
        Severity: Major
        Found in .github/_replace_tags_in_wheel.py - About 45 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language