rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

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

@permission_required('config.change_setting')
def qpool_delete(request, id):
    question = get_object_or_404(Question, pk=id)

    question.delete()
Severity: Major
Found in wouso/interface/cpanel/views.py and 5 other locations - About 3 hrs to fix
wouso/interface/cpanel/views.py on lines 129..136
wouso/interface/cpanel/views.py on lines 184..194
wouso/interface/cpanel/views.py on lines 812..822
wouso/interface/cpanel/views.py on lines 1201..1211
wouso/interface/cpanel/views.py on lines 1247..1257

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

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

        elif line[0] == '-' or line[0] == '+':
            if not a_saved:
                answers.append(a)
                a_saved = True

Severity: Major
Found in wouso/utils/import_questions.py and 1 other location - About 3 hrs to fix
wouso/utils/add_questions.py on lines 140..165

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

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

@permission_required('config.change_setting')
def del_static_page(request, pk):
    page = get_object_or_404(StaticPage, pk=pk)

    page.delete()
Severity: Major
Found in wouso/interface/cpanel/views.py and 5 other locations - About 3 hrs to fix
wouso/interface/cpanel/views.py on lines 129..136
wouso/interface/cpanel/views.py on lines 184..194
wouso/interface/cpanel/views.py on lines 518..528
wouso/interface/cpanel/views.py on lines 812..822
wouso/interface/cpanel/views.py on lines 1247..1257

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

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

@permission_required('config.change_setting')
def artifact_del(request, id):
    artifact = get_object_or_404(Artifact, pk=id)

    artifact.delete()
Severity: Major
Found in wouso/interface/cpanel/views.py and 5 other locations - About 3 hrs to fix
wouso/interface/cpanel/views.py on lines 129..136
wouso/interface/cpanel/views.py on lines 184..194
wouso/interface/cpanel/views.py on lines 518..528
wouso/interface/cpanel/views.py on lines 1201..1211
wouso/interface/cpanel/views.py on lines 1247..1257

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

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

@permission_required('config.change_setting')
def formula_delete(request, id):
    formula = get_object_or_404(Formula, pk=id)
    formula.delete()
    go_back = request.META.get('HTTP_REFERER', None)
Severity: Major
Found in wouso/interface/cpanel/views.py and 5 other locations - About 3 hrs to fix
wouso/interface/cpanel/views.py on lines 184..194
wouso/interface/cpanel/views.py on lines 518..528
wouso/interface/cpanel/views.py on lines 812..822
wouso/interface/cpanel/views.py on lines 1201..1211
wouso/interface/cpanel/views.py on lines 1247..1257

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

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

Challenge has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class Challenge(models.Model):
    STATUS = (
        ('L', 'Launched'),
        ('A', 'Accepted'),
        ('R', 'Refused'),
Severity: Minor
Found in wouso/games/challenge/models.py - About 3 hrs to fix

    Function bazaar_exchange has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def bazaar_exchange(request):
        gold_rate = scoring.calculate('gold-points-rate', gold=1)['points']
        points_rate = scoring.calculate('points-gold-rate', points=1)['gold']
    
        player = request.user.get_profile()
    Severity: Minor
    Found in wouso/interface/apps/magic/views.py - About 3 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 2 locations. Consider refactoring.
    Open

            for i in range(10):
                timestamp=datetime.now() + timedelta(days=-i)
                a = Activity.objects.create(timestamp=timestamp, user_from=player, user_to=player, action='qotd-correct',message_string=str(i),public=True)
    Severity: Major
    Found in wouso/interface/activity/tests.py and 1 other location - About 3 hrs to fix
    wouso/interface/activity/tests.py on lines 141..143

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

    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(3):
                timestamp=datetime.now() + timedelta(days=-i)
                a = Activity.objects.create(timestamp=timestamp, user_from=player, user_to=player, action='qotd-correct',message_string=str(i),public=True)
    Severity: Major
    Found in wouso/interface/activity/tests.py and 1 other location - About 3 hrs to fix
    wouso/interface/activity/tests.py on lines 159..161

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

    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_is_not_runnable_when_it_is_not_accepted(self):
            # Challenge is launched but not accepted
            self.ch.status = 'L'
            self.ch.save()
            response = self.c.get(reverse('view_challenge', args=[self.ch.id]), follow=True)
    Severity: Major
    Found in wouso/games/challenge/tests.py and 1 other location - About 3 hrs to fix
    wouso/games/challenge/tests.py on lines 476..481

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

    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_is_not_runnable_when_it_is_refused(self):
            # Challenge is refused
            self.ch.status = 'R'
            self.ch.save()
            response = self.c.get(reverse('view_challenge', args=[self.ch.id]), follow=True)
    Severity: Major
    Found in wouso/games/challenge/tests.py and 1 other location - About 3 hrs to fix
    wouso/games/challenge/tests.py on lines 469..474

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

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

        trigger: function( event, data, elem, onlyHandlers ) {
            var handle, ontype, cur,
                bubbleType, special, tmp, i,
                eventPath = [ elem || document ],
                type = hasOwn.call( event, "type" ) ? event.type : event,
    Severity: Major
    Found in wouso/resources/static/js/jquery.js - About 3 hrs to fix

      Function trigger has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          trigger: function( event, data, elem, onlyHandlers ) {
              var handle, ontype, cur,
                  bubbleType, special, tmp, i,
                  eventPath = [ elem || document ],
                  type = hasOwn.call( event, "type" ) ? event.type : event,
      Severity: Major
      Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 3 hrs to fix

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

          function Plugin(option) {
            return this.each(function () {
              var $this = $(this)
              var data  = $this.data('bs.alert')
        
        
        Severity: Major
        Found in wouso/resources/static/js/bootstrap.js and 1 other location - About 3 hrs to fix
        wouso/resources/static/js/bootstrap.js on lines 784..792

        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

          function Plugin(option) {
            return this.each(function () {
              var $this = $(this)
              var data  = $this.data('bs.dropdown')
        
        
        Severity: Major
        Found in wouso/resources/static/js/bootstrap.js and 1 other location - About 3 hrs to fix
        wouso/resources/static/js/bootstrap.js on lines 130..138

        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

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

        def truncate_username(username):
            parts = username.split('.')
            if len(parts) != 2:
                print >>sys.stderr, "Username %s should consist of two parts."
                return
        Severity: Major
        Found in wouso/utils/add_users_force.py and 1 other location - About 3 hrs to fix
        wouso/utils/add_users_force_to_race.py on lines 26..31

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

        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 truncate_username(username):
            parts = username.split('.')
            if len(parts) != 2:
                print >>sys.stderr, "Username %s should consist of two parts."
                return
        Severity: Major
        Found in wouso/utils/add_users_force_to_race.py and 1 other location - About 3 hrs to fix
        wouso/utils/add_users_force.py on lines 26..31

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

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

        from django.contrib import messages
        from django.template.loader import render_to_string
        from django.utils.translation import ugettext as _
        from django.core.urlresolvers import reverse
        from django.http import Http404
        Severity: Minor
        Found in wouso/games/challenge/views.py - About 3 hrs to fix

          Function clean has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def clean(self):
                  data = self.cleaned_data
                  num = IntegerSetting.get('question_number_of_answers').get_value()
          
                  # Check the question text. If the normal text is missing, check for the
          Severity: Minor
          Found in wouso/interface/cpanel/forms.py - About 3 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 8 locations. Consider refactoring.
          Open

              def __init__(self, *args, **kwargs):
                  # Set parent's fields
                  self._meta.get_field('verbose_name').default = "Challenges"
                  self._meta.get_field('short_name').default = ""
                  # the url field takes as value only a named url from module's urls.py
          Severity: Major
          Found in wouso/games/challenge/models.py and 7 other locations - About 3 hrs to fix
          wouso/games/grandchallenge/models.py on lines 181..187
          wouso/games/qotd/models.py on lines 87..93
          wouso/games/quest/models.py on lines 304..310
          wouso/games/specialchallenge/models.py on lines 103..107
          wouso/games/specialquest/models.py on lines 148..154
          wouso/games/quiz/models.py on lines 147..151
          wouso/games/workshop/models.py on lines 380..385

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

          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