CiviWiki/OpenCiviWiki

View on GitHub

Showing 22,315 of 22,315 total issues

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

        if (target.hasClass('btn') || target.hasClass('rating-button') || target.is('input') || target.is('textarea') || target.is('label') || target.hasClass('input') || ms_check) {
Severity: Major
Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
project/core/templates/static/js/thread.js on lines 1933..1933

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

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

    renderCivis: function () {
        this.$('#thread-problems').empty();
        this.$('#thread-causes').empty();
        this.$('#thread-solutions').empty();

Severity: Minor
Found in project/core/templates/static/js/thread.js - About 1 hr to fix

    Function success has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                    success: function (response) {
                        var attachment_input = _this.$('#response_attachment_image');
                        var uploaded_images = attachment_input[0].files;
                        if (_this.attachmentCount > 0) {
                            var formData = new FormData(_this.$('#response_attachment_image_form')[0]);
    Severity: Minor
    Found in project/core/templates/static/js/thread.js - About 1 hr to fix

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

                          } else {
                              Materialize.toast('New response created.', 5000);
                              _this.options.parentView.responseCollection.fetch();
                              _this.options.parentView.renderResponses();
                              _this.$el.empty();
      Severity: Major
      Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
      project/core/templates/static/js/thread.js on lines 1028..1033

      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

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

                                  success: function (response2) {
                                      Materialize.toast('New response created.', 5000);
                                      _this.options.parentView.responseCollection.fetch();
                                      _this.options.parentView.renderResponses();
                                      _this.$el.empty();
      Severity: Major
      Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
      project/core/templates/static/js/thread.js on lines 1046..1051

      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

              count.totalRec = this.civiRecViewTotals.problem + this.civiRecViewTotals.cause + this.civiRecViewTotals.solution - recCount.problem - recCount.cause - recCount.solution;
      Severity: Major
      Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
      project/core/templates/static/js/thread.js on lines 1604..1604

      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

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

              count.totalOther = this.civiOtherViewTotals.problem + this.civiOtherViewTotals.cause + this.civiOtherViewTotals.solution - recCount.problem - otherCount.cause - otherCount.solution;
      Severity: Major
      Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
      project/core/templates/static/js/thread.js on lines 1603..1603

      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

      Function create_civi has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_civi(request):
          """
          USAGE:
              Use this function to insert a new connected civi into the database.
      
      
      Severity: Minor
      Found in project/threads/api.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 render_notifications has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var render_notifications = function(data) {
          var unreadCount = parseInt(data.unread_count);
          if (unreadCount === 0) {
              $('#notify-count-wrapper').addClass('hide');
              $('#notify-icon').html('notifications_none').removeClass('active');
      Severity: Minor
      Found in project/core/templates/static/js/notifications.js - About 1 hr to fix

        Function clickRating has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            clickRating: function (e) {
                e.stopPropagation();
                var _this = this;
                var $this = $(e.currentTarget);
        
        
        Severity: Minor
        Found in project/core/templates/static/js/thread.js - About 1 hr to fix

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

                      if (this.civiRecViewLimits[type] === 0) {
                          if (civiRecViewLimits[type] < 5) {
                              civiRecViewLimits[type] = 5;
                          }
                          this.civiRecViewLimits[type] = civiRecViewLimits[type];
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1443..1448

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

          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 (this.civiOtherViewLimits[type] === 0) {
                          if (civiOtherViewLimits[type] < 5) {
                              civiOtherViewLimits[type] = 5;
                          }
                          this.civiOtherViewLimits[type] = civiOtherViewLimits[type];
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1437..1442

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

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

          def upload_thread_image(request):
              """This function is used to upload an image to a thread"""
              if request.method == "POST":
                  r = request.POST
                  thread_id = r.get("thread_id")
          Severity: Minor
          Found in project/threads/api.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

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

                                  $.ajaxSetup({
                                      beforeSend: function(xhr, settings) {
                                          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                              xhr.setRequestHeader("X-CSRFToken", csrftoken);
                                          }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 4 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 459..465
          project/core/templates/static/js/thread.js on lines 488..494
          project/core/templates/static/js/thread.js on lines 1017..1023
          project/core/templates/static/js/thread.js on lines 1157..1163

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

          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 (this.currentCivi !== $newCivi.attr('data-civi-id')) {
                          // $currentCivi.removeClass('current');
                          this.$('.civi-card').removeClass('current');
                          $newCivi.addClass('current');
                          var civi_id = $newCivi.data('civi-id');
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1909..1927

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

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

                                      $.ajaxSetup({
                                          beforeSend: function(xhr, settings) {
                                              if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                                  xhr.setRequestHeader("X-CSRFToken", csrftoken);
                                              }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 4 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 459..465
          project/core/templates/static/js/thread.js on lines 488..494
          project/core/templates/static/js/thread.js on lines 803..809
          project/core/templates/static/js/thread.js on lines 1017..1023

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

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

                      $.ajaxSetup({
                          beforeSend: function(xhr, settings) {
                              if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                  xhr.setRequestHeader("X-CSRFToken", csrftoken);
                              }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 4 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 488..494
          project/core/templates/static/js/thread.js on lines 803..809
          project/core/templates/static/js/thread.js on lines 1017..1023
          project/core/templates/static/js/thread.js on lines 1157..1163

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

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

                                  $.ajaxSetup({
                                      beforeSend: function(xhr, settings) {
                                          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                              xhr.setRequestHeader("X-CSRFToken", csrftoken);
                                          }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 4 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 459..465
          project/core/templates/static/js/thread.js on lines 803..809
          project/core/templates/static/js/thread.js on lines 1017..1023
          project/core/templates/static/js/thread.js on lines 1157..1163

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

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

                                  $.ajaxSetup({
                                      beforeSend: function(xhr, settings) {
                                          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                                              xhr.setRequestHeader("X-CSRFToken", csrftoken);
                                          }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 4 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 459..465
          project/core/templates/static/js/thread.js on lines 488..494
          project/core/templates/static/js/thread.js on lines 803..809
          project/core/templates/static/js/thread.js on lines 1157..1163

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

          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 (this.currentCivi !== $newCivi.attr('data-civi-id')) {
                      // $currentCivi.removeClass('current');
                      this.$('.civi-card').removeClass('current');
                      $newCivi.addClass('current');
                      var civi_id = $newCivi.data('civi-id');
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 1 other location - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1943..1960

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

          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