peterhudec/authomatic

View on GitHub
authomatic/providers/oauth1.py

Summary

Maintainability
F
4 days
Test Coverage

File oauth1.py has 1042 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
|oauth1| Providers
--------------------

Severity: Major
Found in authomatic/providers/oauth1.py - About 2 days to fix

    Function create_request_elements has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_request_elements(
                cls, request_type, credentials, url, params=None, headers=None,
                body='', method='GET', verifier='', callback=''
        ):
            """
    Severity: Minor
    Found in authomatic/providers/oauth1.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 login has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def login(self):
            # get request parameters from which we can determine the login phase
            denied = self.params.get('denied')
            verifier = self.params.get('oauth_verifier', '')
            request_token = self.params.get('oauth_token', '')
    Severity: Minor
    Found in authomatic/providers/oauth1.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 create_request_elements has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def create_request_elements(
    Severity: Major
    Found in authomatic/providers/oauth1.py - About 1 hr to fix

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

          def _x_user_parser(user, data):
              _users = data.get('users', [])
              if _users and _users[0]:
                  _user = _users[0]
                  user.id = _user.get('id')
      Severity: Minor
      Found in authomatic/providers/oauth1.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 _x_user_parser has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def _x_user_parser(user, data):
      
              _user = data.get('query', {}).get('results', {}).get('profile', {})
      
              user.id = _user.get('guid')
      Severity: Minor
      Found in authomatic/providers/oauth1.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 create_signature has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create_signature(cls, method, base, params,
      Severity: Minor
      Found in authomatic/providers/oauth1.py - About 35 mins to fix

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

            def create_signature(self, method, base, params,
        Severity: Minor
        Found in authomatic/providers/oauth1.py - About 35 mins to fix

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

              def create_signature(cls, method, base, params,
          Severity: Minor
          Found in authomatic/providers/oauth1.py - About 35 mins to fix

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

                def _access_user_info(self):
                    """
                    Email is available in separate method so second request is needed.
                    """
                    response = super(Bitbucket, self)._access_user_info()
            Severity: Minor
            Found in authomatic/providers/oauth1.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

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

                @staticmethod
                def _x_user_parser(user, data):
                    user.name = data.get('display_name')
                    user.link = data.get('profile_url')
                    user.picture = data.get('portrait_huge')
            Severity: Major
            Found in authomatic/providers/oauth1.py and 1 other location - About 2 hrs to fix
            authomatic/providers/oauth2.py on lines 1203..1208

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

            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

                supported_user_attributes = core.SupportedUserAttributes(
            Severity: Major
            Found in authomatic/providers/oauth1.py and 1 other location - About 1 hr to fix
            authomatic/providers/oauth2.py on lines 1413..1413

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

            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

                        if not self._http_status_in_category(response.status, 2):
                            raise FailureError(
                                u'Failed to obtain request token from {0}! HTTP status '
                                u'code: {1} content: {2}'.format(
                                    self.request_token_url,
            Severity: Minor
            Found in authomatic/providers/oauth1.py and 1 other location - About 55 mins to fix
            authomatic/providers/oauth2.py on lines 431..441

            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 4 locations. Consider refactoring.
            Open

                supported_user_attributes = core.SupportedUserAttributes(
            Severity: Major
            Found in authomatic/providers/oauth1.py and 3 other locations - About 40 mins to fix
            authomatic/providers/oauth1.py on lines 591..591
            authomatic/providers/oauth1.py on lines 756..756
            authomatic/providers/oauth2.py on lines 1871..1871

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

            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 4 locations. Consider refactoring.
            Open

                supported_user_attributes = core.SupportedUserAttributes(
            Severity: Major
            Found in authomatic/providers/oauth1.py and 3 other locations - About 40 mins to fix
            authomatic/providers/oauth1.py on lines 591..591
            authomatic/providers/oauth1.py on lines 1208..1208
            authomatic/providers/oauth2.py on lines 1871..1871

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

            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 4 locations. Consider refactoring.
            Open

                supported_user_attributes = core.SupportedUserAttributes(
            Severity: Major
            Found in authomatic/providers/oauth1.py and 3 other locations - About 40 mins to fix
            authomatic/providers/oauth1.py on lines 756..756
            authomatic/providers/oauth1.py on lines 1208..1208
            authomatic/providers/oauth2.py on lines 1871..1871

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

            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

            There are no issues that match your filters.

            Category
            Status