derwentx/wp-api-python

View on GitHub

Showing 22 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

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

              try:
                  self.request_token_secret = resp_content['oauth_token_secret'][0]
              except:
                  raise UserWarning(
                      "Could not parse request_token_secret in response from %s : %s"
      Severity: Major
      Found in wordpress/auth.py and 1 other location - About 2 hrs to fix
      wordpress/auth.py on lines 396..403

      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

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

              try:
                  self._request_token = resp_content['oauth_token'][0]
              except:
                  raise UserWarning(
                      "Could not parse request_token in response from %s : %s"
      Severity: Major
      Found in wordpress/auth.py and 1 other location - About 2 hrs to fix
      wordpress/auth.py on lines 405..412

      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

      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

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

            @property
            def authentication(self):
                """
                Provide authentication links discovered from the API.
        
        
        Severity: Minor
        Found in wordpress/auth.py and 1 other location - About 55 mins to fix
        wordpress/auth.py on lines 281..290

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

        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

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

            @property
            def oauth_verifier(self):
                """
                Verifier string used in authentication.
        
        
        Severity: Minor
        Found in wordpress/auth.py and 1 other location - About 55 mins to fix
        wordpress/auth.py on lines 270..279

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

        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

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

                try:
                    authorize_form_action, authorize_form_data = self.get_form_info(
                        confirmation_response, 'oauth1_authorize_form')
                except AssertionError as exc:
                    self.parse_login_form_error(
        Severity: Minor
        Found in wordpress/auth.py and 1 other location - About 50 mins to fix
        wordpress/auth.py on lines 530..535

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

        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

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

                try:
                    login_form_action, login_form_data = self.get_form_info(
                        login_form_response, 'loginform')
                except AssertionError as exc:
                    self.parse_login_form_error(
        Severity: Minor
        Found in wordpress/auth.py and 1 other location - About 50 mins to fix
        wordpress/auth.py on lines 553..558

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

        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

        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

                Severity
                Category
                Status
                Source
                Language