def message
      # Retrieve a text message that may be rendered for a task's status.  This is used in various places,
      # such as System Event history.
      details = TaskStatus::TYPES[self.task_type]
      return _("Non-system event") if details.nil?

      case details[:type]
      when :package
        p = self.parameters[:packages]
        first_package = p.first.is_a?(Hash) ? p.first[:name] : p.first
        unless p && p.length > 0
          if self.task_type == "package_update"
            case self.overall_status
            when "running"
              return "updating"
            when "waiting"
              return "updating"
            when "error"
              return _("all packages update failed")
            else
              return _("all packages update")
            end
          end
        end

        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { package: first_package, total: p.length - 1 }
      when :candlepin_event
        return self.result
      when :package_group
        p = self.parameters[:groups]
        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { group: p.first, total: p.length - 1 }
      when :errata
        p = self.parameters[:errata_ids]
        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { errata: p.first, total: p.length - 1 }
      end
    end
def message
      # Retrieve a text message that may be rendered for a task's status.  This is used in various places,
      # such as System Event history.
      details = TaskStatus::TYPES[self.task_type]
      return _("Non-system event") if details.nil?

      case details[:type]
      when :package
        p = self.parameters[:packages]
        first_package = p.first.is_a?(Hash) ? p.first[:name] : p.first
        unless p && p.length > 0
          if self.task_type == "package_update"
            case self.overall_status
            when "running"
              return "updating"
            when "waiting"
              return "updating"
            when "error"
              return _("all packages update failed")
            else
              return _("all packages update")
            end
          end
        end

        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { package: first_package, total: p.length - 1 }
      when :candlepin_event
        return self.result
      when :package_group
        p = self.parameters[:groups]
        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { group: p.first, total: p.length - 1 }
      when :errata
        p = self.parameters[:errata_ids]
        msg = details[:event_messages][self.overall_status]
        return n_(msg[1], msg[2], p.length) % { errata: p.first, total: p.length - 1 }
      end
    end
TODO: break up method
 rubocop:disable MethodLength