derwentx/wp-api-python

View on GitHub

Showing 16 of 22 total issues

File auth.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""
Wordpress OAuth1.0a Class
"""
Severity: Major
Found in wordpress/auth.py - About 1 day to fix

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

        def request_post_mortem(self, response=None):
            """
            Attempt to diagnose what went wrong in a request
            """
    
    
    Severity: Minor
    Found in wordpress/api.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 helpers.py has 334 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    
    """
    Wordpress Hellper Class
    """
    Severity: Minor
    Found in wordpress/helpers.py - About 4 hrs to fix

      Function parse_login_form_error has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_login_form_error(self, response, exc, **kwargs):
              """
              If unable to parse login form, try to determine which error is present
              """
              login_form_soup = BeautifulSoup(response.text, 'lxml')
      Severity: Minor
      Found in wordpress/auth.py - About 3 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

      Function get_verifier has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_verifier(self, request_token=None, wp_user=None, wp_pass=None):
              """
              Get verifier string from access token.
      
              Pretends to be a browser, uses the authorize auth link,
      Severity: Minor
      Found in wordpress/auth.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_value_like_as_php has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_value_like_as_php(val):
              """ Prepare value for quote """
              try:
                  base = basestring
              except NameError:
      Severity: Minor
      Found in wordpress/helpers.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_verifier has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_verifier(self, request_token=None, wp_user=None, wp_pass=None):
              """
              Get verifier string from access token.
      
              Pretends to be a browser, uses the authorize auth link,
      Severity: Minor
      Found in wordpress/auth.py - About 1 hr to fix

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

            def request(
                self, method, url, auth=None, params=None, data=None, **kwargs
            ):
                headers = {
                    "user-agent": "Wordpress API Client-Python/%s" % __version__,
        Severity: Minor
        Found in wordpress/transport.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 request has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def request(
        Severity: Minor
        Found in wordpress/transport.py - About 45 mins to fix

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

              def add_params_sign(self, method, url, params, sign_key=None, **kwargs):
          Severity: Minor
          Found in wordpress/auth.py - About 35 mins to fix

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

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

              Avoid too many return statements within this function.
              Open

                          return ""
              Severity: Major
              Found in wordpress/helpers.py - About 30 mins to fix

                Function __request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __request(self, method, endpoint, data, **kwargs):
                        """ Do requests """
                
                        endpoint_url = self.requester.endpoint_url(endpoint)
                        endpoint_url = self.auth.get_auth_url(endpoint_url, method, **kwargs)
                Severity: Minor
                Found in wordpress/api.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

                Function retrieve_access_creds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def retrieve_access_creds(self):
                        """Retrieve access_token / access_token_secret stored locally."""
                
                        if not self.creds_store:
                            return
                Severity: Minor
                Found in wordpress/auth.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

                Function store_access_creds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def store_access_creds(self):
                        """ store the access_token and access_token_secret locally. """
                
                        if not self.creds_store:
                            return
                Severity: Minor
                Found in wordpress/auth.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

                Function jsonencode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def jsonencode(cls, data, **kwargs):
                        if PY2:
                            for encoding in filter(None, {
                                kwargs.get('encoding', 'utf8'),
                                sys.getdefaultencoding(),
                Severity: Minor
                Found in wordpress/helpers.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