rosedu/wouso

View on GitHub

Showing 2,707 of 2,707 total issues

Avoid deeply nested control flow statements.
Open

                    for chunk in image.chunks():
                        fout.write(chunk)
            instance = form.save()
Severity: Major
Found in wouso/interface/cpanel/views.py - About 45 mins to fix

    Function add_user_no_matter_what has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def add_user_no_matter_what(username, first_name, last_name, email, password, cookie):
    Severity: Minor
    Found in wouso/utils/add_users_force.py - About 45 mins to fix

      Function add_question has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def add_question(question):
          """ question is a dictionary with the following keys:
              'text': the question text (string)
              'answer_type': whether the question is single choice or multiple choice (string)
              'answers': a dictionary of answers with the following keys:
      Severity: Minor
      Found in wouso/utils/add_questions.py - About 45 mins 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 main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          if len(sys.argv) != 2:
              print 'Usage: python remove_users.py <input-file>'
              print " Input file contains usernames, one per line."
              sys.exit(1)
      Severity: Minor
      Found in wouso/utils/remove_users.py - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function add_user_no_matter_what has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def add_user_no_matter_what(username, first_name, last_name, email, password, cookie):
      Severity: Minor
      Found in wouso/utils/add_users_force_to_race.py - About 45 mins to fix

        Function try_using_truncate has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def try_using_truncate(username, first_name, last_name, email, password, cookie):
        Severity: Minor
        Found in wouso/utils/add_users_force.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if karma_points == 0:
                                  continue
          
                              # Compute formula and calculate amount of bonus given
                              amount = eval(formula.expression.format(**{'karma_points': karma_points}).split('=')[1])
          Severity: Major
          Found in wouso/interface/cpanel/views.py - About 45 mins to fix

            Function update_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def update_user(username, first_name=None, last_name=None, email=None, password=None, is_active=None, is_staff=None, is_superuser=None):
                """Update user by username. Return True if successful. Return False if user
                does not exist.
                """
                user = User.objects.get(username=username)
            Severity: Minor
            Found in wouso/utils/user_util.py - About 45 mins 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 try_using_cookie_no_recurse has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def try_using_cookie_no_recurse(username, first_name, last_name, email, password, cookie):
            Severity: Minor
            Found in wouso/utils/add_users_force_to_race.py - About 45 mins to fix

              Function try_using_truncate has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def try_using_truncate(username, first_name, last_name, email, password, cookie):
              Severity: Minor
              Found in wouso/utils/add_users_force_to_race.py - About 45 mins to fix

                Function try_using_cookie has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def try_using_cookie(username, first_name, last_name, email, password, cookie):
                Severity: Minor
                Found in wouso/utils/add_users_force_to_race.py - About 45 mins to fix

                  Function import_questions_from_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def import_questions_from_file(f, proposed_by=None, endorsed_by=None, category=None, tag=None, active=False):
                  Severity: Minor
                  Found in wouso/utils/add_questions.py - About 45 mins to fix

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

                            this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
                    Severity: Minor
                    Found in wouso/resources/static/js/bootstrap.js and 1 other location - About 45 mins to fix
                    wouso/resources/static/js/bootstrap.js on lines 1164..1164

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 50.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

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

                    class DeleteTagView(DeleteView):
                        model = LessonTag
                        success_url = reverse_lazy('manage_lesson_tags')
                    
                        def get(self, *args, **kwargs):
                    Severity: Major
                    Found in wouso/interface/apps/lesson/cpanel_views.py and 8 other locations - About 45 mins to fix
                    wouso/games/quiz/cpanel_views.py on lines 41..46
                    wouso/games/quiz/cpanel_views.py on lines 84..89
                    wouso/interface/apps/files/cpanel_views.py on lines 41..46
                    wouso/interface/apps/files/cpanel_views.py on lines 84..89
                    wouso/interface/apps/lesson/cpanel_views.py on lines 71..76
                    wouso/interface/apps/lesson/cpanel_views.py on lines 114..119
                    wouso/interface/forum/cpanel_views.py on lines 47..52
                    wouso/interface/forum/cpanel_views.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 35.

                    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

                            challenges_played_week = Challenge.objects.filter(date__gte=week_start).filter(
                                Q(status='P') | Q(status='D'))
                    Severity: Minor
                    Found in wouso/interface/apps/statistics/views.py and 1 other location - About 45 mins to fix
                    wouso/games/challenge/models.py on lines 288..288

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

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

                    class DeleteForumView(DeleteView):
                        model = Forum
                        success_url = reverse_lazy('forum')
                    
                        def get(self, *args, **kwargs):
                    Severity: Major
                    Found in wouso/interface/forum/cpanel_views.py and 8 other locations - About 45 mins to fix
                    wouso/games/quiz/cpanel_views.py on lines 41..46
                    wouso/games/quiz/cpanel_views.py on lines 84..89
                    wouso/interface/apps/files/cpanel_views.py on lines 41..46
                    wouso/interface/apps/files/cpanel_views.py on lines 84..89
                    wouso/interface/apps/lesson/cpanel_views.py on lines 71..76
                    wouso/interface/apps/lesson/cpanel_views.py on lines 114..119
                    wouso/interface/apps/lesson/cpanel_views.py on lines 157..162
                    wouso/interface/forum/cpanel_views.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 35.

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

                    class DeleteCategoryView(DeleteView):
                        model = FileCategory
                        success_url = reverse_lazy('manage_file_categories')
                    
                        def get(self, *args, **kwargs):
                    Severity: Major
                    Found in wouso/interface/apps/files/cpanel_views.py and 8 other locations - About 45 mins to fix
                    wouso/games/quiz/cpanel_views.py on lines 41..46
                    wouso/games/quiz/cpanel_views.py on lines 84..89
                    wouso/interface/apps/files/cpanel_views.py on lines 41..46
                    wouso/interface/apps/lesson/cpanel_views.py on lines 71..76
                    wouso/interface/apps/lesson/cpanel_views.py on lines 114..119
                    wouso/interface/apps/lesson/cpanel_views.py on lines 157..162
                    wouso/interface/forum/cpanel_views.py on lines 47..52
                    wouso/interface/forum/cpanel_views.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 35.

                    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

                                self.fields['answer_%d' % i] = forms.CharField(max_length=100,
                                                        widget=forms.Textarea, required=False)
                    Severity: Minor
                    Found in wouso/interface/apps/qproposal/forms.py and 1 other location - About 45 mins to fix
                    wouso/interface/cpanel/forms.py on lines 34..35

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

                    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 post_cast has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def post_cast(sender, **kwargs):
                        """ Execute action after a spell is cast. This is used to implement specific spells
                        such as 'clean any existing spell' cast.
                    
                        Returns True if action has been taken, False if not.
                    Severity: Minor
                    Found in wouso/core/god/god.py - About 45 mins 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

                                self.fields['answer_%d' % i] = forms.CharField(max_length=500,
                                                                               widget=forms.Textarea, required=False)
                    Severity: Minor
                    Found in wouso/interface/cpanel/forms.py and 1 other location - About 45 mins to fix
                    wouso/interface/apps/qproposal/forms.py on lines 16..17

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

                    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