dragonchain/dragonchain

View on GitHub
dragonchain/lib/authorization.py

Summary

Maintainability
D
1 day
Test Coverage
A
99%

Function verify_request_authorization has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

def verify_request_authorization(  # noqa: C901
    authorization: str,
    http_verb: str,
    full_path: str,
    dcid: str,
Severity: Minor
Found in dragonchain/lib/authorization.py - About 5 hrs 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

File authorization.py has 303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2020 Dragonchain, Inc.
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
Severity: Minor
Found in dragonchain/lib/authorization.py - About 3 hrs to fix

    Function verify_request_authorization has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def verify_request_authorization(  # noqa: C901
    Severity: Major
    Found in dragonchain/lib/authorization.py - About 1 hr to fix

      Function get_authorization has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_authorization(
      Severity: Major
      Found in dragonchain/lib/authorization.py - About 1 hr to fix

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

        def generate_authenticated_request(
            http_verb: str, dcid: str, full_path: str, json_content: dict = None, hmac_hash_type: str = "SHA256"
        ) -> Tuple[dict, bytes]:
            """Generate request data (headers and body) for making authenticated http requests to other dragonchains or matchmaking
            Args:
        Severity: Minor
        Found in dragonchain/lib/authorization.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 get_hmac_message_string has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get_hmac_message_string(
        Severity: Major
        Found in dragonchain/lib/authorization.py - About 50 mins to fix

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

          def generate_authenticated_request(
          Severity: Minor
          Found in dragonchain/lib/authorization.py - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status