File suggestion_services.py
has 3338 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
Function get_suggestions_waiting_for_review_info_to_notify_reviewers
has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring. Open
def get_suggestions_waiting_for_review_info_to_notify_reviewers(
reviewer_ids: List[str]
) -> List[List[suggestion_registry.ReviewableSuggestionEmailInfo]]:
"""For each user, returns information that will be used to notify reviewers
about the suggestions waiting longest for review, that the reviewer has
- Read upRead up
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 update_question_review_stats
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def update_question_review_stats(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates QuestionReviewStatsModel and
QuestionReviewerTotalContributionStatsModel model for given question
- Read upRead up
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 update_translation_review_stats
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def update_translation_review_stats(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates TranslationReviewStatsModel
TranslationReviewerTotalContributionStatsModel model for given translation
- Read upRead up
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 increment_translation_submitter_total_stats_at_review
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def increment_translation_submitter_total_stats_at_review(
translation_submitter_total_stat: (
suggestion_registry.TranslationSubmitterTotalContributionStats),
content_word_count: int,
suggestion_is_accepted: bool,
- Read upRead up
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 increment_question_submitter_total_stats_at_review
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def increment_question_submitter_total_stats_at_review(
question_submitter_total_stat: (
suggestion_registry.QuestionSubmitterTotalContributionStats),
suggestion_is_accepted: bool,
edited_by_reviewer: bool
- Read upRead up
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 update_question_contribution_stats_at_review
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def update_question_contribution_stats_at_review(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates QuestionContributionStatsModel
QuestionSubmitterTotalContributionStatsModel models for given question
- Read upRead up
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 accept_suggestion
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def accept_suggestion(
suggestion_id: str,
reviewer_id: str,
commit_message: str,
review_message: str
- Read upRead up
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 _update_suggestion_counts_in_community_contribution_stats_transactional
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _update_suggestion_counts_in_community_contribution_stats_transactional(
suggestions: List[suggestion_registry.BaseSuggestion], amount: int
) -> None:
"""Updates the community contribution stats counts associated with the given
suggestions by the given amount. Note that this method should only ever be
- Read upRead up
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 update_translation_contribution_stats_at_review
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_translation_contribution_stats_at_review(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates TranslationContributionStatsModel and
TranslationSubmitterTotalContributionStatsModel model for
- Read upRead up
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 update_translation_contribution_stats_at_submission
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_translation_contribution_stats_at_submission(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates TranslationContributionStatsModel and
TranslationSubmitterTotalContributionStatsModel model for
- Read upRead up
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_suggestion
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_suggestion(
Function create_suggestion
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_suggestion(
Function create_suggestion
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_suggestion(
Function create_suggestion
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_suggestion(
Function create_suggestion
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_suggestion(
Function create_suggestion
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create_suggestion(
suggestion_type: str,
target_type: str,
target_id: str,
target_version_at_submission: int,
- Read upRead up
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_reviewable_translation_suggestions_by_offset
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_reviewable_translation_suggestions_by_offset(
Function update_question_contribution_stats_at_submission
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_question_contribution_stats_at_submission(
suggestion: suggestion_registry.BaseSuggestion
) -> None:
"""Creates/updates QuestionContributionStatsModel and
QuestionSubmitterTotalContributionStatsModel models for given question
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if translation_suggestion.author_id != (
user_contribution_rights.id):
heapq.heappush(suggestions_waiting_longest_heap, (
translation_suggestion.last_updated,
translation_suggestion))
Function _generate_translation_contributor_certificate_data
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _generate_translation_contributor_certificate_data(
language_code: str,
from_date: datetime.datetime,
to_date: datetime.datetime,
user_id: str
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if len(suggestions_waiting_longest_heap) == (
MAX_NUMBER_OF_SUGGESTIONS_TO_EMAIL_REVIEWER):
# The shortest review wait time corresponds to the most
# recent review submission date, which is the max of
# the heap.
Function increment_translation_review_stats
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def increment_translation_review_stats(
Function generate_contributor_certificate_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def generate_contributor_certificate_data(
Function get_submitted_suggestions_by_offset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_submitted_suggestions_by_offset(
Function get_submitted_suggestions_by_offset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_submitted_suggestions_by_offset(
Function increment_translation_reviewer_total_stats
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def increment_translation_reviewer_total_stats(
Function enqueue_contributor_ranking_notification_email_task
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def enqueue_contributor_ranking_notification_email_task(
Function get_submitted_suggestions_by_offset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_submitted_suggestions_by_offset(
Function get_submitted_suggestions_by_offset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_submitted_suggestions_by_offset(
Function get_reviewable_question_suggestions_by_offset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_reviewable_question_suggestions_by_offset(
Function get_reviewable_translation_suggestions_by_offset
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_reviewable_translation_suggestions_by_offset(
user_id: str,
opportunity_summary_exp_ids: Optional[List[str]],
limit: Optional[int],
offset: int,
- Read upRead up
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 reject_suggestions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def reject_suggestions(
suggestion_ids: List[str], reviewer_id: str, review_message: str
) -> None:
"""Rejects the suggestions with the given suggestion_ids.
- Read upRead up
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"