rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

Consider simplifying this complex logical expression.
Open

                        if ( forward && useCache ) {
                            // Seek `elem` from a previously-cached index
                            outerCache = parent[ expando ] || (parent[ expando ] = {});
                            cache = outerCache[ type ] || [];
                            nodeIndex = cache[0] === dirruns && cache[1];
Severity: Critical
Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 2 hrs to fix

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

    @staff_required
    def grandchalls_hard_reset(request):
        if request.method == 'POST':
            GrandChallengeGame.reset()
            return redirect('grandchalls')
    Severity: Major
    Found in wouso/games/grandchallenge/cpanel_views.py and 1 other location - About 2 hrs to fix
    wouso/games/grandchallenge/cpanel_views.py on lines 16..22

    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 54.

    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 3 locations. Consider refactoring.
    Open

        def setUp(self):
            super(ForumViewsTest, self).setUp()
            self.admin = self._get_superuser()
            self.client = Client()
            self.client.login(username='admin', password='admin')
    Severity: Major
    Found in wouso/interface/forum/tests.py and 2 other locations - About 2 hrs to fix
    wouso/interface/cpanel/tests.py on lines 38..42
    wouso/games/workshop/tests.py on lines 135..139

    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 54.

    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

    Severity: Major
    Found in wouso/interface/forum/admin.py and 1 other location - About 2 hrs to fix
    wouso/games/specialquest/admin.py on lines 0..8

    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 54.

    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

    Severity: Major
    Found in wouso/games/specialquest/admin.py and 1 other location - About 2 hrs to fix
    wouso/interface/forum/admin.py on lines 0..8

    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 54.

    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 3 locations. Consider refactoring.
    Open

        def setUp(self):
            super(CpanelViewsTest, self).setUp()
            self.admin = self._get_superuser()
            self.client = Client()
            self.client.login(username='admin', password='admin')
    Severity: Major
    Found in wouso/interface/cpanel/tests.py and 2 other locations - About 2 hrs to fix
    wouso/games/workshop/tests.py on lines 135..139
    wouso/interface/forum/tests.py on lines 9..13

    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 54.

    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 3 locations. Consider refactoring.
    Open

        def setUp(self):
            super(TestWorkshopViews, self).setUp()
            self.admin = self._get_superuser()
            self.c = Client()
            self.c.login(username='admin', password='admin')
    Severity: Major
    Found in wouso/games/workshop/tests.py and 2 other locations - About 2 hrs to fix
    wouso/interface/cpanel/tests.py on lines 38..42
    wouso/interface/forum/tests.py on lines 9..13

    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 54.

    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

    @staff_required
    def grandchalls_round_next(request):
        if request.method == 'POST':
            GrandChallengeGame.round_next()
            return redirect('grandchalls')
    Severity: Major
    Found in wouso/games/grandchallenge/cpanel_views.py and 1 other location - About 2 hrs to fix
    wouso/games/grandchallenge/cpanel_views.py on lines 35..41

    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 54.

    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

                if (options.formatItem) {
                    li.innerHTML = options.formatItem(row, i, num);
                    li.selectValue = row[0];
                } else {
                    li.innerHTML = row[0];
    Severity: Major
    Found in wouso/resources/static/js/jquery.autocomplete.js and 1 other location - About 2 hrs to fix
    wouso/resources/static/js/jquery.autocomplete.js on lines 455..461

    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 81.

    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

                    if (options.formatItem) {
                        li.innerHTML = options.formatItem(row, i, num);
                        li.selectValue = row[0];
                    } else {
                        li.innerHTML = row[0];
    Severity: Major
    Found in wouso/resources/static/js/jquery.autocomplete.js and 1 other location - About 2 hrs to fix
    wouso/resources/static/js/jquery.autocomplete.js on lines 324..330

    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 81.

    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 views.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import datetime
    import logging
    from django.conf import settings
    from django.contrib.auth import authenticate, login, logout
    from django.contrib.auth.models import User
    Severity: Minor
    Found in wouso/interface/views.py - About 2 hrs to fix

      Function add has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

              add: function(element, interval, label, fn, times, belay) {
                  var counter = 0;
                  
                  if (jQuery.isFunction(label)) {
                      if (!times) 
      Severity: Minor
      Found in wouso/resources/static/js/jquery.timers.js - 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 karma_group_view has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def karma_group_view(request, id):
          group = get_object_or_404(PlayerGroup, pk=id)
          players = group.players.all()
      
          if request.method == 'POST':
      Severity: Minor
      Found in wouso/interface/cpanel/views.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

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

          def test_no_correct_and_partial_wrong(self):
              q = self.get_question(4, 3)
              post = self.fake_answers(q, 0, 2)
              self.assertEqual(Challenge._calculate_points(post)['points'], 0)
      Severity: Major
      Found in wouso/games/challenge/tests.py and 5 other locations - About 2 hrs to fix
      wouso/games/challenge/tests.py on lines 369..372
      wouso/games/challenge/tests.py on lines 374..377
      wouso/games/challenge/tests.py on lines 379..382
      wouso/games/challenge/tests.py on lines 389..392
      wouso/games/challenge/tests.py on lines 394..397

      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 53.

      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 6 locations. Consider refactoring.
      Open

          def test_full_wrong(self):
              q = self.get_question(4, 3)
              post = self.fake_answers(q, 0, 3)
              self.assertEqual(Challenge._calculate_points(post)['points'], 0)
      Severity: Major
      Found in wouso/games/challenge/tests.py and 5 other locations - About 2 hrs to fix
      wouso/games/challenge/tests.py on lines 369..372
      wouso/games/challenge/tests.py on lines 374..377
      wouso/games/challenge/tests.py on lines 379..382
      wouso/games/challenge/tests.py on lines 384..387
      wouso/games/challenge/tests.py on lines 394..397

      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 53.

      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 6 locations. Consider refactoring.
      Open

          def test_partial_correct_no_wrong(self):
              q = self.get_question(4, 3)
              post = self.fake_answers(q, 2, 0)
              self.assertEqual(Challenge._calculate_points(post)['points'], 50)
      Severity: Major
      Found in wouso/games/challenge/tests.py and 5 other locations - About 2 hrs to fix
      wouso/games/challenge/tests.py on lines 374..377
      wouso/games/challenge/tests.py on lines 379..382
      wouso/games/challenge/tests.py on lines 384..387
      wouso/games/challenge/tests.py on lines 389..392
      wouso/games/challenge/tests.py on lines 394..397

      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 53.

      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 artifact has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def artifact(artifact):
          if not artifact:
              return '(no artifact)'
      
          if isinstance(artifact, PlayerArtifactAmount):
      Severity: Minor
      Found in wouso/core/magic/templatetags/artifacts.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

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

          def test_full_correct_no_wrong(self):
              q = self.get_question(4, 3)
              post = self.fake_answers(q, 4, 0)
              self.assertEqual(Challenge._calculate_points(post)['points'], 100)
      Severity: Major
      Found in wouso/games/challenge/tests.py and 5 other locations - About 2 hrs to fix
      wouso/games/challenge/tests.py on lines 369..372
      wouso/games/challenge/tests.py on lines 379..382
      wouso/games/challenge/tests.py on lines 384..387
      wouso/games/challenge/tests.py on lines 389..392
      wouso/games/challenge/tests.py on lines 394..397

      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 53.

      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 grandchalls_round has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def grandchalls_round(request):
          """ Play a round """
          # TODO: move logic to models.
          """ regular round """
          over = 0
      Severity: Minor
      Found in wouso/games/grandchallenge/cpanel_views.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

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

          def test_all_answers(self):
              q = self.get_question(4, 3)
              post = self.fake_answers(q, 4, 3)
              self.assertEqual(Challenge._calculate_points(post)['points'], 0)
      Severity: Major
      Found in wouso/games/challenge/tests.py and 5 other locations - About 2 hrs to fix
      wouso/games/challenge/tests.py on lines 369..372
      wouso/games/challenge/tests.py on lines 374..377
      wouso/games/challenge/tests.py on lines 379..382
      wouso/games/challenge/tests.py on lines 384..387
      wouso/games/challenge/tests.py on lines 389..392

      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 53.

      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