Showing 515 of 5,889 total issues
Function _current_user_override
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _current_user_override(self) -> bool:
"""Return whether the currently logged in user is a teacher, and can view all of a student's
information regardless of their privacy settings.
Returns:
- 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 handle_rank_choice
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_rank_choice(q, show_answers=False):
# For some reason, this seems to be faster than select_related("question", "user", "choice")
question_votes = votes = Answer.objects.filter(question=q).select_related()
choices = []
c_set = q.choice_set.all().order_by("num")
- 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_viewable_members
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _get_viewable_members(
self, user: "get_user_model()"
) -> Union[QuerySet, Collection["get_user_model()"]]: # pylint: disable=unsubscriptable-object
"""Get an unsorted QuerySet of the members that you have permission to view.
Args:
- 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 lookups
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def lookups(self, request, model_admin):
# from ...urls import urlpatterns
# urlpatterns = [url for url in urlpatterns]
# return list(zip(urlpatterns, gettext_lazy(urlpatterns)))
if not self.url_paths_looked_up:
- 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_hidden_members
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_hidden_members(
self, user: "get_user_model()" = None
) -> Union[QuerySet, Collection["get_user_model()"]]: # pylint: disable=unsubscriptable-object
"""Returns a QuerySet of the members that you do not have permission to view.
Args:
- 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 recommended_activities
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def recommended_activities(self):
key = "{}:recommended_activities".format(self.username)
cached = cache.get(key)
if cached is not None:
return cached
- 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 save_dark_mode_settings
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def save_dark_mode_settings(request, user):
dark_mode_form = DarkModeForm(user, data=request.POST, initial={"dark_mode_enabled": user.dark_mode_properties.dark_mode_enabled})
if dark_mode_form.is_valid():
if dark_mode_form.has_changed():
user.dark_mode_properties.dark_mode_enabled = dark_mode_form.cleaned_data["dark_mode_enabled"]
- 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 dashes
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def dashes(phone):
"""Returns the phone number formatted with dashes."""
if isinstance(phone, str):
if phone.startswith("+1"):
return "1-" + "-".join((phone[2:5], phone[5:8], phone[8:]))
- 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 class_name
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def class_name(self):
n = self.name.lower()
t = "other"
if "blue day" in n or "mod blue" in n:
- 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 test_profile_view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def test_profile_view(self):
user = self.login()
with self.settings(YEAR_TURNOVER_MONTH=(timezone.localtime() + timezone.timedelta(days=70)).month):
# Test very plain view of own profile
- 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 add_event_view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_event_view(request):
"""Add event page.
An events administrator can create an event directly without
approval.
- 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 show_fuzzy_date
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show_fuzzy_date(self):
"""Checks whether the event is in the next or previous 2 weeks.
Returns:
Whether to display the fuzzy date.
- 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 modify_event_view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def modify_event_view(request, event_id):
"""Modify event page. You may only modify an event if you are an
administrator.
Args:
- 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 register_view
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def register_view(request, item_type):
"""Register an item."""
registration_types = {"calculator": CalculatorRegistrationForm, "computer": ComputerRegistrationForm, "phone": PhoneRegistrationForm}
if item_type not in registration_types:
raise http.Http404
- 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 handle_choice
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_choice(q, show_answers=False):
question_votes = votes = Answer.objects.filter(question=q)
total_count = question_votes.count()
users = q.get_users_voted()
choices = []
- 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"