def formatted_servers
      static_ips = connect.describe_addresses.addresses.map(&:public_ip)

      servers.select { |server| include_server? server }.map do |server|
        o = {
          date: server.launch_time.to_s,
          az: server.placement.availability_zone,
          id: server.instance_id,
          subnet: [server.subnet_id, "(#{subnet_name[server.subnet_id]})"].join(' '),
          priv_ip: server.private_ip_address,
          type: server.instance_type,
          vpc: server.vpc_id,
          state: opts[:csv] ? server.state.name : colorize_state(server.state.name).bold
        }

        if opts[:groups]
          groups_string =
            server.security_groupserver.map { |g| "#{g.group_id} (#{g.group_name})" }.join(', ')

          # Shorten the groups string to a manageable length
          unless (opts[:csv] || opts[:all_groups]) && groups_string.length > GROUPS_MAX_LENGTH
            groups_string = groups_string[0..GROUPS_MAX_LENGTH] + '...'
          end

          o[:groups] = groups_string
        end

        if server.vpc_id && opts[:vpc]
          o[:vpc] = [server.vpc_id, "(#{vpc_name[server.vpc_id]})"].join(' ')
        end

        if server.public_ip_address
          static_ip = static_ips.include?(server.public_ip_address) ? '(S)' : '(D)'
          o[:pub_ip] = [server.public_ip_address, static_ip].join(' ')
        end

        # Always include the name tag regardless of cli args (for searching)
        (opts[:tags] | %w[tag_Name]).each do |tag|
          next unless (k = server.tags.find { |t| t.key == tag })

          o["tag_#{tag}".to_sym] = k.value
        end

        o
      end
    end
def formatted_servers
      static_ips = connect.describe_addresses.addresses.map(&:public_ip)

      servers.select { |server| include_server? server }.map do |server|
        o = {
          date: server.launch_time.to_s,
          az: server.placement.availability_zone,
          id: server.instance_id,
          subnet: [server.subnet_id, "(#{subnet_name[server.subnet_id]})"].join(' '),
          priv_ip: server.private_ip_address,
          type: server.instance_type,
          vpc: server.vpc_id,
          state: opts[:csv] ? server.state.name : colorize_state(server.state.name).bold
        }

        if opts[:groups]
          groups_string =
            server.security_groupserver.map { |g| "#{g.group_id} (#{g.group_name})" }.join(', ')

          # Shorten the groups string to a manageable length
          unless (opts[:csv] || opts[:all_groups]) && groups_string.length > GROUPS_MAX_LENGTH
            groups_string = groups_string[0..GROUPS_MAX_LENGTH] + '...'
          end

          o[:groups] = groups_string
        end

        if server.vpc_id && opts[:vpc]
          o[:vpc] = [server.vpc_id, "(#{vpc_name[server.vpc_id]})"].join(' ')
        end

        if server.public_ip_address
          static_ip = static_ips.include?(server.public_ip_address) ? '(S)' : '(D)'
          o[:pub_ip] = [server.public_ip_address, static_ip].join(' ')
        end

        # Always include the name tag regardless of cli args (for searching)
        (opts[:tags] | %w[tag_Name]).each do |tag|
          next unless (k = server.tags.find { |t| t.key == tag })

          o["tag_#{tag}".to_sym] = k.value
        end

        o
      end
    end
rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
 rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity