psono/psono-server

View on GitHub

Showing 423 of 423 total issues

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

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')

        file_ids = []
        parent_shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_file_link.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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')

        secrets = []
        parent_shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_secret_link.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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

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

        link_id = str(attrs.get('link_id')).replace("-", "")

        shares = []
Severity: Minor
Found in psono/restapi/serializers/delete_share_link.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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        user_share_right_id = attrs.get('user_share_right_id', None)
        group_share_right_id = attrs.get('group_share_right_id', None)

        if user_share_right_id is None and group_share_right_id is None:
Severity: Minor
Found in psono/restapi/serializers/delete_share_right.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 validate has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

        title = attrs.get('title', '').strip()
        type = attrs.get('type', '').lower().strip()
        gcp_cloud_storage_bucket = attrs.get('gcp_cloud_storage_bucket', '').strip()
Severity: Minor
Found in psono/restapi/serializers/create_file_repository.py - About 1 hr to fix

    Function setUp has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def setUp(self):
    
            self.test_email = ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) + 'test@example.com'
            self.test_email_bcrypt = 'a'
            self.test_username = ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) + 'test@psono.pw'
    Severity: Minor
    Found in psono/fileserver/tests/authorize_upload.py - About 1 hr to fix

      Function post has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def post(self, request, *args, **kwargs):
              """
              Check the username and authkey and return the REST Token
              if the credentials are valid and authenticated.
      
      
      Severity: Minor
      Found in psono/restapi/views/login.py - About 1 hr to fix

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

            def get(self, request, *args, **kwargs):
                """
                Check the health of the application
                
                :param request:
        Severity: Minor
        Found in psono/restapi/views/health_check.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_group_details has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_group_details(self, request, membership):
        
                members = []
                if membership.accepted:
                    for m in membership.group.members.all():
        Severity: Minor
        Found in psono/restapi/views/group.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 is_allowed_url has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def is_allowed_url(url: str, url_filter: list) -> bool:
            """
            Takes an url, checks it against URL_FILTER and returns whether the url is allowed or not
        
            :param url: The url to test
        Severity: Minor
        Found in psono/restapi/utils/various.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 put has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def put(self, request, *args, **kwargs):
                """
                Checks the REST Token and updates the users email / authkey / secret and private key
        
                :param request:
        Severity: Minor
        Found in psono/restapi/views/user_update.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 validate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                api_key_id = attrs.get('api_key_id')
                secret_id = attrs.get('secret_id')
                api_key_secret_key = attrs.get('api_key_secret_key', False)
        Severity: Minor
        Found in psono/restapi/serializers/update_secret_with_api_key.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 config_get has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def config_get(key, *args):
            if 'PSONO_' + key in os.environ:
                val = os.environ.get('PSONO_' + key)
                try:
                    json_object = json.loads(val)
        Severity: Minor
        Found in psono/psono/settings.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_user_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_user_info(self, user):
        
                memberships = []
                for m in User_Group_Membership.objects.filter(user=user).select_related('group').only("id", "accepted", "group_admin", "share_admin", "create_date", "group__id", "group__name", "group__create_date", "group__public_key"):
                    memberships.append({
        Severity: Minor
        Found in psono/administration/views/user.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 post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def post(self, request, *args, **kwargs):
                """
                Updates a api_key
        
                :param request:
        Severity: Minor
        Found in psono/restapi/views/api_key.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 validate_username has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate_username(self, value):
        
                # According to RFC2142 all "authoritative" email addresses are:
                # ( https://www.ietf.org/rfc/rfc2142.txt )
        
        
        Severity: Minor
        Found in psono/restapi/serializers/register.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                # We hardcode the settings for scrypt and the hashing parameters, as every client that is not providing them
                # is using those parameters below internally
                hashing_algorithm = attrs.get('hashing_algorithm', 'scrypt')
        Severity: Minor
        Found in psono/restapi/serializers/register.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

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

            def get(self, request, group_id = None, *args, **kwargs):
                """
                Returns a list of all groups
        
                :param args:
        Severity: Minor
        Found in psono/administration/views/group.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate(self, attrs: dict) -> dict:
        
                username = attrs.get('username')
                emergency_authkey = attrs.get('emergency_authkey')
        
        
        Severity: Minor
        Found in psono/restapi/serializers/activate_emergency_login.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

        Severity
        Category
        Status
        Source
        Language