mysociety/alaveteli

View on GitHub

Showing 338 of 434 total issues

Method track_set has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def track_set
    if @user
      @existing_track = TrackThing.find_existing(@user, @track_thing)
      if @existing_track
        flash[:notice] =
Severity: Minor
Found in app/controllers/track_controller.rb - About 1 hr to fix

    Method holding_pen_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.holding_pen_request
        ir = InfoRequest.find_by_url_title("holding_pen")
        if ir.nil?
          ir = InfoRequest.new(
            user: User.internal_admin_user,
    Severity: Minor
    Found in app/models/info_request.rb - About 1 hr to fix

      Method subscribe_follow_notice has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def subscribe_follow_notice(track_thing)
          wall_url_user = show_user_wall_path(url_name: track_thing.tracking_user.url_name)
          case track_thing.track_type
          when 'request_updates'
            _('You are now <a href="{{wall_url_user}}">following</a> updates about \'{{link_to_request}}\', a request.',
      Severity: Minor
      Found in app/helpers/track_helper.rb - About 1 hr to fix

        Method send_daily_notifications has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.send_daily_notifications
            done_something = false
            query = "notifications.frequency = ? AND " \
                    "notifications.send_after <= ? AND " \
                    "notifications.seen_at IS NULL AND " \
        Severity: Minor
        Found in app/mailers/notification_mailer.rb - About 1 hr to fix

          Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run(*args)
              # Run an external program, and return its output.
              # Standard error is suppressed unless the program
              # fails (i.e. returns a non-zero exit status).
              # If the program fails, returns nil and writes any error to stderr.
          Severity: Minor
          Found in lib/alaveteli_external_command.rb - About 1 hr to fix

            Method set_locale_fields_from_csv_row has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def set_locale_fields_from_csv_row(is_new, locale, row, options)
                changed = ActiveSupport::OrderedHash.new
                csv_field_names = options[:field_names]
                csv_import_fields.each do |field_name, _field_notes|
                  localized_field_name = self.class.localized_csv_field_name(locale, field_name)
            Severity: Minor
            Found in app/models/public_body.rb - About 1 hr to fix

              Method short_description has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.short_description(state)
                    descriptions = {
                          'waiting_classification'        => _("Needs status update"),
                          'waiting_response'              => _("Awaiting response"),
                          'waiting_response_overdue'      => _("Delayed"),
              Severity: Minor
              Found in app/models/info_request/state.rb - About 1 hr to fix

                Method extract_attachments has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def extract_attachments
                    _mail = raw_email.mail!
                    attachment_attributes = MailHandler.get_attachment_attributes(_mail)
                    attachment_attributes = attachment_attributes.inject({}) do |memo, attrs|
                      attrs.delete(:original_body)
                Severity: Minor
                Found in app/models/incoming_message.rb - About 1 hr to fix

                  Method recent_requests has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.recent_requests
                      request_events = []
                      request_events_all_successful = false
                      # Get some successful requests
                      begin
                  Severity: Minor
                  Found in app/models/info_request.rb - About 1 hr to fix

                    Method translated_fields has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def translated_fields
                        fields = @template.tag.div id: 'div-locales' do
                          @template.concat(locale_tabs)
                    
                          locales = @template.tag.div class: 'tab-content' do
                    Severity: Minor
                    Found in app/helpers/admin/translated_record_form.rb - About 1 hr to fix

                      Method status_text_waiting_clarification has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def status_text_waiting_clarification(info_request, opts = {})
                          is_owning_user = opts.fetch(:is_owning_user)
                      
                          str = ''.html_safe
                      
                      
                      Severity: Minor
                      Found in app/helpers/info_request_helper.rb - About 1 hr to fix

                        Method render_exception has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def render_exception(exception)
                            # In development let Rails handle the exception with its stack trace
                            # templates.
                            raise exception if Rails.application.config.consider_all_requests_local
                        
                        
                        Severity: Minor
                        Found in app/controllers/application_controller.rb - About 1 hr to fix

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

                            def create
                              if @post_redirect.present?
                                @user_signin =
                                  User.authenticate_from_form(user_signin_params,
                                                              @post_redirect.reason_params[:user_name])
                          Severity: Minor
                          Found in app/controllers/users/sessions_controller.rb - About 1 hr to fix

                            Method update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def update
                                raise ActiveRecord::RecordNotFound if cannot? :admin, @comment
                            
                                old_body = @comment.body.dup
                                old_visible = @comment.visible
                            Severity: Minor
                            Found in app/controllers/admin_comment_controller.rb - About 1 hr to fix

                              Method _get_attachment_leaves_recursive has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def _get_attachment_leaves_recursive(part, within_rfc822_attachment, parent_mail)
                                      leaves_found = []
                                      if part.multipart?
                                        if part.parts.empty?
                                          # This is typically caused by a missing final
                              Severity: Minor
                              Found in lib/mail_handler/backends/mail_backend.rb - About 1 hr to fix

                                Method body has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def body
                                    return @cached_body if @cached_body
                                
                                    begin
                                      return file.download if masked?
                                Severity: Minor
                                Found in app/models/foi_attachment.rb - About 55 mins 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_previous_email_sent_to has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def get_previous_email_sent_to(info_request_event)
                                    last_email = nil
                                    info_request_events.each do |e|
                                      if ((info_request_event.is_sent_sort? && e.is_sent_sort?) || (info_request_event.is_followup_sort? && e.is_followup_sort?)) && e.outgoing_message_id == info_request_event.outgoing_message_id
                                        break if e.id == info_request_event.id
                                Severity: Minor
                                Found in app/models/info_request.rb - About 55 mins 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 data_and_draft_checks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def data_and_draft_checks
                                    if data.nil?
                                      errors.add(:data, _("Please choose a file containing your photo."))
                                      return
                                    end
                                Severity: Minor
                                Found in app/models/profile_photo.rb - About 55 mins 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 confirm has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def confirm
                                    post_redirect = PostRedirect.find_by_email_token(params[:email_token])
                                
                                    if post_redirect.nil? || !post_redirect.email_token_valid?
                                      render template: 'user/bad_token'
                                Severity: Minor
                                Found in app/controllers/users/confirmations_controller.rb - About 55 mins 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 mass_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def mass_tag
                                    lookup_query
                                
                                    if params[:tag] && (params[:tag] != "")
                                      if params[:table_name] == 'exact'
                                Severity: Minor
                                Found in app/controllers/admin_public_body_controller.rb - About 55 mins 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

                                Severity
                                Category
                                Status
                                Source
                                Language