core/storage/suggestion/gae_models.py

Summary

Maintainability
F
2 wks
Test Coverage

File gae_models.py has 3015 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2018 The Oppia Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in core/storage/suggestion/gae_models.py - About 1 wk to fix

    Function get_in_review_translation_suggestions_with_exp_ids_by_offset has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_in_review_translation_suggestions_with_exp_ids_by_offset(
            cls,
            limit: Optional[int],
            offset: int,
            user_id: str,
    Severity: Minor
    Found in core/storage/suggestion/gae_models.py - About 5 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_in_review_translation_suggestions_by_offset has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_in_review_translation_suggestions_by_offset(
            cls,
            limit: Optional[int],
            offset: int,
            user_id: str,
    Severity: Minor
    Found in core/storage/suggestion/gae_models.py - About 5 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_in_review_question_suggestions_by_offset has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_in_review_question_suggestions_by_offset(
            cls,
            limit: int,
            offset: int,
            user_id: str,
    Severity: Minor
    Found in core/storage/suggestion/gae_models.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

    GeneralSuggestionModel has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class GeneralSuggestionModel(base_models.BaseModel):
        """Model to store suggestions made by Oppia users.
    
        The ID of the suggestions created is the same as the ID of the thread
        linked to the suggestion.
    Severity: Minor
    Found in core/storage/suggestion/gae_models.py - About 3 hrs to fix

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

          def fetch_page(
              cls,
              page_size: int,
              offset: int,
              sort_by: Optional[SortChoices.value],
      Severity: Minor
      Found in core/storage/suggestion/gae_models.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 fetch_page has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_page(
              cls,
              page_size: int,
              offset: int,
              language_code: str,
      Severity: Minor
      Found in core/storage/suggestion/gae_models.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 fetch_page has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_page(
              cls,
              page_size: int,
              offset: int,
              sort_by: Optional[SortChoices.value],
      Severity: Minor
      Found in core/storage/suggestion/gae_models.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 fetch_page has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch_page(
              cls,
              page_size: int,
              offset: int,
              language_code: str,
      Severity: Minor
      Found in core/storage/suggestion/gae_models.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 create has 15 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def create(
      Severity: Major
      Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

        Function create has 11 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create(
        Severity: Major
        Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

          Function create has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def create(
          Severity: Major
          Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

            Function create has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def create(
            Severity: Major
            Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

              Function create has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def create(
              Severity: Major
              Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

                Function create has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def create(
                Severity: Major
                Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

                  Function create has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def create(
                  Severity: Major
                  Found in core/storage/suggestion/gae_models.py - About 1 hr to fix

                    Function create has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def create(
                    Severity: Major
                    Found in core/storage/suggestion/gae_models.py - About 50 mins to fix

                      Function create has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def create(
                      Severity: Major
                      Found in core/storage/suggestion/gae_models.py - About 50 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if len(sorted_results) == page_size:
                                                    break
                                else:
                        Severity: Major
                        Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                          Function get_in_review_translation_suggestions_with_exp_ids_by_offset has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def get_in_review_translation_suggestions_with_exp_ids_by_offset(
                          Severity: Minor
                          Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if len(sorted_results) == page_size:
                                                        break
                                    else:
                            Severity: Major
                            Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if suggestion_model.author_id != user_id:
                                                          sorted_results.append(suggestion_model)
                                                          if len(sorted_results) == limit:
                                                              break
                              
                              
                              Severity: Major
                              Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if len(sorted_results) == page_size:
                                                            break
                                        else:
                                Severity: Major
                                Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                                  Function fetch_page has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def fetch_page(
                                  Severity: Minor
                                  Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if len(sorted_results) == page_size:
                                                                break
                                            else:
                                    Severity: Major
                                    Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if suggestion_model.author_id != user_id:
                                                                  sorted_results.append(suggestion_model)
                                                                  if len(sorted_results) == limit:
                                                                      break
                                      
                                      
                                      Severity: Major
                                      Found in core/storage/suggestion/gae_models.py - About 45 mins to fix

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

                                            def get_in_review_question_suggestions_by_offset(
                                        Severity: Minor
                                        Found in core/storage/suggestion/gae_models.py - About 35 mins to fix

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

                                              def get_user_created_suggestions_by_offset(
                                          Severity: Minor
                                          Found in core/storage/suggestion/gae_models.py - About 35 mins to fix

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

                                                def get_in_review_translation_suggestions_by_offset(
                                            Severity: Minor
                                            Found in core/storage/suggestion/gae_models.py - About 35 mins to fix

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

                                                  def fetch_page(
                                              Severity: Minor
                                              Found in core/storage/suggestion/gae_models.py - About 35 mins to fix

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

                                                    def fetch_page(
                                                Severity: Minor
                                                Found in core/storage/suggestion/gae_models.py - About 35 mins to fix

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status