rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

Consider simplifying this complex logical expression.
Open

                if ( ( mappedTypes || origType === handleObj.origType ) &&
                    ( !handler || handler.guid === handleObj.guid ) &&
                    ( !tmp || tmp.test( handleObj.namespace ) ) &&
                    ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
                    handlers.splice( j, 1 );
Severity: Critical
Found in wouso/resources/static/js/jquery.js - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                    if ( ( mappedTypes || origType === handleObj.origType ) &&
                        ( !handler || handler.guid === handleObj.guid ) &&
                        ( !tmp || tmp.test( handleObj.namespace ) ) &&
                        ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
                        handlers.splice( j, 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

              if 'buy' in action:
                  # Check if player spent 500 gold on spells
                  if not player.magic.has_modifier('ach-spent-gold'):
                      if spent_gold(player) >= 500:
                          cls.earn_achievement(player, 'ach-spent-gold')
      Severity: Major
      Found in wouso/interface/activity/achievements.py and 1 other location - About 2 hrs to fix
      wouso/interface/activity/achievements.py on lines 393..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 50.

      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

              if 'gold' in action:
                  # Check if player has 300 gold
                  if not player.magic.has_modifier('ach-gold-300'):
                      if gold_amount(player) >= 300:
                          cls.earn_achievement(player, 'ach-gold-300')
      Severity: Major
      Found in wouso/interface/activity/achievements.py and 1 other location - About 2 hrs to fix
      wouso/interface/activity/achievements.py on lines 377..381

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

      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 test_grading has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def test_grading(self):
              p1 = self._get_player(1)
              p2 = self._get_player(2)
              semig = Semigroup.objects.create(day=datetime.today().day, hour=datetime.today().hour - datetime.today().hour % 2)
              semig.players.add(p1, p2)
      Severity: Minor
      Found in wouso/games/workshop/tests.py - About 2 hrs to fix

        Function slide has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          Carousel.prototype.slide = function (type, next) {
            var $active   = this.$element.find('.item.active')
            var $next     = next || $active[type]()
            var isCycling = this.interval
            var direction = type == 'next' ? 'left' : 'right'
        Severity: Minor
        Found in wouso/resources/static/js/bootstrap.js - About 1 hr to fix

          Function internalRemoveData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function internalRemoveData( elem, name, pvt ) {
              if ( !jQuery.acceptData( elem ) ) {
                  return;
              }
          
          
          Severity: Minor
          Found in wouso/resources/static/js/jquery.js - About 1 hr to fix

            Function internalRemoveData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function internalRemoveData( elem, name, pvt ) {
                if ( !jQuery.acceptData( elem ) ) {
                    return;
                }
            
            
            Severity: Minor
            Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 1 hr to fix

              Function get_specialquest_user_button has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_specialquest_user_button(kls, request, player):
                      specialquest_button = dict(MATE=False, OTHER=False,
                                                 ALREADY_INVITED=False, INIVTE=False)
                      if request.user.get_profile().id != player.id:
                          squser = request.user.get_profile().get_extension(SpecialQuestUser)
              Severity: Minor
              Found in wouso/games/specialquest/models.py - About 1 hr 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 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def add(question, answers, category=None, tags=None, file_tags=None):
                  ''' question is a dict with the following keys: text, endorsed_by, answer_type
                  [, proposed_by, active, type, code]
                  answers is a list of dicts with the following keys: text, correct [, explanation]
                  '''
              Severity: Minor
              Found in wouso/utils/import_questions.py - About 1 hr 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 infraction_recheck has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def infraction_recheck(request):
                  """ Rerun an infraction check on the current challenge history
              
                      The view should allow for other infraction additions. """
                  try:
              Severity: Minor
              Found in wouso/interface/cpanel/views.py - About 1 hr 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 create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def create(request, to=None, reply_to=None):
                  if to is not None:
                      to = get_object_or_404(Player, pk=to)
                  if reply_to is not None:
                      reply_to = get_object_or_404(Message, pk=reply_to)
              Severity: Minor
              Found in wouso/interface/apps/messaging/views.py - About 1 hr 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

                      for i in range(10):
                          timestamp=datetime.now() + timedelta(minutes = -1)
                          a = Message.objects.create(timestamp=timestamp, sender=player,receiver=player,subject = "a",text = "b")
              Severity: Major
              Found in wouso/interface/activity/tests.py and 1 other location - About 1 hr to fix
              wouso/interface/activity/tests.py on lines 458..460

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

              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

                  if not user_from.can_launch():
                      messages.error(request, _('You cannot launch another challenge today.'))
                      logging.info("Ready to unlock (cannot launch today).")
                      lock.unlock()
                      return redirect('challenge_index_view')
              Severity: Major
              Found in wouso/games/challenge/views.py and 1 other location - About 1 hr to fix
              wouso/games/challenge/views.py on lines 178..182

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

              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

                  if not user_from.has_enough_points():
                      messages.error(request, _('You need at least 30 points to launch a challenge'))
                      logging.info("Ready to unlock (not enough points).")
                      lock.unlock()
                      return redirect('challenge_index_view')
              Severity: Major
              Found in wouso/games/challenge/views.py and 1 other location - About 1 hr to fix
              wouso/games/challenge/views.py on lines 166..170

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

              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

              class LessonCategoryView(ListView):
                  """ Shows all tags related to the current category"""
                  model = LessonCategory
                  context_object_name = 'category'
                  template_name = 'lesson/category.html'
              Severity: Major
              Found in wouso/interface/apps/lesson/views.py and 1 other location - About 1 hr to fix
              wouso/interface/apps/lesson/views.py on lines 38..45

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

              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 set_inactive(self):
                      """ Same as activating, updates all Question objects with the
                      tag
                      """
                      if self.active is False:
              Severity: Major
              Found in wouso/core/qpool/models.py and 1 other location - About 1 hr to fix
              wouso/core/qpool/models.py on lines 29..37

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

              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

              class LessonTagView(ListView):
                  """ Shows all lessons related to the current category"""
                  model = LessonTag
                  context_object_name = 'tag'
                  template_name = 'lesson/tag.html'
              Severity: Major
              Found in wouso/interface/apps/lesson/views.py and 1 other location - About 1 hr to fix
              wouso/interface/apps/lesson/views.py on lines 25..32

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

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

                  try:
                      proposed_by = User.objects.get(username=proposed_by_name)
                  except Exception as e:
                      print e
                      print >>sys.stderr, "Proposed by user %s does not exist." %(proposed_by_name)
              Severity: Major
              Found in wouso/utils/add_questions.py and 3 other locations - About 1 hr to fix
              wouso/utils/add_questions.py on lines 215..220
              wouso/utils/add_questions.py on lines 225..230
              wouso/utils/add_questions.py on lines 235..240

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

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

                  try:
                      category = Category.objects.get(name=category_name)
                  except Exception as e:
                      print e
                      print >>sys.stderr, "Category %s does not exist." %(category_name)
              Severity: Major
              Found in wouso/utils/add_questions.py and 3 other locations - About 1 hr to fix
              wouso/utils/add_questions.py on lines 205..210
              wouso/utils/add_questions.py on lines 215..220
              wouso/utils/add_questions.py on lines 235..240

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

              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