rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

Function import_questions_from_file has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

def import_questions_from_file(f, proposed_by=None, endorsed_by=None, category=None, tag=None, active=False):
    # read file and parse contents
    a_saved = True
    q_saved = True
    a = {}
Severity: Minor
Found in wouso/utils/add_questions.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

File tests.py has 484 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import unittest
from datetime import datetime,timedelta
from mock import patch
from django.contrib.auth.models import User
Severity: Minor
Found in wouso/games/challenge/tests.py - About 7 hrs to fix

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

        def test_challenge_cannot_be_submitted_when_it_is_not_accepted(self):
            self.ch.status = 'L'
            self.ch.save()
            # Submit the challenge
            data = {self.question1.id: [u'answer_%d' %(self.answer1.id)],
    Severity: Major
    Found in wouso/games/challenge/tests.py and 1 other location - About 6 hrs to fix
    wouso/games/challenge/tests.py on lines 524..531

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

    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_challenge_cannot_be_submitted_when_it_is_refused(self):
            self.ch.status = 'R'
            self.ch.save()
            # Submit the challenge
            data = {self.question1.id: [u'answer_%d' %(self.answer1.id)],
    Severity: Major
    Found in wouso/games/challenge/tests.py and 1 other location - About 6 hrs to fix
    wouso/games/challenge/tests.py on lines 515..522

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

    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

                for i in xrange(1, IntegerSetting.get('question_number_of_answers').get_value() + 1):
                    a = Answer.objects.create(question=self.instance)
                    a.text = data['answer_%d' % i]
                    a.correct = data['correct_%d' % i]
                    a.active = data['active_%d' % i]
    Severity: Major
    Found in wouso/interface/cpanel/forms.py and 1 other location - About 6 hrs to fix
    wouso/interface/cpanel/forms.py on lines 99..104

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

    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

                for i in xrange(1, IntegerSetting.get('question_number_of_answers').get_value() + 1):
                    a = Answer.objects.create(question=self.instance)
                    a.rich_text = data['rich_answer_%d' % i]
                    a.correct = data['rich_correct_%d' % i]
                    a.active = data['rich_active_%d' % i]
    Severity: Major
    Found in wouso/interface/cpanel/forms.py and 1 other location - About 6 hrs to fix
    wouso/interface/cpanel/forms.py on lines 90..95

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

    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

            for i in range(1, 7):
                timestamp = datetime.now() + timedelta(days=-i)
                if (i % 4) == 0:
                    a = Activity.objects.create(timestamp=timestamp,
                    user_from=player1, user_to=player2, action='chall-refused',
    Severity: Major
    Found in wouso/interface/activity/tests.py and 1 other location - About 6 hrs to fix
    wouso/interface/activity/tests.py on lines 260..267

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

    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

    def try_using_index_no_recurse(username, first_name, last_name, email, password):
        ret = OP_EXISTS
        for i in range(1,100):
            _username = username+"%d" %(i)
            ret = add_user_helper(_username, first_name, last_name, email, password)
    Severity: Major
    Found in wouso/utils/add_users_force.py and 1 other location - About 6 hrs to fix
    wouso/utils/add_users_force_to_race.py on lines 14..24

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

    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

    def try_using_index_no_recurse(username, first_name, last_name, email, password):
        ret = OP_EXISTS
        for i in range(1,100):
            _username = username+"%d" %(i)
            ret = add_user_helper(_username, first_name, last_name, email, password)
    Severity: Major
    Found in wouso/utils/add_users_force_to_race.py and 1 other location - About 6 hrs to fix
    wouso/utils/add_users_force.py on lines 14..24

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

    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

            for i in range(1, 100):
                timestamp = datetime.now() + timedelta(days=-i)
                if i % 5 == 0:
                    a = Activity.objects.create(timestamp=timestamp,
                        user_from=player, user_to=player, action='chall-draw',
    Severity: Major
    Found in wouso/interface/activity/tests.py and 1 other location - About 6 hrs to fix
    wouso/interface/activity/tests.py on lines 315..322

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

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

    from math import ceil
    from random import shuffle
    from datetime import datetime, time, timedelta
    from django.db import models
    from django.template.loader import render_to_string
    Severity: Minor
    Found in wouso/games/workshop/models.py - About 6 hrs to fix

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

          def _get_foo_question(self, correct=2):
              """ Return a Question object selected for Today """
              class Question: pass
              class Answer: pass
              q = Question()
      Severity: Major
      Found in wouso/games/qotd/tests.py and 1 other location - About 6 hrs to fix
      wouso/games/challenge/tests.py on lines 36..47

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

      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 _get_foo_question(self, correct=2):
              """ Return a Question """
              class Question: pass
              class Answer: pass
              q = Question()
      Severity: Major
      Found in wouso/games/challenge/tests.py and 1 other location - About 6 hrs to fix
      wouso/games/qotd/tests.py on lines 22..33

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

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

      from django.core.cache import cache
      import unittest
      from datetime import datetime
      from django.contrib.auth.models import User, Group, Permission
      from django.contrib.contenttypes.models import ContentType
      Severity: Minor
      Found in wouso/interface/cpanel/tests.py - About 6 hrs to fix

        File handlers.py has 435 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from datetime import datetime, timedelta
        from django.shortcuts import get_object_or_404
        from django.template.defaultfilters import slugify
        from django.utils.html import strip_tags
        from piston.handler import BaseHandler
        Severity: Minor
        Found in wouso/interface/api/handlers.py - About 6 hrs to fix

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

                  for i, u in enumerate(Player.objects.all().order_by('-points')):
                      topuser = u.get_extension(TopUser)
                      position = i + 1
                      hs, created = History.objects.get_or_create(user=topuser, date=datetime.now().date(), relative_to=None)
                      hs.position, hs.points = position, u.points
          Severity: Major
          Found in wouso/games/challenge/tests.py and 1 other location - About 6 hrs to fix
          wouso/games/challenge/tests.py on lines 214..219

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

          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

          def add_user_no_matter_what(username, first_name, last_name, email, password, cookie):
              _ret = add_user_helper(username, first_name, last_name, email, password)
          
              # Assume everything went OK.
              ret = True
          Severity: Major
          Found in wouso/utils/add_users_force_to_race.py and 1 other location - About 6 hrs to fix
          wouso/utils/add_users_force.py on lines 149..166

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

          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/quest/cpanel_urls.py and 1 other location - About 6 hrs to fix
          wouso/games/grandchallenge/cpanel_urls.py on lines 0..12

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

          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

                  for i, u in enumerate(Player.objects.all().order_by('-points')):
                      topuser = u.get_extension(TopUser)
                      position = i + 1
                      hs, created = History.objects.get_or_create(user=topuser, date=datetime.now().date(), relative_to=None)
                      hs.position, hs.points = position, u.points
          Severity: Major
          Found in wouso/games/challenge/tests.py and 1 other location - About 6 hrs to fix
          wouso/games/challenge/tests.py on lines 248..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 103.

          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

          def add_user_no_matter_what(username, first_name, last_name, email, password, cookie):
              _ret = add_user_helper(username, first_name, last_name, email, password)
          
              # Assume everything went OK.
              ret = True
          Severity: Major
          Found in wouso/utils/add_users_force.py and 1 other location - About 6 hrs to fix
          wouso/utils/add_users_force_to_race.py on lines 149..166

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

          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