mysociety/alaveteli

View on GitHub

Showing 462 of 632 total issues

Function drawBar has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function drawBar(x, y, b, barLeft, barRight, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) {
            var left, right, bottom, top,
                drawLeft, drawRight, drawTop, drawBottom,
                tmp;

Severity: Major
Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

    Function insertLegend has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            function insertLegend() {
    
                placeholder.find(".legend").remove();
    
                if (!options.legend.show)
    Severity: Major
    Found in app/assets/javascripts/jquery.flot.js - About 3 hrs to fix

      File mail_backend.rb has 300 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'mail'
      require 'mapi/msg'
      require 'mapi/convert'
      
      module Mail
      Severity: Minor
      Found in lib/mail_handler/backends/mail_backend.rb - About 3 hrs to fix

        Method main has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

        def main(in_test_mode)
          Dir.chdir($alaveteli_dir) do
            raw_message = $stdin.read
            begin
              message = MailHandler.mail_from_raw_email(raw_message)
        Severity: Minor
        Found in script/handle-mail-replies.rb - 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

        Method authenticate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          def authenticate
            if AlaveteliConfiguration::skip_admin_auth
              session[:using_admin] = 1
              return
            else
        Severity: Minor
        Found in app/controllers/admin_controller.rb - 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

        Method alert_overdue_requests has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.alert_overdue_requests
            info_requests = InfoRequest.where("described_state = 'waiting_response'
                        AND awaiting_description = ?
                        AND user_id is not null
                        AND use_notifications = ?
        Severity: Minor
        Found in app/mailers/request_mailer.rb - 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 drawSeriesErrors has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function drawSeriesErrors(plot, ctx, s){
        
                var points = s.datapoints.points,
                        ps = s.datapoints.pointsize,
                        ax = [s.xaxis, s.yaxis],
        Severity: Major
        Found in app/assets/javascripts/jquery.flot.errorbars.js - About 3 hrs to fix

          Function onKeyDown has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  onKeyDown: function(e) {
                      var isInput = e.target === this.$control_input[0];
                      var self = this;
              
                      if (self.isLocked) {
          Severity: Major
          Found in app/assets/javascripts/alaveteli_pro/selectize.js - About 3 hrs to fix

            Function init has 76 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function init(plot) {
                    // This is kind of a hack. There are no hooks in Flot between
                    // the creation and measuring of the ticks (setTicks, measureTickLabels
                    // in setupGrid() ) and the drawing of the ticks and plot box
                    // (insertAxisLabels in setupGrid() ).
            Severity: Major
            Found in app/assets/javascripts/jquery.flot.axislabels.js - About 3 hrs to fix

              Function setUpCorrespondenceCollapsing has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var setUpCorrespondenceCollapsing = function(){
                $('.js-collapsable').each(function(){
                  var $collapsable = $(this);
                  var $triggers = $(this).find('.js-collapsable-trigger');
                  var $correspondenceHeader = $(this).find('.correspondence__header');
              Severity: Major
              Found in app/assets/javascripts/correspondence-collapse.js - About 3 hrs to fix

                Method up has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def up
                    default_locale = AlaveteliLocalization.default_locale
                
                    fields = {:title => :text,
                              :description => :text}
                Severity: Major
                Found in db/migrate/20140716131107_create_category_translation_tables.rb - About 2 hrs to fix

                  Method get_attachment_text_one_file has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_attachment_text_one_file(content_type, body, charset = 'utf-8')
                      # note re. charset: TMail always tries to convert email bodies
                      # to UTF8 by default, so normally it should already be that.
                      text = ''
                      # TODO: - tell all these command line tools to return utf-8
                  Severity: Minor
                  Found in lib/mail_handler/mail_handler.rb - 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 findNearbyItem has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          function findNearbyItem(mouseX, mouseY, seriesFilter) {
                              var maxDistance = options.grid.mouseActiveRadius,
                                  smallestDistance = maxDistance * maxDistance + 1,
                                  item = null, foundPoint = false, i, j, ps;
                  
                  
                  Severity: Major
                  Found in app/assets/javascripts/jquery.flot.js - About 2 hrs to fix

                    Method index has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def index
                        # Tasks to do
                        @requires_admin_requests = InfoRequest.
                          find_in_state('requires_admin').
                            not_embargoed
                    Severity: Major
                    Found in app/controllers/admin_general_controller.rb - About 2 hrs to fix

                      Class RequestFilter has 25 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        class RequestFilter
                      
                          extend ActiveModel::Naming
                          include ActiveModel::Conversion
                      
                      
                      Severity: Minor
                      Found in app/models/alaveteli_pro/request_filter.rb - About 2 hrs to fix

                        Method add_correspondence has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def add_correspondence
                            json = ActiveSupport::JSON.decode(params[:correspondence_json])
                            attachments = params[:attachments]
                        
                            direction = json["direction"]
                        Severity: Major
                        Found in app/controllers/api_controller.rb - About 2 hrs to fix

                          Method update has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def update
                              if @pretoken
                                @pretoken_redirect = PostRedirect.find_by(:token => @pretoken)
                              end
                          
                          
                          Severity: Minor
                          Found in app/controllers/password_changes_controller.rb - 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

                          Method get_status_from_params has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def get_status_from_params(params)
                              query = ""
                              if params[:latest_status]
                                statuses = []
                                if params[:latest_status].class == String
                          Severity: Minor
                          Found in lib/xapian_queries.rb - 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

                          Method import_csv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def import_csv
                              @notes = ""
                              @errors = ""
                              if request.post?
                                dry_run_only = params['commit'] != 'Upload'
                          Severity: Minor
                          Found in app/controllers/admin_public_body_controller.rb - 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

                          Method create has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def create
                              begin
                                @token = Stripe::Token.retrieve(params[:stripeToken])
                          
                                customer = current_user.pro_account.try(:stripe_customer)
                          Severity: Major
                          Found in app/controllers/alaveteli_pro/subscriptions_controller.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language