rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

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

def add_user_helper(username, first_name, last_name, email, password):
    """Helper function for adding user. Return value states wether operation
    completed successfully, and exception was encountered or use already
    existed.
    """
Severity: Major
Found in wouso/utils/add_users_force.py and 1 other location - About 5 hrs to fix
wouso/utils/add_users_force_to_race.py on lines 131..146

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

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

import unittest
from datetime import datetime, timedelta
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db import IntegrityError
Severity: Minor
Found in wouso/core/magic/tests.py - About 5 hrs to fix

    CpanelViewsTest has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CpanelViewsTest(WousoTest):
        def setUp(self):
            super(CpanelViewsTest, self).setUp()
            self.admin = self._get_superuser()
            self.client = Client()
    Severity: Minor
    Found in wouso/interface/cpanel/tests.py - About 5 hrs to fix

      Function Callbacks has 128 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      jQuery.Callbacks = function( options ) {
      
          // Convert options from String-formatted to Object-formatted if needed
          // (we check in cache first)
          options = typeof options === "string" ?
      Severity: Major
      Found in wouso/resources/static/js/jquery.js - About 5 hrs to fix

        Function Callbacks has 128 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        jQuery.Callbacks = function( options ) {
        
            // Convert options from String-formatted to Object-formatted if needed
            // (we check in cache first)
            options = typeof options === "string" ?
        Severity: Major
        Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 5 hrs to fix

          Function main has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

          def main():
              """In main, parse command line arguments and call corresponding functions.
              """
          
              parser = argparse.ArgumentParser()
          Severity: Minor
          Found in wouso/utils/user_util.py - About 5 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

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

                  for i in range(1, 10):
                      timestamp = datetime.now()
                      if (i % 4) == 0:
                          Activity.objects.create(timestamp=timestamp,
                                  user_from=player, user_to=player,
          Severity: Major
          Found in wouso/interface/activity/tests.py and 1 other location - About 5 hrs to fix
          wouso/interface/activity/tests.py on lines 413..420

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

          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 in range(1, 10):
                      timestamp = datetime.now()
                      if (i % 4) == 0:
                          Activity.objects.create(timestamp=timestamp,
                                  user_from=player, user_to=player,
          Severity: Major
          Found in wouso/interface/activity/tests.py and 1 other location - About 5 hrs to fix
          wouso/interface/activity/tests.py on lines 398..405

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

          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

          Consider simplifying this complex logical expression.
          Open

                      if ( event.pageX == null && original.clientX != null ) {
                          eventDoc = event.target.ownerDocument || document;
                          doc = eventDoc.documentElement;
                          body = eventDoc.body;
          
          
          Severity: Critical
          Found in wouso/resources/static/js/jquery.js - About 5 hrs to fix

            Function cb has 125 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function cb(e) {
                        if (xhr.aborted || callbackProcessed) {
                            return;
                        }
                        try {
            Severity: Major
            Found in wouso/resources/static/js/jquery.form.js - About 5 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                          if ( event.pageX == null && original.clientX != null ) {
                              eventDoc = event.target.ownerDocument || document;
                              doc = eventDoc.documentElement;
                              body = eventDoc.body;
              
              
              Severity: Critical
              Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 5 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.popover')
                      var options = typeof option == 'object' && option
                Severity: Major
                Found in wouso/resources/static/js/bootstrap.js and 1 other location - About 4 hrs to fix
                wouso/resources/static/js/bootstrap.js on lines 1531..1541

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

                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.tooltip')
                      var options = typeof option == 'object' && option
                Severity: Major
                Found in wouso/resources/static/js/bootstrap.js and 1 other location - About 4 hrs to fix
                wouso/resources/static/js/bootstrap.js on lines 1645..1655

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

                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 self.challenge.user_to.score > self.challenge.user_from.score:
                            result = (self.challenge.user_to, self.challenge.user_from)
                        elif self.challenge.user_from.score > self.challenge.user_to.score:
                            result = (self.challenge.user_from, self.challenge.user_to)
                        else: #draw game
                Severity: Major
                Found in wouso/games/specialchallenge/models.py and 1 other location - About 4 hrs to fix
                wouso/games/challenge/models.py on lines 616..621

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

                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 self.challenge.user_to.score > self.challenge.user_from.score:
                            result = (self.challenge.user_to, self.challenge.user_from)
                        elif self.challenge.user_from.score > self.challenge.user_to.score:
                            result = (self.challenge.user_from, self.challenge.user_to)
                        else:  # draw game
                Severity: Major
                Found in wouso/games/challenge/models.py and 1 other location - About 4 hrs to fix
                wouso/games/specialchallenge/models.py on lines 84..89

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

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

                from django import forms
                from django.shortcuts import render_to_response, redirect, get_object_or_404
                from django.template.context import RequestContext
                from django.views.generic import View, ListView, UpdateView, CreateView, \
                    DetailView
                Severity: Minor
                Found in wouso/games/workshop/cpanel.py - About 4 hrs to fix

                  Function remove has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                  Open

                          remove: function(element, label, fn) {
                              var timers = element.$timers, ret;
                              
                              if ( timers ) {
                                  
                  Severity: Minor
                  Found in wouso/resources/static/js/jquery.timers.js - About 4 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

                  def remove_user_from_race(username, race_name):
                      """Remove user from race. Return True if successful. Return False if user
                      or race does not exist. Race is actually non important. It will simply be
                      set to None."""
                      player = Player.objects.get(user__username=username)
                  Severity: Major
                  Found in wouso/utils/user_util.py and 1 other location - About 4 hrs to fix
                  wouso/utils/user_util.py on lines 200..212

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

                  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 PlayerSpellAmount(models.Model):
                      """ Tie spells to collecting user """
                      class Meta:
                          unique_together = ('player', 'spell')
                      player = models.ForeignKey('user.Player')
                  Severity: Major
                  Found in wouso/core/magic/models.py and 1 other location - About 4 hrs to fix
                  wouso/core/magic/models.py on lines 200..209

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

                  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 PlayerArtifactAmount(models.Model):
                      """ Tie artifact and amount to the owner user """
                      class Meta:
                          unique_together = ('player', 'artifact')
                      player = models.ForeignKey('user.Player')
                  Severity: Major
                  Found in wouso/core/magic/models.py and 1 other location - About 4 hrs to fix
                  wouso/core/magic/models.py on lines 212..221

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

                  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