mysociety/alaveteli

View on GitHub

Showing 58 of 434 total issues

Method alert_overdue_requests has 65 lines of code (exceeds 25 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: Major
Found in app/mailers/request_mailer.rb - About 2 hrs to fix

    Method alert_tracks has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.alert_tracks
        done_something = false
        now = Time.zone.now
        one_week_ago = now - 7.days
        User.where(["last_daily_track_email < ?", now - 1.day ]).find_each do |user|
    Severity: Major
    Found in app/mailers/track_mailer.rb - About 2 hrs to fix

      Method import_csv_from_file has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = [])
          errors = []
          notes = []
          begin
            ActiveRecord::Base.transaction do
      Severity: Major
      Found in app/models/public_body.rb - About 2 hrs to fix

        Method body_request_events has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def body_request_events
            feed_type = params[:feed_type]
            if @public_body.id != params[:id].to_i
              raise PermissionDenied, "#{@public_body.id} != #{params[:id]}"
            end
        Severity: Major
        Found in app/controllers/api_controller.rb - About 2 hrs to fix

          Method show has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def show
              long_cache
              @page = get_search_page_from_params
              requests_per_page = 25
          
          
          Severity: Major
          Found in app/controllers/public_body_controller.rb - About 2 hrs to fix

            Method alert_comment_on_request has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.alert_comment_on_request
                # We only check comments made in the last month - this means if the
                # cron jobs broke for more than a month events would be lost, but no
                # matter. I suspect the performance gain will be needed (with an index on updated_at)
            
            
            Severity: Major
            Found in app/mailers/request_mailer.rb - About 2 hrs to fix

              Method get_attachment_text_one_file has 57 lines of code (exceeds 25 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: Major
              Found in lib/mail_handler.rb - About 2 hrs to fix

                Method upload_response has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def upload_response
                    AlaveteliLocalization.with_locale(locale) do
                      @info_request = InfoRequest.not_embargoed.find_by_url_title!(params[:url_title])
                
                      @reason_params = {
                Severity: Major
                Found in app/controllers/request_controller.rb - About 2 hrs to fix

                  Method render_new_compose has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def render_new_compose
                      params[:info_request] = {} unless params[:info_request]
                  
                      # Reconstruct the params
                      # first the public body (by URL name or id)
                  Severity: Major
                  Found in app/controllers/request_controller.rb - About 2 hrs to fix

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

                      def create
                        set_last_request(@info_request)
                    
                        if params[:last_info_request_event_id].to_i != @info_request.
                            last_event_id_needing_description
                    Severity: Major
                    Found in app/controllers/classifications_controller.rb - About 2 hrs to fix

                      Method initialize_query has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def initialize_query(options)
                            #raise options.to_yaml
                      
                            self.runtime += Benchmark.realtime {
                              offset = options[:offset] || 0
                      Severity: Major
                      Found in lib/acts_as_xapian/acts_as_xapian.rb - About 2 hrs to fix

                        Method signchangeemail has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def signchangeemail
                            # "authenticated?" has done the redirect to signin page for us
                            return unless authenticated? || ask_to_login(
                              web: _('To change your email address used on {{site_name}}',
                                     site_name: site_name),
                        Severity: Major
                        Found in app/controllers/user_controller.rb - About 2 hrs to fix

                          Method public_bodies has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def self.public_bodies
                              per_graph = 10
                              minimum_requests = AlaveteliConfiguration.minimum_requests_for_statistics
                              # Make sure minimum_requests is > 0 to avoid division-by-zero
                              minimum_requests = [minimum_requests, 1].max
                          Severity: Major
                          Found in app/models/statistics.rb - About 2 hrs to fix

                            Method to_admin_message has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body)
                            Severity: Major
                            Found in app/mailers/contact_mailer.rb - About 50 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      rescue
                                        $stderr.puts("Error processing zip file: #{$ERROR_INFO.inspect}")
                              Severity: Major
                              Found in lib/mail_handler.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            raise "dry run mismatched real run" if !errors.empty?
                                Severity: Major
                                Found in app/controllers/admin_public_body_controller.rb - About 45 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                        elsif curr_state && (event.event_type == 'followup_sent' || event.event_type == 'sent') && event.described_state && (event.described_state == 'waiting_response' || event.described_state == 'internal_review')
                                          # Followups can set the status to waiting response / internal
                                          # review. Initial requests ('sent') set the status to waiting response.
                                  
                                          # We want to store that in calculated_state state so it gets
                                  Severity: Major
                                  Found in app/models/info_request.rb - About 40 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                        return false if empty_return_path?
                                    Severity: Major
                                    Found in app/models/raw_email.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                          return false if auto_submitted?
                                      Severity: Major
                                      Found in app/models/raw_email.rb - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                            return 2 if MailHandler::ReplyHandler.is_oof?(message)
                                        Severity: Major
                                        Found in script/handle-mail-replies.rb - About 30 mins to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language