rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

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

    try:
        tag = Tag.objects.get(name=tag_name)
    except Exception as e:
        print e
        print >>sys.stderr, "Tag %s does not exist." %(tag_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 225..230

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_active(self):
        """ Activating a tag implies activating all the Question objects
        having this tag.
        """
        if self.active is True:
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 39..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 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:
        endorsed_by = User.objects.get(username=endorsed_by_name)
    except Exception as e:
        print e
        print >>sys.stderr, "Endorsed by user %s does not exist." %(endorsed_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 205..210
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 2 locations. Consider refactoring.
Open

            if i <= 3:
                timestamp = datetime.now() + timedelta(minutes=-10)
                a = Message.objects.create(timestamp=timestamp, sender=player,receiver=user_to,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 440..442

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

Function select has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

select = Sizzle.select = function( selector, context, results, seed ) {
    var i, tokens, token, type, find,
        compiled = typeof selector === "function" && selector,
        match = !seed && tokenize( (selector = compiled.selector || selector) );

Severity: Minor
Found in wouso/resources/static/js/jquery.js - About 1 hr to fix

    Function internalData has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function internalData has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
          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 select has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        select = Sizzle.select = function( selector, context, results, seed ) {
            var i, tokens, token, type, find,
                compiled = typeof selector === "function" && selector,
                match = !seed && tokenize( (selector = compiled.selector || selector) );
        
        
        Severity: Minor
        Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 1 hr to fix

          Function tokenize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
              var matched, match, tokens, type,
                  soFar, groups, preFilters,
                  cached = tokenCache[ selector + " " ];
          
          
          Severity: Minor
          Found in wouso/resources/static/js/jquery.js - About 1 hr to fix

            Function tokenize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
                var matched, match, tokens, type,
                    soFar, groups, preFilters,
                    cached = tokenCache[ selector + " " ];
            
            
            Severity: Minor
            Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 1 hr to fix

              Function matcherFromTokens has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function matcherFromTokens( tokens ) {
                  var checkContext, matcher, j,
                      len = tokens.length,
                      leadingRelative = Expr.relative[ tokens[0].type ],
                      implicitRelative = leadingRelative || Expr.relative[" "],
              Severity: Minor
              Found in wouso/resources/static/js/jquery.js - About 1 hr to fix

                Function matcherFromTokens has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function matcherFromTokens( tokens ) {
                    var checkContext, matcher, j,
                        len = tokens.length,
                        leadingRelative = Expr.relative[ tokens[0].type ],
                        implicitRelative = leadingRelative || Expr.relative[" "],
                Severity: Minor
                Found in wouso/resources/static/js/jquery-1.11.1.min.js - About 1 hr to fix

                  Function propose has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def propose(request):
                  
                      MAX_ANSWERS = 6
                  
                      if request.method == 'POST':
                  Severity: Minor
                  Found in wouso/interface/apps/qproposal/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 question_switch has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def question_switch(request, id):
                      """ Accept a proposed question """
                      question = get_object_or_404(Question, pk=id)
                  
                      # qproposal - endorse part
                  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 management_task has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def management_task(cls, now=None, stdout=sys.stdout):
                          now = now if now is not None else datetime.now()
                          today = now.date()
                  
                          # Global ladder
                  Severity: Minor
                  Found in wouso/interface/top/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 setup_create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def setup_create(request):
                      user = request.user.get_profile().get_extension(SpecialQuestUser)
                      group = user.group
                      error = ''
                      if group is not None:
                  Severity: Minor
                  Found in wouso/games/specialquest/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 save has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def save(self, commit=True):
                          new = self.instance.pk is None
                          question = super(QuestionForm, self).save(commit=commit)
                          if new:
                              for i in range(self.DEFAULT_ANSWERS):
                  Severity: Minor
                  Found in wouso/games/specialchallenge/forms.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 handle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def handle(self, *args, **options):
                          save_load_labels = ['magic', 'scoring.coin', 'scoring.formula', 'config', 'pages', 'user.race', 'user.playergroup']
                          reset_labels = ['magic', 'scoring', 'config', 'pages']
                          if options['check_setup']:
                              ok = True
                  Severity: Minor
                  Found in wouso/core/game/management/commands/wousoctl.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

                          return dict(first_name=player.user.first_name, last_name=player.user.last_name, id=player.id, points=player.points,
                                      level=player.level_no, avatar=player_avatar(player), display_name=unicode(player))
                  Severity: Major
                  Found in wouso/interface/api/handlers.py and 1 other location - About 1 hr to fix
                  wouso/interface/api/handlers.py on lines 479..480

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

                  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, u in enumerate(pr.player_set.all().order_by('-points')):
                                  hs = NewHistory.record(u, today, relative_to=pr)
                                  hs.position, hs.points = i + 1, u.points
                                  hs.save()
                  Severity: Major
                  Found in wouso/interface/top/models.py and 1 other location - About 1 hr to fix
                  wouso/interface/top/models.py on lines 281..284

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

                  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