psono/psono-server

View on GitHub

Showing 228 of 423 total issues

Function validate has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:

        shard_id = attrs.get('shard_id', None)
        file_repository_id = attrs.get('file_repository_id', None)
        parent_share_id = attrs.get('parent_share_id', None)
Severity: Minor
Found in psono/restapi/serializers/create_file.py - About 4 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 handle has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def handle(self, *args, **options):

        integration_key = options['integration_key']
        secret_key = options['secret_key']
        host = options['host']
Severity: Minor
Found in psono/restapi/management/commands/testduoconnection.py - About 4 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_all_secrets has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_secrets(datastore, token, session_secret_key, include_trash_bin_items=False):

    def handle_items(items):
        for item in items:
            if not "secret_id" in item:
Severity: Minor
Found in examples/export_as_json.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

File revoke_download.py has 318 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from django.urls import reverse
from django.conf import settings
from django.utils import timezone
from datetime import timedelta
from rest_framework import status
Severity: Minor
Found in psono/fileserver/tests/revoke_download.py - About 3 hrs to fix

    Function authenticate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def authenticate(self, request):
            token_hash = self.get_token_hash(request)
            token = self.get_db_token(token_hash)
    
            user = get_cache(User, token.user_id)
    Severity: Minor
    Found in psono/restapi/authentication.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 validate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(self, attrs: dict) -> dict:
    
            user_id = attrs.get('user_id', '')
            user_username = attrs.get('user_username', '').lower().strip()
            user_email = attrs.get('user_email', '').lower().strip()
    Severity: Minor
    Found in psono/restapi/serializers/user_search.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 filter_datastore_export has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def filter_datastore_export(folder, include_trash_bin_items=False):
    
        unwanted_folder_properties = [
            "id",
            "datastore_id",
    Severity: Minor
    Found in examples/export_as_json.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 delete has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def delete(self, request, *args, **kwargs):
            """
            Delete File_Link obj
    
            Necessary Rights:
    Severity: Minor
    Found in psono/restapi/views/file_link.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_all_shares has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_all_shares(folder, token, session_secret_key):
    
        def handle_share(share):
            share_read_result = api_read_share(token, session_secret_key, share['share_id'])
            share_content = None
    Severity: Minor
    Found in examples/export_as_json.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 authenticate has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    def authenticate(username: str = "", user: User = None, authkey: str = "", password: str = "") -> Tuple: # nosec
        """
        Checks if the authkey for the given user, specified by the email or directly by the user object matches
    
        :param username: str
    Severity: Minor
    Found in psono/restapi/utils/various.py - About 2 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 user.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from django.conf import settings
    from django.db.models import Q, Exists, OuterRef
    from rest_framework import status
    from rest_framework.response import Response
    from rest_framework.generics import GenericAPIView
    Severity: Minor
    Found in psono/administration/views/user.py - About 2 hrs to fix

      Function get has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(self, request, user_share_right_id = None, *args, **kwargs):
              """
              Returns a specific Share_Right or a list of all the Share_Rights of the user who requested it
      
              :param request:
      Severity: Minor
      Found in psono/restapi/views/share_right.py - About 2 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 validate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, attrs: dict) -> dict:
      
              link_id = str(attrs.get('link_id')).replace("-", "")
              new_parent_share_id = attrs.get('new_parent_share_id', None)
              new_parent_datastore_id = attrs.get('new_parent_datastore_id', None)
      Severity: Minor
      Found in psono/restapi/serializers/update_share_link.py - About 2 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 validate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate(self, attrs: dict) -> dict:
      
              duo_id = attrs.get('duo_id', '')
              duo_token = attrs.get('duo_token', None)
      
      
      Severity: Minor
      Found in psono/restapi/serializers/activate_duo.py - About 2 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 share_right.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import os
      from collections import defaultdict
      
      from rest_framework import status
      from rest_framework.response import Response
      Severity: Minor
      Found in psono/restapi/views/share_right.py - About 2 hrs to fix

        Function validate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                user_id = attrs.get('user_id', False)
                group_id = attrs.get('group_id', False)
                share_id = attrs['share_id']
        Severity: Minor
        Found in psono/restapi/serializers/create_share_right.py - About 2 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 validate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                duo_token = attrs.get('duo_token', None)
        
                token = self.context['request'].auth
        Severity: Minor
        Found in psono/restapi/serializers/duo_verify.py - About 2 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 api_key_with_session.py has 271 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        A small demo script that shows how to access the datastore with a session (unrestricted API key) and modify a secret
        """
        import requests
        import json
        Severity: Minor
        Found in examples/api_key_with_session.py - About 2 hrs to fix

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

              def post(self, request, *args, **kwargs):
                  """
                  Updates a secret
          
                  Necessary Rights:
          Severity: Minor
          Found in psono/restapi/views/secret.py - About 2 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 fileserver_access has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          def fileserver_access(cmsl, ip_address, read=None, write=None, allow_link_shares=None):
              """
              Tests weather an ip address has access for a specific cluster member shard link
          
              :param cmsl:
          Severity: Minor
          Found in psono/restapi/utils/various.py - About 2 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

          Severity
          Category
          Status
          Source
          Language