CiviWiki/OpenCiviWiki

View on GitHub

Showing 22,315 of 22,315 total issues

ThreadView has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

cw.ThreadView = BB.View.extend({
    el: '#thread',
    template: _.template($('#thread-template').html()),
    wikiTemplate: _.template($('#thread-wiki-template').html()),
    bodyTemplate: _.template($('#thread-body-template').html()),
Severity: Minor
Found in project/core/templates/static/js/thread.js - About 3 hrs to fix

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

        createCivi: function (e) {
            var _this = this;
    
            var title = this.$el.find('#civi-title').val(),
                body = this.$el.find('#civi-body').val(),
    Severity: Minor
    Found in project/core/templates/static/js/thread.js - About 3 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

            if (this.viewRecommended){
                this.$(".label-recommended").addClass('current');
                this.$(".label-other").removeClass('current');
                this.$(".badge-recommended").addClass('current');
                this.$(".badge-other").removeClass('current');
    Severity: Major
    Found in project/core/templates/static/js/thread.js and 1 other location - About 3 hrs to fix
    project/core/templates/static/js/thread.js on lines 1619..1625

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

    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

            } else {
                this.$(".label-recommended").removeClass('current');
                this.$(".label-other").addClass('current');
                this.$(".badge-recommended").removeClass('current');
                this.$(".badge-other").addClass('current');
    Severity: Major
    Found in project/core/templates/static/js/thread.js and 1 other location - About 3 hrs to fix
    project/core/templates/static/js/thread.js on lines 1613..1619

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

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

        createResponse: function (e) {
            var _this = this;
            this.$(e.currentTarget).addClass('disabled').attr('disabled', true);
            var title = this.$('#response-title').val(),
                body = this.$('#response-body').val(),
    Severity: Major
    Found in project/core/templates/static/js/thread.js - About 3 hrs to fix

      Function initRecommended has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          initRecommended: function() {
              var _this = this;
              this.recommendedCivis = [];
              this.otherCivis = [];
              this.civiRecViewTotals = {problem : 0,cause: 0,solution: 0};
      Severity: Major
      Found in project/core/templates/static/js/thread.js - About 2 hrs to fix

        Function editThread has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            editThread: function (e) {
                var _this = this;
                _this.$(e.currentTarget).addClass('disabled').attr('disabled', true);
        
                var title = this.$el.find('#thread-title').val().trim();
        Severity: Minor
        Found in project/core/templates/static/js/thread.js - About 2 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

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

                        success: function (response) {
                            var new_civi_data = response.data;
                            var new_civi = new cw.CiviModel(new_civi_data);
                            var can_edit = new_civi.get('author').username == _this.options.parentView.username ? true : false;
        
        
        Severity: Major
        Found in project/core/templates/static/js/thread.js - About 2 hrs to fix

          Function upload_civi_image has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          def upload_civi_image(request):
              """This function is used to upload an image for a Civi"""
              if request.method == "POST":
                  r = request.POST
                  civi_id = r.get("civi_id")
          Severity: Minor
          Found in project/threads/api.py - About 2 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

          Function createResponse has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              createResponse: function (e) {
                  var _this = this;
                  this.$(e.currentTarget).addClass('disabled').attr('disabled', true);
                  var title = this.$('#response-title').val(),
                      body = this.$('#response-body').val(),
          Severity: Minor
          Found in project/core/templates/static/js/thread.js - About 2 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 3 locations. Consider refactoring.
          Open

              addImageLinkInput: function(){
                  var link_images = this.$('.civi-link-images').length;
                  if (link_images > 20 ) {
                      Materialize.toast("Don't think you need any more...", 5000);
                  } else {
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 2 hrs to fix
          project/core/templates/static/js/thread.js on lines 197..205
          project/core/templates/static/js/thread.js on lines 936..944

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

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

              addImageLinkInput: function(){
                  var link_images = this.$('.civi-link-images').length;
                  if (link_images > 20 ) {
                      Materialize.toast("Don't think you need any more...", 5000);
                  } else {
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 2 hrs to fix
          project/core/templates/static/js/thread.js on lines 705..713
          project/core/templates/static/js/thread.js on lines 936..944

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

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

              addImageLinkInput: function(){
                  var link_images = this.$('.civi-link-images').length;
                  if (link_images > 20 ) {
                      Materialize.toast("Don't think you need any more...", 5000);
                  } else {
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 2 hrs to fix
          project/core/templates/static/js/thread.js on lines 197..205
          project/core/templates/static/js/thread.js on lines 705..713

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

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

                                          error: function(e){
                                              Materialize.toast('ERROR: Image could not be uploaded', 5000);
                                              Materialize.toast(e.statusText, 5000);
                                              _this.$(e.currentTarget).removeClass('disabled').attr('disabled', false);
                                          }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1182..1186
          project/core/templates/static/js/thread.js on lines 1215..1219

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 71.

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

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

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

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

          Refactorings

          Further Reading

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

                              } else {
                                  _.each(civi.get('links'), function(link){
                                      var linked_civi = this.civis.get(link);
                                      if (linked_civi) {
                                          this.otherCivis.push(link);
          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 1406..1413

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 71.

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

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

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

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

          Refactorings

          Further Reading

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

                              if ((voteData.activity_type == 'vote_pos' || voteData.activity_type == 'vote_vpos')){
                                  _.each(civi.get('links'), function(link){
                                      var linked_civi = this.civis.get(link);
                                      if (linked_civi) {
                                          this.recommendedCivis.push(link);
          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 1413..1420

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 71.

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

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

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

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

          Refactorings

          Further Reading

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

                                          error: function(e){
                                              Materialize.toast('ERROR: Image could not be uploaded', 5000);
                                              Materialize.toast(e.statusText, 5000);
                                              _this.$(e.currentTarget).removeClass('disabled').attr('disabled', false);
                                          },
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1215..1219
          project/core/templates/static/js/thread.js on lines 1243..1247

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 71.

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

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

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

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

          Refactorings

          Further Reading

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

                                          error: function(e){
                                              Materialize.toast('ERROR: Image could not be uploaded', 5000);
                                              Materialize.toast(e.statusText, 5000);
                                              _this.$(e.currentTarget).removeClass('disabled').attr('disabled', false);
                                          }
          Severity: Major
          Found in project/core/templates/static/js/thread.js and 2 other locations - About 1 hr to fix
          project/core/templates/static/js/thread.js on lines 1182..1186
          project/core/templates/static/js/thread.js on lines 1243..1247

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 71.

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

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

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

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

          Refactorings

          Further Reading

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

              def score(self, requested_user_id=None):
                  # TODO: add docstring comment describing this score function
                  # in relatively plain English
                  # include descriptions of all variables
          
          
          Severity: Minor
          Found in project/threads/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

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

                  var ms_check = target.hasClass('ms-ctn') || target.hasClass('ms-sel-ctn') || target.hasClass('ms-close-btn') || target.hasClass('ms-trigger') || target.hasClass('ms-trigger-ico') || target.hasClass('ms-res-ctn') || target.hasClass('ms-sel-item') || target.hasClass('ms-res-group');
          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 1935..1935

          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

          Severity
          Category
          Status
          Source
          Language