psono/psono-server

View on GitHub

Showing 423 of 423 total issues

Avoid too many return statements within this function.
Open

        return args[0]
Severity: Major
Found in psono/psono/settings.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return config
    Severity: Major
    Found in psono/psono/settings.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return eprint_and_exit_gunicorn(f"deserializing {config_format} config from '{config_source}' failed: {e}")
      Severity: Major
      Found in psono/psono/settings.py - About 30 mins to fix

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

            def post(self, request, *args, **kwargs):
                """
                Check the REST Token and returns the user's public key. To identify the user either the email or the user_id needs
                to be provided
        
        
        Severity: Minor
        Found in psono/restapi/views/user_search.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, request, api_key_id = None, *args, **kwargs):
                """
                Returns either a list of all api_keys with own access privileges or the members specified api_key
                
                :param request:
        Severity: Minor
        Found in psono/restapi/views/api_key.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, request, link_share_id = None, *args, **kwargs):
                """
                Returns either a list of all link_shares with own access privileges or the members specified link_share
                
                :param request:
        Severity: Minor
        Found in psono/restapi/views/link_share.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 delete_avatar_storage_of_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def delete_avatar_storage_of_user(user_id):
            """
            Deletes the avatar storage of a user
            """
            storage = get_avatar_storage()
        Severity: Minor
        Found in psono/restapi/utils/avatar.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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def get(self, request, share_id = None, *args, **kwargs):
                """
                Returns a list of all shares with all own share rights on that share or
                returns a share with all rights existing on the share
        
        
        Severity: Minor
        Found in psono/restapi/views/share.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 get_cache has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_cache(model, pk):
            pk = str(pk)
            try:
                cached_entity = None
                if settings.CACHE_ENABLE:
        Severity: Minor
        Found in psono/restapi/utils/various.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 api_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def api_request(method, endpoint, data = None, token = None, session_secret_key = None):
        
            if token:
                headers = {'content-type': 'application/json', 'authorization': 'Token ' + token}
            else:
        Severity: Minor
        Found in examples/create_secret_in_share.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 api_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def api_request(method, endpoint, data = None, token = None, session_secret_key = None):
        
            if token:
                headers = {'content-type': 'application/json', 'authorization': 'Token ' + token}
            else:
        Severity: Minor
        Found in examples/api_key_with_session.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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle(self, *args, **options):
        
                shards = Fileserver_Shard.objects.all()
        
                if len(shards) == 0:
        Severity: Minor
        Found in psono/restapi/management/commands/fsshardlist.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def post(self, request, *args, **kwargs):
                """
                Marks a Membership as accepted. In addition update the membership with the new encryption key.
        
                :param request:
        Severity: Minor
        Found in psono/restapi/views/membership_accept.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 ivalt_auth_request_verify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def ivalt_auth_request_verify(mobile: str) -> dict:
             # verify user's mobile to authenticate
            url = "https://api.ivalt.com/biometric-geo-fence-auth-results"
            headers = {
                "x-api-key": settings.IVALT_SECRET_KEY,
        Severity: Minor
        Found in psono/restapi/utils/ivalt.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 api_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def api_request(method, endpoint, data = None, token = None, session_secret_key = None):
        
            if token:
                headers = {'content-type': 'application/json', 'authorization': 'Token ' + token}
            else:
        Severity: Minor
        Found in examples/create_secret_in_datastore.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 handle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle(self, *args, **options):
        
                clusters = Fileserver_Cluster.objects.all()
        
                if len(clusters) == 0:
        Severity: Minor
        Found in psono/restapi/management/commands/fsclusterlist.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                link_share_id = attrs.get('link_share_id')
                allowed_reads = attrs.get('allowed_reads', None)
                passphrase = attrs.get('passphrase', None)
        Severity: Minor
        Found in psono/restapi/serializers/update_link_share.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                ga_token = attrs.get('ga_token', '').lower().strip()
        
                if not ga_token.isdigit():
        Severity: Minor
        Found in psono/restapi/serializers/ga_verify.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                mobile = attrs.get('mobile', '').strip()
        
                if not settings.IVALT_SECRET_KEY or settings.IVALT_SECRET_KEY == '':  #nosec -- not [B105:hardcoded_password_string]
        Severity: Minor
        Found in psono/restapi/serializers/create_ivalt.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
                avatar_id = self.context['request'].parser_context['kwargs'].get('avatar_id', False)
                user_id = self.context['request'].parser_context['kwargs'].get('user_id', False)
        
                try:
        Severity: Minor
        Found in psono/restapi/serializers/read_avatar_image.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