mysociety/alaveteli

View on GitHub

Showing 339 of 435 total issues

Method timeline has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def timeline
    # Recent events
    @events_title = get_events_title

    @events = WillPaginate::Collection.create((params[:page] or 1), 100) do |pager|
Severity: Minor
Found in app/controllers/admin_general_controller.rb - About 1 hr to fix

    Method get_status_description has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

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

        def update
          if @user.suspended?
            flash[:error] = _('Suspended users cannot edit their profile')
            redirect_to edit_profile_about_me_path
            return
      Severity: Minor
      Found in app/controllers/user_profile/about_me_controller.rb - About 1 hr to fix

        Method update_index has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.update_index(flush = false, verbose = false)
            # STDOUT.puts("start of ActsAsXapian.update_index") if verbose
        
            # Before calling writable_init we have to make sure every model class has been initialized.
            # i.e. has had its class code loaded, so acts_as_xapian has been called inside it, and
        Severity: Minor
        Found in lib/acts_as_xapian/acts_as_xapian.rb - About 1 hr to fix

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

            def default_message_replacements
              opts = {}
          
              if info_request
                opts[:url] = request_url(info_request) if info_request.url_title
          Severity: Minor
          Found in app/models/outgoing_message.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 show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def show
              medium_cache
              AlaveteliLocalization.with_locale(locale) do
                # Test for whole request being hidden
                return render_hidden if cannot?(:read, @info_request)
          Severity: Minor
          Found in app/controllers/request_controller.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 create has a Cognitive Complexity of 10 (exceeds 5 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: Minor
          Found in app/controllers/classifications_controller.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 authenticate_from_form has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.authenticate_from_form(params, specific_user_login = false)
              params[:email].strip!
          
              if specific_user_login
                auth_fail_message = _("Either the email or password was not recognised, please try again.")
          Severity: Minor
          Found in app/models/user.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 foi_error_messages_for has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def foi_error_messages_for(*params)
              options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {}
              objects = params.collect { |object_name| instance_variable_get("@#{object_name}") }.compact
              count   = objects.inject(0) { |sum, object| sum + object.errors.count }
              return if count.zero?
          Severity: Minor
          Found in app/helpers/application_helper.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 template_changed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def template_changed
              if raw_body.empty? || HTMLEntities.new.decode(raw_body) =~
                                    /\A#{template_regex(letter_template.body(default_message_replacements))}/
                if message_type == 'followup'
                  if what_doing == 'internal_review'
          Severity: Minor
          Found in app/models/outgoing_message.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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              begin
                @pro_account = current_user.pro_account ||= current_user.build_pro_account
          
                # Ensure previous incomplete subscriptions are cancelled to prevent them
          Severity: Minor
          Found in app/controllers/alaveteli_pro/subscriptions_controller.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 cache_attachments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def cache_attachments
              if !params[:skip_cache].nil?
                yield
              else
                if foi_fragment_cache_exists?(cache_key_path)
          Severity: Minor
          Found in app/controllers/attachments_controller.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 list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def list
              long_cache
          
              @tag = params[:tag] || 'all'
              @tag = @tag.upcase if @tag.scan(/./mu).size == 1
          Severity: Minor
          Found in app/controllers/public_body_controller.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 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 get_request_variety_from_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_request_variety_from_params(params)
              query = ""
              sortby = "newest"
              varieties = []
              if params[:request_variety] && !(query =~ /variety:/)
          Severity: Minor
          Found in lib/xapian_queries.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 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 migrate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def migrate
              count = unattached_files.count
          
              unattached_files.find_each.with_index do |file, index|
                Kernel.silence_warnings do
          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

          Severity
          Category
          Status
          Source
          Language