mysociety/alaveteli

View on GitHub

Showing 58 of 436 total issues

File info_request.rb has 1392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'digest/sha1'
require 'fileutils'

class InfoRequest < ApplicationRecord
  OLD_AGE_IN_DAYS = 21.days
Severity: Major
Found in app/models/info_request.rb - About 3 days to fix

    Class InfoRequest has 151 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class InfoRequest < ApplicationRecord
      OLD_AGE_IN_DAYS = 21.days
    
      include Rails.application.routes.url_helpers
      include AlaveteliPro::RequestSummaries
    Severity: Major
    Found in app/models/info_request.rb - About 2 days to fix

      File acts_as_xapian.rb has 824 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'English'
      begin
        require 'xapian'
        $acts_as_xapian_bindings_available = true
      
      
      Severity: Major
      Found in lib/acts_as_xapian/acts_as_xapian.rb - About 1 day to fix

        File public_body.rb has 721 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'csv'
        require 'securerandom'
        require 'set'
        require 'confidence_intervals'
        
        
        Severity: Major
        Found in app/models/public_body.rb - About 1 day to fix

          File routes.rb has 697 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'sidekiq/web'
          
          include AlaveteliFeatures::Constraints
          
          # Allow easy extension from themes. Note these will have the highest priority.
          Severity: Major
          Found in config/routes.rb - About 1 day to fix

            Class User has 75 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class User < ApplicationRecord
              include AlaveteliFeatures::Helpers
              include AlaveteliPro::PhaseCounts
              include User::Authentication
              include User::LoginToken
            Severity: Major
            Found in app/models/user.rb - About 1 day to fix

              File request_controller.rb has 595 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'zip'
              
              class RequestController < ApplicationController
                skip_before_action :html_response, only: [:show, :select_authorities]
              
              
              Severity: Major
              Found in app/controllers/request_controller.rb - About 1 day to fix

                File user.rb has 528 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class User < ApplicationRecord
                  include AlaveteliFeatures::Helpers
                  include AlaveteliPro::PhaseCounts
                  include User::Authentication
                  include User::LoginToken
                Severity: Major
                Found in app/models/user.rb - About 1 day to fix

                  Class PublicBody has 60 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class PublicBody < ApplicationRecord
                    include CalculatedHomePage
                    include Categorisable
                    include Taggable
                    include Notable
                  Severity: Major
                  Found in app/models/public_body.rb - About 1 day to fix

                    Method get_language_name has 191 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.get_language_name(locale)
                        language_names = {
                          'ab'    => 'аҧсуа',
                          'aa'    => 'Afaraf',
                          'af'    => 'Afrikaans',
                    Severity: Major
                    Found in lib/languages.rb - About 7 hrs to fix

                      Function d3TimeSeries has 158 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function d3TimeSeries(selector, data, title, metric_name) {
                      
                        // Add the title
                        var wrapper_element = document.querySelectorAll(selector)[0];
                      
                      
                      Severity: Major
                      Found in app/assets/javascripts/time_series.js - About 6 hrs to fix

                        Method initialize has 147 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def initialize(user, project: nil, public_token: false)
                            # Define abilities for the passed in user here. For example:
                            #
                            #   user ||= User.new # guest user (not logged in)
                            #   if user.is_admin?
                        Severity: Major
                        Found in app/models/ability.rb - About 5 hrs to fix

                          Method world_foi_websites has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def self.world_foi_websites
                              world_foi_websites = [
                                { name: "WhatDoTheyKnow",
                                  country_name: "United Kingdom",
                                  country_iso_code: "GB",
                          Severity: Major
                          Found in lib/world_foi_websites.rb - About 4 hrs to fix

                            Method new has 104 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def new
                                # All new requests are of normal_sort
                                unless params[:outgoing_message].nil?
                                  params[:outgoing_message][:what_doing] = 'normal_sort'
                                end
                            Severity: Major
                            Found in app/controllers/request_controller.rb - About 4 hrs to fix

                              Function stripeForm has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function stripeForm(form, options) {
                                var that = Object.assign({
                                  stripe: Stripe(AlaveteliPro.stripe_publishable_key),
                                  form: form,
                                  submit: document.getElementById('js-stripe-submit'),
                              Severity: Major
                              Found in app/assets/javascripts/alaveteli_pro/stripe.js - About 3 hrs to fix

                                Method search has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  def search
                                    # TODO: Why is this so complicated with arrays and stuff? Look at the route
                                    # in config/routes.rb for comments.
                                
                                    combined = params[:combined].split("/")
                                Severity: Major
                                Found in app/controllers/general_controller.rb - About 3 hrs to fix

                                  Method xapian_index has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      def xapian_index(terms = true, values = true, texts = true)
                                        # if we have a conditional function for indexing, call it and destroy object if failed
                                        if self.class.xapian_options.include?(:if)
                                          if_value = xapian_value(self.class.xapian_options[:if], :boolean)
                                          unless if_value
                                  Severity: Major
                                  Found in lib/acts_as_xapian/acts_as_xapian.rb - 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 index has 73 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

                                        Method add_correspondence has 72 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
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language