psono/psono-server

View on GitHub

Showing 228 of 423 total issues

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

    def put(self, request, *args, **kwargs):
        """
        Updates a secret.

        :param request:
Severity: Minor
Found in psono/restapi/views/api_key_access_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 get_groups has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def get_groups(self, request):
        # Generates a list of groups wherever the user has any rights for it
        memberships = User_Group_Membership.objects.select_related('group').filter(user=request.user).exclude(
            accepted=False).distinct()

Severity: Minor
Found in psono/restapi/views/group.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 authenticate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def authenticate(self, request):
        try:
            token_hash = self.get_token_hash(request)
        except exceptions.AuthenticationFailed:
            token_hash = None
Severity: Minor
Found in psono/restapi/authentication.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 17 (exceeds 5 allowed). Consider refactoring.
Open

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

        username = attrs.get('username')
        recovery_authkey = attrs.get('recovery_authkey')
        hashing_algorithm = attrs.get('hashing_algorithm', '')
Severity: Minor
Found in psono/restapi/serializers/set_new_password.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 16 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_ids = attrs.get('link_ids')
        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/bulk_move_secret_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 post has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self, request, *args, **kwargs):
        """
        First step of the login with an emergency code

        :param request:
Severity: Minor
Found in psono/restapi/views/emergency_login.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 user_has_rights_on_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def user_has_rights_on_file(user_id: str = "", file_id: str = "", read: bool = None, write: bool = None) -> bool:
    """
    Checks if the given user has the requested rights for the given file

    :param user_id:
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

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

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')
        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/move_file_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 16 (exceeds 5 allowed). Consider refactoring.
Open

    def validate(self, attrs: dict) -> dict:
        link_id = attrs.get('link_id')
        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/move_secret_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 16 (exceeds 5 allowed). Consider refactoring.
Open

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

        file_id = self.context['request'].parser_context['kwargs'].get('file_id', False)
        credit = 0

Severity: Minor
Found in psono/restapi/serializers/read_file.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 put has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def put(self, request, *args, **kwargs):
        """
        Creates a new group membership

        :param request:
Severity: Minor
Found in psono/restapi/views/membership.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 15 (exceeds 5 allowed). Consider refactoring.
Open

    def post(self, request, *args, **kwargs):
        """
        Accepts the username, email and authkey and creates a new user
        if the username (and email address) do not already exist

Severity: Minor
Found in psono/restapi/views/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 load_config has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def load_config(config_path: str):
    settings_override = os.environ.get(ENV_VAR_SERVER_SETTING_BASE64, '')
    settings_override_toml = os.environ.get(ENV_VAR_SERVER_SETTING_TOML_BASE64, '')

    if settings_override:
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 main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    # 1. Generate the login info including the private key for PFS
    session_private_key, client_login_info = generate_client_login_info()

    # 2. Send the login request and handle eventual exceptions, problems and so on ...
Severity: Minor
Found in examples/api_key_with_session.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_all_direct_user_rights has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_direct_user_rights(user_id: str, share_id: Union[str, List[str]]) -> Union[User_Share_Right, None, List[Union[User_Share_Right, None]]]:

    if isinstance(share_id, list):
        if len(share_id) == 0:
            return []
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 get_all_direct_group_rights has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_direct_group_rights(user_id: str, share_id: Union[str, List[str]]) -> Union[Group_Share_Right, None, List[Union[Group_Share_Right, None]]]:

    if isinstance(share_id, list):
        if len(share_id) == 0:
            return []
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 get_all_inherited_rights has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_inherited_rights(user_id: str, share_id: Union[str, List[str]]) -> Union[User_Share_Right, None, List[Union[User_Share_Right, None]]]:

    if isinstance(share_id, list):
        if len(share_id) == 0:
            return []
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 validate has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

    Function setUp has 40 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_download.py - About 1 hr to fix

      Function setUp has 40 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/revoke_download.py - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language