tlsfuzzer/tlslite-ng

View on GitHub
tlslite/utils/python_dsakey.py

Summary

Maintainability
B
6 hrs
Test Coverage
A
95%

Function verify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def verify(self, signature, hashData, padding=None, hashAlg=None,
               saltLen=None):
        """Verify the passed-in bytes with the signature.

        This verifies a DSA signature on the passed-in data.
Severity: Minor
Found in tlslite/utils/python_dsakey.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 verify has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def verify(self, signature, hashData, padding=None, hashAlg=None,
Severity: Minor
Found in tlslite/utils/python_dsakey.py - About 35 mins to fix

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

        def __init__(self, p=0, q=0, g=0, x=0, y=0):
    Severity: Minor
    Found in tlslite/utils/python_dsakey.py - About 35 mins to fix

      Avoid too many return statements within this function.
      Open

              return False
      Severity: Major
      Found in tlslite/utils/python_dsakey.py - About 30 mins to fix

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

                if gmpyLoaded or GMPY2_LOADED:
                    p = mpz(p)
                    q = mpz(q)
                    g = mpz(g)
                    x = mpz(x)
        Severity: Major
        Found in tlslite/utils/python_dsakey.py and 1 other location - About 2 hrs to fix
        tlslite/utils/python_dsakey.py on lines 56..61

        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 54.

        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

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

                if gmpyLoaded or GMPY2_LOADED:
                    p = mpz(p)
                    q = mpz(q)
                    g = mpz(g)
                    x = mpz(x)
        Severity: Major
        Found in tlslite/utils/python_dsakey.py and 1 other location - About 2 hrs to fix
        tlslite/utils/python_dsakey.py on lines 25..30

        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 54.

        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

        The backslash is redundant between brackets
        Open

                    v = ((powMod(self.g, u1, self.p) * \
        Severity: Minor
        Found in tlslite/utils/python_dsakey.py by pep8

        Avoid explicit line join between brackets.

        The preferred way of wrapping long lines is by using Python's
        implied line continuation inside parentheses, brackets and braces.
        Long lines can be broken over multiple lines by wrapping expressions
        in parentheses.  These should be used in preference to using a
        backslash for line continuation.
        
        E502: aaa = [123, \\n       123]
        E502: aaa = ("bbb " \\n       "ccc")
        
        Okay: aaa = [123,\n       123]
        Okay: aaa = ("bbb "\n       "ccc")
        Okay: aaa = "bbb " \\n    "ccc"
        Okay: aaa = 123  # \\

        Expected 2 blank lines, found 1
        Open

        class Python_DSAKey(DSAKey):
        Severity: Minor
        Found in tlslite/utils/python_dsakey.py by pep8

        Separate top-level function and class definitions with two blank lines.

        Method definitions inside a class are separated by a single blank
        line.
        
        Extra blank lines may be used (sparingly) to separate groups of
        related functions.  Blank lines may be omitted between a bunch of
        related one-liners (e.g. a set of dummy implementations).
        
        Use blank lines in functions, sparingly, to indicate logical
        sections.
        
        Okay: def a():\n    pass\n\n\ndef b():\n    pass
        Okay: def a():\n    pass\n\n\nasync def b():\n    pass
        Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
        Okay: default = 1\nfoo = 1
        Okay: classify = 1\nfoo = 1
        
        E301: class Foo:\n    b = 0\n    def bar():\n        pass
        E302: def a():\n    pass\n\ndef b(n):\n    pass
        E302: def a():\n    pass\n\nasync def b(n):\n    pass
        E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
        E303: def a():\n\n\n\n    pass
        E304: @decorator\n\ndef a():\n    pass
        E305: def a():\n    pass\na()
        E306: def a():\n    def b():\n        pass\n    def c():\n        pass

        There are no issues that match your filters.

        Category
        Status