Skip to content

Commit

Permalink
fixup! Fixes #23948: Remove early return to prepare to Scala3 migrati…
Browse files Browse the repository at this point in the history
…on in box sequence/traverse

Fixes #23948: Remove early return to prepare to Scala3 migration in box sequence/traverse
  • Loading branch information
fanf committed Dec 21, 2023
1 parent 355a9f5 commit 4f0ccc3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ class ClassicTechniqueWriter(basePath: String, parameterTypeService: ParameterTy
method_info <- methods.get(call.methodId)
(_, classParameterValue) <- call.parameters.find(_._1 == method_info.classParameter)

params <- Control.sequence(method_info.parameters) { p =>
params <- Control.traverse(method_info.parameters) { p =>
for {
(_, value) <- Box(call.parameters.find(_._1 == p.id))
escaped <- parameterTypeService.translate(value, p.parameterType, AgentType.CfeCommunity).toBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import com.normation.rudder.services.reports.CacheComplianceQueueAction.Expected
import com.normation.rudder.services.reports.CacheExpectedReportAction
import com.normation.rudder.services.reports.CacheExpectedReportAction.InsertNodeInCache
import com.normation.rudder.services.reports.InvalidateCache
import com.normation.utils.Control.sequence
import com.normation.utils.Control.traverse
import net.liftweb.common.Box
import net.liftweb.common.Empty
import net.liftweb.common.EmptyBox
Expand Down Expand Up @@ -517,7 +517,7 @@ trait ComposedNewNodeManager extends NewNodeManager with NewNodeManagerHooks {

// validate pre acceptance for a Node, if an error occurs, stop everything on that node.
def passPreAccept(inventory: FullInventory) = {
sequence(unitAcceptors)(unitAcceptor => {
traverse(unitAcceptors)(unitAcceptor => {
unitAcceptor.preAccept(Seq(inventory), modId, actor) match {
case Full(seq) => // ok, cool
NodeLogger.PendingNode.debug(s"Pre acceptance phase: '${unitAcceptor.name}' OK")
Expand All @@ -537,7 +537,7 @@ trait ComposedNewNodeManager extends NewNodeManager with NewNodeManagerHooks {

// accept one node
def acceptOne(sm: FullInventory, modId: ModificationId, actor: EventActor): Box[FullInventory] = {
(sequence(unitAcceptors) { unitAcceptor =>
(traverse(unitAcceptors) { unitAcceptor =>
try {
unitAcceptor.acceptOne(sm, modId, actor) ?~! "Error when executing accept node process named %s".format(
unitAcceptor.name
Expand All @@ -561,7 +561,7 @@ trait ComposedNewNodeManager extends NewNodeManager with NewNodeManagerHooks {

// validate post acceptance for a Node, if an error occurs, Rollback the node acceptance
def passPostAccept(inventory: FullInventory) = {
sequence(unitAcceptors)(unitAcceptor => {
traverse(unitAcceptors)(unitAcceptor => {
unitAcceptor.postAccept(Seq(inventory), modId, actor) match {
case Full(seq) => // ok, cool
NodeLogger.PendingNode.debug(s"Post acceptance phase: '${unitAcceptor.name}' OK")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ final case class RestExtractorService(
.extractJsonListString(
json,
"agent_support",
sequence(_) {
traverse(_) {
case "dsc" => Full(AgentType.Dsc :: Nil)
case "cfengine-community" => Full(AgentType.CfeCommunity :: AgentType.CfeEnterprise :: Nil)
case _ => Failure("invalid agent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ class NodeApiService2(
newNodeManager.refuse(ids, modId, actor, "").map(_.map(serializeServerInfo(_, "refused")))

case DeleteNode =>
boxSequence(ids.map(actualNodeDeletion(_, modId, actor)))
sequence(ids.map(actualNodeDeletion(_, modId, actor)))
}).map(_.toList)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object Control {

import cats.syntax.traverse._

private implicit val boxApplicative: Applicative[Box] = new Applicative[Box] {
implicit private val boxApplicative: Applicative[Box] = new Applicative[Box] {
override def pure[A](x: A): Box[A] = Full(x)

override def ap[A, B](ff: Box[A => B])(fa: Box[A]): Box[B] = ff.flatMap(f => fa.map(f))
Expand Down

0 comments on commit 4f0ccc3

Please sign in to comment.