CiviWiki/OpenCiviWiki

View on GitHub

Showing 50 of 22,315 total issues

File thread.js has 1688 lines of code (exceeds 250 allowed). Consider refactoring.
Open

cw = cw || {};

cw.DEFAULTS = {
    types: ['problem', 'cause', 'solution'],
    types_plural: ['problems', 'causes', 'solutions'],
Severity: Major
Found in project/core/templates/static/js/thread.js - About 4 days to fix

    Function saveEdit has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
    Open

        saveEdit: function(e) {
            e.stopPropagation();
            var _this = this;
            var c_type = this.model.get('type');
            var new_body = this.$('.edit-civi-body').val().trim();
    Severity: Minor
    Found in project/core/templates/static/js/thread.js - About 1 day 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 saveEdit has 177 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        saveEdit: function(e) {
            e.stopPropagation();
            var _this = this;
            var c_type = this.model.get('type');
            var new_body = this.$('.edit-civi-body').val().trim();
    Severity: Major
    Found in project/core/templates/static/js/thread.js - About 7 hrs to fix

      File models.py has 440 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import datetime
      import json
      import math
      import os
      from calendar import month_name
      Severity: Minor
      Found in project/threads/models.py - About 6 hrs to fix

        File api.py has 415 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import json
        
        from accounts.models import Profile
        from common.utils import check_database, save_image_from_url
        from core.custom_decorators import require_post_params
        Severity: Minor
        Found in project/threads/api.py - About 5 hrs to fix

          Function editThread has 125 lines of code (exceeds 25 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: Major
          Found in project/core/templates/static/js/thread.js - About 5 hrs to fix

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

                            success: function (response) {
                                _this.closeEdit(e);
                                // var score = $this.find('.rate-value');
                                // var new_vote = parseInt(score.text())+ 1;
                                // score.text(new_vote);
            Severity: Major
            Found in project/core/templates/static/js/thread.js - About 4 hrs to fix

              Function createCivi has 104 lines of code (exceeds 25 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: Major
              Found in project/core/templates/static/js/thread.js - About 4 hrs to fix

                Function renderOutline has 100 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    renderOutline: function(){
                        var _this = this;
                        if (this.civis.length === 0){
                            // render with mock data to prevent errors
                            var mockData = {
                Severity: Major
                Found in project/core/templates/static/js/thread.js - About 4 hrs to fix

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

                                  success: function (response) {
                                      var file = $('#thread_attachment_image').val();
                                      var img_url = _this.$('#link-image-form').val().trim();
                                      if (_this.removeImage) {
                                          // if file
                  Severity: Major
                  Found in project/core/templates/static/js/thread.js - About 3 hrs to fix

                    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

                      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

                            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

                            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
                              Severity
                              Category
                              Status
                              Source
                              Language