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:
Severity: Minor
Found in intranet/apps/users/models.py - About 25 mins 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 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")
Severity: Minor
Found in intranet/apps/polls/views.py - About 25 mins 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_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:
Severity: Minor
Found in intranet/apps/eighth/models.py - About 25 mins 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 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:
Severity: Minor
Found in intranet/apps/logs/admin.py - About 25 mins 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_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:
Severity: Minor
Found in intranet/apps/eighth/models.py - About 25 mins 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 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
Severity: Minor
Found in intranet/apps/users/models.py - About 25 mins 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 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"]
Severity: Minor
Found in intranet/apps/preferences/views.py - About 25 mins 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 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:]))
Severity: Minor
Found in intranet/apps/users/templatetags/phone_numbers.py - About 25 mins 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 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:
Severity: Minor
Found in intranet/apps/schedule/models.py - About 25 mins 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 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
Severity: Minor
Found in intranet/apps/users/tests.py - About 25 mins 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 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.
Severity: Minor
Found in intranet/apps/events/views.py - About 25 mins 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 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.
Severity: Minor
Found in intranet/apps/events/models.py - About 25 mins 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 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:
Severity: Minor
Found in intranet/apps/events/views.py - About 25 mins 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 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
Severity: Minor
Found in intranet/apps/itemreg/views.py - About 25 mins 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 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 = []
Severity: Minor
Found in intranet/apps/polls/views.py - About 25 mins 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