Showing 5,889 of 5,889 total issues

File models.py has 1510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pylint: disable=too-many-lines; Allow more than 1000 lines
import datetime
import logging
import string
from typing import Collection, Iterable, List, Optional, Union
Severity: Major
Found in intranet/apps/eighth/models.py - About 4 days to fix

    Function schedule_activity_view has a Cognitive Complexity of 165 (exceeds 5 allowed). Consider refactoring.
    Open

    def schedule_activity_view(request):
        if request.method == "POST":
            formset = ScheduledActivityFormset(request.POST)
    
            if formset.is_valid():
    Severity: Minor
    Found in intranet/apps/eighth/views/admin/scheduling.py - About 3 days 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def test_lostitem_delete_view(self):
            self.login()
            user2 = get_user_model().objects.get_or_create(username="awilliam1")[0]
            item = LostItem.objects.create(user=user2, title="hellotest1", description="Hello", last_seen="3000-01-01")
    
    
    Severity: Major
    Found in intranet/apps/lostfound/tests.py and 1 other location - About 3 days to fix
    intranet/apps/lostfound/tests.py on lines 130..152

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 320.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        def test_founditem_delete_view(self):
            self.login()
            user2 = get_user_model().objects.get_or_create(username="awilliam1")[0]
            item = FoundItem.objects.create(user=user2, title="hellotest1", description="Hello", found="3000-01-01")
    
    
    Severity: Major
    Found in intranet/apps/lostfound/tests.py and 1 other location - About 3 days to fix
    intranet/apps/lostfound/tests.py on lines 55..77

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 320.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function add_user has a Cognitive Complexity of 150 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_user(
            self,
            user: "get_user_model()",
            request: Optional[HttpRequest] = None,
            force: bool = False,
    Severity: Minor
    Found in intranet/apps/eighth/models.py - About 3 days 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        editor.on("instanceReady", function () {
            // TODO: Don't duplicate this function. Bad!
            var text = editor.getData();
            dates = chrono.parse(text)
                .sort(function (a, b) {
    Severity: Major
    Found in intranet/static/js/announcement.form.js and 1 other location - About 2 days to fix
    intranet/static/js/announcement.form.js on lines 78..105

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 498.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        editor.on("change", function () {
            // TODO: Optimize by only parsing on new spaces
            var text = editor.getData();
            dates = chrono.parse(text)
                .sort(function (a, b) {
    Severity: Major
    Found in intranet/static/js/announcement.form.js and 1 other location - About 2 days to fix
    intranet/static/js/announcement.form.js on lines 49..76

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 498.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            $(window).on({
                "touchstart": function(e) {
                    initX = e.originalEvent.touches[0].clientX;
                    initY = e.originalEvent.touches[0].clientY;
                    listening = true;
    Severity: Major
    Found in intranet/static/js/schedule.js and 1 other location - About 2 days to fix
    intranet/static/js/common.nav.js on lines 21..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 490.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        $(window).on({
            "touchstart": function(e) {
                initX = e.originalEvent.touches[0].clientX;
                initY = e.originalEvent.touches[0].clientY;
                listening = true;
    Severity: Major
    Found in intranet/static/js/common.nav.js and 1 other location - About 2 days to fix
    intranet/static/js/schedule.js on lines 206..253

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 490.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File models.py has 1102 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # pylint: disable=too-many-lines; Allow more than 1000 lines
    import logging
    from base64 import b64encode
    from datetime import timedelta
    from typing import Collection, Dict, Optional, Union
    Severity: Major
    Found in intranet/apps/users/models.py - About 2 days to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def test_founditem_modify_view(self):
              self.login()
              user2 = get_user_model().objects.get_or_create(username="awilliam1")[0]
              item = FoundItem.objects.create(user=user2, title="hellotest1", description="Hello", found="3000-01-01")
      
      
      Severity: Major
      Found in intranet/apps/lostfound/tests.py and 1 other location - About 2 days to fix
      intranet/apps/lostfound/tests.py on lines 29..53

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 250.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def test_lostitem_modify_view(self):
              self.login()
              user2 = get_user_model().objects.get_or_create(username="awilliam1")[0]
              item = LostItem.objects.create(user=user2, title="hellotest1", description="Hello", last_seen="3000-01-01")
      
      
      Severity: Major
      Found in intranet/apps/lostfound/tests.py and 1 other location - About 2 days to fix
      intranet/apps/lostfound/tests.py on lines 104..128

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 250.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function poll_vote_view has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
      Open

      def poll_vote_view(request, poll_id):
          poll = get_object_or_404(Poll, id=poll_id)
      
          user = request.user
          is_polls_admin = user.has_admin_permission("polls")
      Severity: Minor
      Found in intranet/apps/polls/views.py - About 2 days 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 eighth_signup_view has a Cognitive Complexity of 111 (exceeds 5 allowed). Consider refactoring.
      Open

      def eighth_signup_view(request, block_id=None):
          start_time = time.time()
      
          if block_id is None and "block" in request.GET:
              block_ids = request.GET.getlist("block")
      Severity: Minor
      Found in intranet/apps/eighth/views/signup.py - About 2 days 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 query has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
      Open

      def query(q, admin=False):
          # If only a digit, search for student ID and user ID
          results = []
          if is_entirely_digit(q):
              results = list(get_user_model().objects.exclude_from_search().filter(Q(student_id=q) | Q(id=q)))
      Severity: Minor
      Found in intranet/apps/search/views.py - About 2 days 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def test_reject_event(self):
              event = Event.objects.create(title="Test Event", description="test", approved=False, time=timezone.localtime())
              event2 = Event.objects.create(title="Test Event2", description="test", approved=False, time=timezone.localtime())
      
              response = self.client.post(reverse("events"), data={"reject": event.id}, follow=True)
      Severity: Major
      Found in intranet/apps/events/tests.py and 1 other location - About 2 days to fix
      intranet/apps/events/tests.py on lines 332..346

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 222.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          def test_approve_event(self):
              event = Event.objects.create(title="Test Event", description="test", approved=False, time=timezone.localtime())
              event2 = Event.objects.create(title="Test Event2", description="test", approved=False, time=timezone.localtime())
      
              response = self.client.post(reverse("events"), data={"approve": event.id}, follow=True)
      Severity: Major
      Found in intranet/apps/events/tests.py and 1 other location - About 2 days to fix
      intranet/apps/events/tests.py on lines 348..362

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 222.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function files_type has a Cognitive Complexity of 97 (exceeds 5 allowed). Consider refactoring.
      Open

      def files_type(request, fstype=None):
          """Do all processing (directory listing, file downloads) for a given filesystem."""
          try:
              host = Host.objects.get(code=fstype)
          except Host.DoesNotExist:
      Severity: Minor
      Found in intranet/apps/files/views.py - About 1 day 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 edit_activity_view has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
      Open

      def edit_activity_view(request, activity_id):
          try:
              activity = EighthActivity.objects.get(id=activity_id)  # include deleted
          except EighthActivity.DoesNotExist as e:
              raise http.Http404 from e
      Severity: Minor
      Found in intranet/apps/eighth/views/admin/activities.py - About 1 day 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      @login_required
      @deny_restricted
      def founditem_modify_view(request, item_id=None):
          """
          Modify a FoundItem.
      Severity: Major
      Found in intranet/apps/lostfound/views.py and 1 other location - About 1 day to fix
      intranet/apps/lostfound/views.py on lines 65..93

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 195.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language