nathan-v/aws_okta_keyman

View on GitHub
aws_okta_keyman/okta.py

Summary

Maintainability
B
6 hrs
Test Coverage

File okta.py has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

#
# Credits: Portions of this code were copied/modified from
# https://github.com/ThoughtWorksInc/oktaauth
#
# Copyright (c) 2015, Peter Gillard-Moss
Severity: Minor
Found in aws_okta_keyman/okta.py - About 7 hrs to fix

    Function handle_push_factors has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_push_factors(self, factors, state_token):
            """Handle  any push-type factors.
    
            Args:
                factors: Dict of supported MFA push factors from Okta
    Severity: Minor
    Found in aws_okta_keyman/okta.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 handle_response_factors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_response_factors(self, factors, state_token):
            """Handle any OTP-type factors.
    
            Raises back to keyman.py to interact with the user for an OTP response
    
    
    Severity: Minor
    Found in aws_okta_keyman/okta.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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(
            self,
            organization,
            username,
            password,
    Severity: Minor
    Found in aws_okta_keyman/okta.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 handle_mfa_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_mfa_response(self, ret):
            """In the case of an MFA response evaluate the response and handle
            accordingly based on available MFA factors.
    
            Args:
    Severity: Minor
    Found in aws_okta_keyman/okta.py - About 55 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 duo_auth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def duo_auth(self, fid, state_token, passcode=None):
            """Trigger a Duo Auth request.
    
            This method is meant to be called by self.auth() if a Login session
            requires MFA, and the users profile supports Duo.
    Severity: Minor
    Found in aws_okta_keyman/okta.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in aws_okta_keyman/okta.py - About 35 mins to fix

      Function auth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def auth(self, state_token=None):
              """Perform an initial authentication against Okta.
      
              The initial Okta Login authentication is handled here - and optionally
              MFA authentication is triggered. If successful, this method stores a
      Severity: Minor
      Found in aws_okta_keyman/okta.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 mfa_wait_loop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def mfa_wait_loop(self, ret, data, sleep=2):
              """Wait loop that keeps checking Okta for MFA status.
      
              Args:
                  ret: Dict (JSON) response from a previous API call
      Severity: Minor
      Found in aws_okta_keyman/okta.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

      Line too long (86 > 79 characters)
      Open

                  i["label"]: i["linkUrl"] for i in resp_obj if i["appName"] == "amazon_aws"
      Severity: Minor
      Found in aws_okta_keyman/okta.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      There are no issues that match your filters.

      Category
      Status