mysociety/alaveteli

View on GitHub

Showing 277 of 434 total issues

Method start has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def start()
    # Start a POP3 session and ensure that it will be closed in any case.
    unless block_given?
      raise ArgumentError, "AlaveteliMailPoller#start takes a block"
    end
Severity: Minor
Found in lib/alaveteli_mail_poller.rb - 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

Method extract_attached_message_headers has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def extract_attached_message_headers(leaf)
        body = get_part_body(leaf)
        # Test to see if we are in the first part of the attached
        # RFC822 message and it is text, if so add headers.
        if leaf.within_rfc822_attachment == leaf && get_content_type(leaf) == 'text/plain'
Severity: Minor
Found in lib/mail_handler/backends/mail_backend.rb - 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

Method _get_attachment_leaves_recursive has a Cognitive Complexity of 10 (exceeds 5 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

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 run has a Cognitive Complexity of 10 (exceeds 5 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

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 mirror has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def mirror
    return puts(not_a_mirror) unless mirror_service?
    return puts(mirror_primary_not_disk_service) unless disk_service?

    count = mirrorable_blobs.count
Severity: Minor
Found in lib/tasks/storage/storage.rb - 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

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