mirror of
https://gitee.com/zhangsken/opencode.git
synced 2026-10-16 10:30:01 +08:00
chore: enforce mapError simplifications (#46028)
This commit is contained in:
@@ -24,8 +24,8 @@ export const invoke = (plan: Plan, input: unknown): Effect.Effect<unknown, unkno
|
||||
const response = yield* client
|
||||
.execute(request)
|
||||
.pipe(
|
||||
Effect.catch((cause) =>
|
||||
Effect.fail(toolError(`${plan.operation.method} ${plan.operation.path} failed: transport error`, cause)),
|
||||
Effect.mapError((cause) =>
|
||||
toolError(`${plan.operation.method} ${plan.operation.path} failed: transport error`, cause),
|
||||
),
|
||||
)
|
||||
const text = yield* readResponseBody(response, plan)
|
||||
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
id: no-effect-catch-fail
|
||||
snapshots:
|
||||
Effect.catch(effect, (error) => Effect.fail(transform(error))):
|
||||
fixed: Effect.mapError(effect, (error) => transform(error))
|
||||
labels:
|
||||
- source: Effect.catch(effect, (error) => Effect.fail(transform(error)))
|
||||
style: primary
|
||||
start: 0
|
||||
end: 62
|
||||
Effect.catch(effect, error => { return Effect.fail(transform(error)) }):
|
||||
fixed: Effect.mapError(effect, (error) => transform(error))
|
||||
labels:
|
||||
- source: Effect.catch(effect, error => { return Effect.fail(transform(error)) })
|
||||
style: primary
|
||||
start: 0
|
||||
end: 71
|
||||
Stream.catch(stream, (error) => Stream.fail(transform(error))):
|
||||
fixed: Stream.mapError(stream, (error) => transform(error))
|
||||
labels:
|
||||
- source: Stream.catch(stream, (error) => Stream.fail(transform(error)))
|
||||
style: primary
|
||||
start: 0
|
||||
end: 62
|
||||
? |
|
||||
effect.pipe(
|
||||
Effect.catch((error) =>
|
||||
Effect.fail(transform(error)),
|
||||
),
|
||||
)
|
||||
: fixed: |
|
||||
effect.pipe(
|
||||
Effect.mapError((error) => transform(error),),
|
||||
)
|
||||
labels:
|
||||
- source: |-
|
||||
Effect.catch((error) =>
|
||||
Effect.fail(transform(error)),
|
||||
)
|
||||
style: primary
|
||||
start: 15
|
||||
end: 77
|
||||
effect.pipe(Effect.catch((error) => Effect.fail(transform(error)))):
|
||||
fixed: effect.pipe(Effect.mapError((error) => transform(error)))
|
||||
labels:
|
||||
- source: Effect.catch((error) => Effect.fail(transform(error)))
|
||||
style: primary
|
||||
start: 12
|
||||
end: 66
|
||||
effect.pipe(Effect.catch((error) => { return Effect.fail(transform(error)) })):
|
||||
fixed: effect.pipe(Effect.mapError((error) => transform(error)))
|
||||
labels:
|
||||
- source: Effect.catch((error) => { return Effect.fail(transform(error)) })
|
||||
style: primary
|
||||
start: 12
|
||||
end: 77
|
||||
"effect.pipe(Effect.catch((error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error))))":
|
||||
fixed: "effect.pipe(Effect.mapError((error): Wrapped => transform(error)))"
|
||||
labels:
|
||||
- source: "Effect.catch((error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 97
|
||||
"effect.pipe(Effect.catch((error: Error) => Effect.fail(transform(error))))":
|
||||
fixed: "effect.pipe(Effect.mapError((error: Error) => transform(error)))"
|
||||
labels:
|
||||
- source: "Effect.catch((error: Error) => Effect.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 73
|
||||
"effect.pipe(Effect.catch((error: Error): Effect.Effect<never, Wrapped, Scope> => { return Effect.fail(transform(error)) }))":
|
||||
fixed: "effect.pipe(Effect.mapError((error: Error): Wrapped => transform(error)))"
|
||||
labels:
|
||||
- source: "Effect.catch((error: Error): Effect.Effect<never, Wrapped, Scope> => { return Effect.fail(transform(error)) })"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 122
|
||||
effect.pipe(Effect.catch(error => Effect.fail(new Wrapped(error)))):
|
||||
fixed: effect.pipe(Effect.mapError((error) => new Wrapped(error)))
|
||||
labels:
|
||||
- source: Effect.catch(error => Effect.fail(new Wrapped(error)))
|
||||
style: primary
|
||||
start: 12
|
||||
end: 66
|
||||
stream.pipe(Stream.catch((error) => Stream.fail(transform(error)))):
|
||||
fixed: stream.pipe(Stream.mapError((error) => transform(error)))
|
||||
labels:
|
||||
- source: Stream.catch((error) => Stream.fail(transform(error)))
|
||||
style: primary
|
||||
start: 12
|
||||
end: 66
|
||||
stream.pipe(Stream.catch((error) => { return Stream.fail(transform(error)) })):
|
||||
fixed: stream.pipe(Stream.mapError((error) => transform(error)))
|
||||
labels:
|
||||
- source: Stream.catch((error) => { return Stream.fail(transform(error)) })
|
||||
style: primary
|
||||
start: 12
|
||||
end: 77
|
||||
"stream.pipe(Stream.catch((error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error))))":
|
||||
fixed: "stream.pipe(Stream.mapError((error): Wrapped => transform(error)))"
|
||||
labels:
|
||||
- source: "Stream.catch((error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 98
|
||||
"stream.pipe(Stream.catch((error: Error) => Stream.fail(transform(error))))":
|
||||
fixed: "stream.pipe(Stream.mapError((error: Error) => transform(error)))"
|
||||
labels:
|
||||
- source: "Stream.catch((error: Error) => Stream.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 73
|
||||
"stream.pipe(Stream.catch((error: Error): Stream.Stream<string, Wrapped, Scope> => { return Stream.fail(transform(error)) }))":
|
||||
fixed: "stream.pipe(Stream.mapError((error: Error): Wrapped => transform(error)))"
|
||||
labels:
|
||||
- source: "Stream.catch((error: Error): Stream.Stream<string, Wrapped, Scope> => { return Stream.fail(transform(error)) })"
|
||||
style: primary
|
||||
start: 12
|
||||
end: 123
|
||||
stream.pipe(Stream.catch(error => Stream.fail(new Wrapped(error)))):
|
||||
fixed: stream.pipe(Stream.mapError((error) => new Wrapped(error)))
|
||||
labels:
|
||||
- source: Stream.catch(error => Stream.fail(new Wrapped(error)))
|
||||
style: primary
|
||||
start: 12
|
||||
end: 66
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
id: no-effect-catch-fail-tsx
|
||||
snapshots:
|
||||
const view = <Widget value={Effect.catch(effect, error => Effect.fail(new Wrapped(error)))} />:
|
||||
fixed: const view = <Widget value={Effect.mapError(effect, (error) => new Wrapped(error))} />
|
||||
labels:
|
||||
- source: Effect.catch(effect, error => Effect.fail(new Wrapped(error)))
|
||||
style: primary
|
||||
start: 28
|
||||
end: 90
|
||||
const view = <Widget value={Stream.catch(stream, error => Stream.fail(new Wrapped(error)))} />:
|
||||
fixed: const view = <Widget value={Stream.mapError(stream, (error) => new Wrapped(error))} />
|
||||
labels:
|
||||
- source: Stream.catch(stream, error => Stream.fail(new Wrapped(error)))
|
||||
style: primary
|
||||
start: 28
|
||||
end: 90
|
||||
const view = <Widget value={effect.pipe(Effect.catch((error) => Effect.fail(transform(error))))} />:
|
||||
fixed: const view = <Widget value={effect.pipe(Effect.mapError((error) => transform(error)))} />
|
||||
labels:
|
||||
- source: Effect.catch((error) => Effect.fail(transform(error)))
|
||||
style: primary
|
||||
start: 40
|
||||
end: 94
|
||||
const view = <Widget value={effect.pipe(Effect.catch((error) => { return Effect.fail(transform(error)) }))} />:
|
||||
fixed: const view = <Widget value={effect.pipe(Effect.mapError((error) => transform(error)))} />
|
||||
labels:
|
||||
- source: Effect.catch((error) => { return Effect.fail(transform(error)) })
|
||||
style: primary
|
||||
start: 40
|
||||
end: 105
|
||||
"const view = <Widget value={effect.pipe(Effect.catch((error: Error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error))))} />":
|
||||
fixed: "const view = <Widget value={effect.pipe(Effect.mapError((error: Error): Wrapped => transform(error)))} />"
|
||||
labels:
|
||||
- source: "Effect.catch((error: Error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 40
|
||||
end: 132
|
||||
const view = <Widget value={stream.pipe(Stream.catch((error) => Stream.fail(transform(error))))} />:
|
||||
fixed: const view = <Widget value={stream.pipe(Stream.mapError((error) => transform(error)))} />
|
||||
labels:
|
||||
- source: Stream.catch((error) => Stream.fail(transform(error)))
|
||||
style: primary
|
||||
start: 40
|
||||
end: 94
|
||||
const view = <Widget value={stream.pipe(Stream.catch((error) => { return Stream.fail(transform(error)) }))} />:
|
||||
fixed: const view = <Widget value={stream.pipe(Stream.mapError((error) => transform(error)))} />
|
||||
labels:
|
||||
- source: Stream.catch((error) => { return Stream.fail(transform(error)) })
|
||||
style: primary
|
||||
start: 40
|
||||
end: 105
|
||||
"const view = <Widget value={stream.pipe(Stream.catch((error: Error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error))))} />":
|
||||
fixed: "const view = <Widget value={stream.pipe(Stream.mapError((error: Error): Wrapped => transform(error)))} />"
|
||||
labels:
|
||||
- source: "Stream.catch((error: Error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error)))"
|
||||
style: primary
|
||||
start: 40
|
||||
end: 133
|
||||
@@ -0,0 +1,51 @@
|
||||
id: no-effect-catch-fail
|
||||
valid:
|
||||
- effect.pipe(Effect.mapError((error) => transform(error)))
|
||||
- Effect.mapError(effect, (error) => transform(error))
|
||||
- stream.pipe(Stream.mapError((error) => transform(error)))
|
||||
- Stream.mapError(stream, (error) => transform(error))
|
||||
- effect.pipe(Effect.catch((error) => Effect.fail(error)))
|
||||
- stream.pipe(Stream.catch((error) => Stream.fail(error)))
|
||||
- "effect.pipe(Effect.catch((error: Error) => Effect.fail(error)))"
|
||||
- "stream.pipe(Stream.catch((error: Error) => Stream.fail(error)))"
|
||||
- effect.pipe(Effect.catch((error) => Effect.fail((error))))
|
||||
- effect.pipe(Effect.catch((error) => { log(error); return Effect.fail(transform(error)) }))
|
||||
- stream.pipe(Stream.catch((error) => { log(error); return Stream.fail(transform(error)) }))
|
||||
- "effect.pipe(Effect.catch((error) => condition ? Effect.fail(transform(error)) : Effect.fail(other(error))))"
|
||||
- "stream.pipe(Stream.catch((error) => condition ? Stream.fail(transform(error)) : Stream.fail(other(error))))"
|
||||
- effect.pipe(Effect.catchCause((cause) => Effect.fail(transform(cause))))
|
||||
- stream.pipe(Stream.catchCause((cause) => Stream.fail(transform(cause))))
|
||||
- effect.pipe(Effect.catch((error) => cleanup.pipe(Effect.andThen(Effect.fail(transform(error))))))
|
||||
- stream.pipe(Stream.catch((error) => cleanup.pipe(Stream.concat(Stream.fail(transform(error))))))
|
||||
- effect.pipe(Other.catch((error) => Effect.fail(transform(error))))
|
||||
- stream.pipe(Other.catch((error) => Stream.fail(transform(error))))
|
||||
- effect.pipe(Effect.catch((error) => Stream.fail(transform(error))))
|
||||
- stream.pipe(Stream.catch((error) => Effect.fail(transform(error))))
|
||||
- Effect.catch(effect, options, (error) => Effect.fail(transform(error)))
|
||||
- Stream.catch(stream, options, (error) => Stream.fail(transform(error)))
|
||||
- effect.pipe(Effect.catch(function (error) { return Effect.fail(transform(error)) }))
|
||||
- stream.pipe(Stream.catch(function (error) { return Stream.fail(transform(error)) }))
|
||||
- "effect.pipe(Effect.catch((error): Other.Effect<never, Wrapped> => Effect.fail(transform(error))))"
|
||||
- "stream.pipe(Stream.catch((error): Other.Stream<string, Wrapped> => Stream.fail(transform(error))))"
|
||||
invalid:
|
||||
- effect.pipe(Effect.catch((error) => Effect.fail(transform(error))))
|
||||
- Effect.catch(effect, (error) => Effect.fail(transform(error)))
|
||||
- effect.pipe(Effect.catch(error => Effect.fail(new Wrapped(error))))
|
||||
- effect.pipe(Effect.catch((error) => { return Effect.fail(transform(error)) }))
|
||||
- Effect.catch(effect, error => { return Effect.fail(transform(error)) })
|
||||
- "effect.pipe(Effect.catch((error: Error) => Effect.fail(transform(error))))"
|
||||
- "effect.pipe(Effect.catch((error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error))))"
|
||||
- "effect.pipe(Effect.catch((error: Error): Effect.Effect<never, Wrapped, Scope> => { return Effect.fail(transform(error)) }))"
|
||||
- stream.pipe(Stream.catch((error) => Stream.fail(transform(error))))
|
||||
- Stream.catch(stream, (error) => Stream.fail(transform(error)))
|
||||
- stream.pipe(Stream.catch(error => Stream.fail(new Wrapped(error))))
|
||||
- stream.pipe(Stream.catch((error) => { return Stream.fail(transform(error)) }))
|
||||
- "stream.pipe(Stream.catch((error: Error) => Stream.fail(transform(error))))"
|
||||
- "stream.pipe(Stream.catch((error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error))))"
|
||||
- "stream.pipe(Stream.catch((error: Error): Stream.Stream<string, Wrapped, Scope> => { return Stream.fail(transform(error)) }))"
|
||||
- |
|
||||
effect.pipe(
|
||||
Effect.catch((error) =>
|
||||
Effect.fail(transform(error)),
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
id: no-effect-catch-fail-tsx
|
||||
valid:
|
||||
- const view = <Widget value={effect.pipe(Effect.mapError((error) => transform(error)))} />
|
||||
- const view = <Widget value={effect.pipe(Effect.catch((error) => Effect.fail(error)))} />
|
||||
- "const view = <Widget value={effect.pipe(Effect.catch((error: Error) => Effect.fail(error)))} />"
|
||||
- const view = <Widget value={effect.pipe(Effect.catch((error) => { log(error); return Effect.fail(transform(error)) }))} />
|
||||
- "const view = <Widget value={effect.pipe(Effect.catch((error) => condition ? Effect.fail(transform(error)) : Effect.fail(other(error))))} />"
|
||||
- const view = <Widget value={effect.pipe(Effect.catchCause((cause) => Effect.fail(transform(cause))))} />
|
||||
- const view = <Widget value={effect.pipe(Effect.catch((error) => cleanup.pipe(Effect.andThen(Effect.fail(transform(error))))))} />
|
||||
- const view = <Widget value={effect.pipe(Other.catch((error) => Effect.fail(transform(error))))} />
|
||||
- const view = <Widget value={stream.pipe(Stream.catch((error) => Effect.fail(transform(error))))} />
|
||||
- const view = <Widget value={Effect.catch(effect, options, (error) => Effect.fail(transform(error)))} />
|
||||
invalid:
|
||||
- const view = <Widget value={effect.pipe(Effect.catch((error) => Effect.fail(transform(error))))} />
|
||||
- const view = <Widget value={Effect.catch(effect, error => Effect.fail(new Wrapped(error)))} />
|
||||
- const view = <Widget value={effect.pipe(Effect.catch((error) => { return Effect.fail(transform(error)) }))} />
|
||||
- "const view = <Widget value={effect.pipe(Effect.catch((error: Error): Effect.Effect<never, Wrapped> => Effect.fail(transform(error))))} />"
|
||||
- const view = <Widget value={stream.pipe(Stream.catch((error) => Stream.fail(transform(error))))} />
|
||||
- const view = <Widget value={Stream.catch(stream, error => Stream.fail(new Wrapped(error)))} />
|
||||
- const view = <Widget value={stream.pipe(Stream.catch((error) => { return Stream.fail(transform(error)) }))} />
|
||||
- "const view = <Widget value={stream.pipe(Stream.catch((error: Error): Stream.Stream<string, Wrapped> => Stream.fail(transform(error))))} />"
|
||||
@@ -0,0 +1,75 @@
|
||||
id: no-effect-catch-fail-tsx
|
||||
language: Tsx
|
||||
message: Use mapError instead of catching only to fail with a transformed error.
|
||||
severity: error
|
||||
rule:
|
||||
all:
|
||||
- pattern: $MODULE.catch($$$ARGS)
|
||||
- any:
|
||||
- pattern: Effect.catch($$$SELF, ($ERROR) => Effect.fail($MAPPED))
|
||||
- pattern: Effect.catch($$$SELF, $ERROR => Effect.fail($MAPPED))
|
||||
- pattern: Effect.catch($$$SELF, ($ERROR) => { return Effect.fail($MAPPED) })
|
||||
- pattern: Effect.catch($$$SELF, $ERROR => { return Effect.fail($MAPPED) })
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => Effect.fail($MAPPED))"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => { return Effect.fail($MAPPED) })"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Effect.fail($MAPPED))"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Effect.fail($MAPPED) })"
|
||||
- pattern: Stream.catch($$$SELF, ($ERROR) => Stream.fail($MAPPED))
|
||||
- pattern: Stream.catch($$$SELF, $ERROR => Stream.fail($MAPPED))
|
||||
- pattern: Stream.catch($$$SELF, ($ERROR) => { return Stream.fail($MAPPED) })
|
||||
- pattern: Stream.catch($$$SELF, $ERROR => { return Stream.fail($MAPPED) })
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => Stream.fail($MAPPED))"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => { return Stream.fail($MAPPED) })"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Stream.fail($MAPPED))"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Stream.fail($MAPPED) })"
|
||||
- not:
|
||||
pattern: $MODULE.catch($_FIRST, $_SECOND, $$$REST)
|
||||
constraints:
|
||||
MAPPED:
|
||||
not:
|
||||
any:
|
||||
- kind: identifier
|
||||
- kind: parenthesized_expression
|
||||
rewriters:
|
||||
- id: unwrap-effect-fail-with-return-type-tsx
|
||||
rule:
|
||||
any:
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => Effect.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => { return Effect.fail($MAPPED) }"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Effect.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Effect.fail($MAPPED) }"
|
||||
fix: "($ERROR): $ERROR_TYPE => $MAPPED"
|
||||
- id: unwrap-stream-fail-with-return-type-tsx
|
||||
rule:
|
||||
any:
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => Stream.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => { return Stream.fail($MAPPED) }"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Stream.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Stream.fail($MAPPED) }"
|
||||
fix: "($ERROR): $ERROR_TYPE => $MAPPED"
|
||||
- id: unwrap-effect-fail-tsx
|
||||
rule:
|
||||
any:
|
||||
- pattern: ($ERROR) => Effect.fail($MAPPED)
|
||||
- pattern: $ERROR => Effect.fail($MAPPED)
|
||||
- pattern: ($ERROR) => { return Effect.fail($MAPPED) }
|
||||
- pattern: $ERROR => { return Effect.fail($MAPPED) }
|
||||
fix: ($ERROR) => $MAPPED
|
||||
- id: unwrap-stream-fail-tsx
|
||||
rule:
|
||||
any:
|
||||
- pattern: ($ERROR) => Stream.fail($MAPPED)
|
||||
- pattern: $ERROR => Stream.fail($MAPPED)
|
||||
- pattern: ($ERROR) => { return Stream.fail($MAPPED) }
|
||||
- pattern: $ERROR => { return Stream.fail($MAPPED) }
|
||||
fix: ($ERROR) => $MAPPED
|
||||
transform:
|
||||
MAPPED_ARGS:
|
||||
rewrite:
|
||||
rewriters:
|
||||
- unwrap-effect-fail-with-return-type-tsx
|
||||
- unwrap-stream-fail-with-return-type-tsx
|
||||
- unwrap-effect-fail-tsx
|
||||
- unwrap-stream-fail-tsx
|
||||
source: $$$ARGS
|
||||
fix: $MODULE.mapError($MAPPED_ARGS)
|
||||
@@ -0,0 +1,75 @@
|
||||
id: no-effect-catch-fail
|
||||
language: TypeScript
|
||||
message: Use mapError instead of catching only to fail with a transformed error.
|
||||
severity: error
|
||||
rule:
|
||||
all:
|
||||
- pattern: $MODULE.catch($$$ARGS)
|
||||
- any:
|
||||
- pattern: Effect.catch($$$SELF, ($ERROR) => Effect.fail($MAPPED))
|
||||
- pattern: Effect.catch($$$SELF, $ERROR => Effect.fail($MAPPED))
|
||||
- pattern: Effect.catch($$$SELF, ($ERROR) => { return Effect.fail($MAPPED) })
|
||||
- pattern: Effect.catch($$$SELF, $ERROR => { return Effect.fail($MAPPED) })
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => Effect.fail($MAPPED))"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => { return Effect.fail($MAPPED) })"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Effect.fail($MAPPED))"
|
||||
- pattern: "Effect.catch($$$SELF, ($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Effect.fail($MAPPED) })"
|
||||
- pattern: Stream.catch($$$SELF, ($ERROR) => Stream.fail($MAPPED))
|
||||
- pattern: Stream.catch($$$SELF, $ERROR => Stream.fail($MAPPED))
|
||||
- pattern: Stream.catch($$$SELF, ($ERROR) => { return Stream.fail($MAPPED) })
|
||||
- pattern: Stream.catch($$$SELF, $ERROR => { return Stream.fail($MAPPED) })
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => Stream.fail($MAPPED))"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => { return Stream.fail($MAPPED) })"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Stream.fail($MAPPED))"
|
||||
- pattern: "Stream.catch($$$SELF, ($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Stream.fail($MAPPED) })"
|
||||
- not:
|
||||
pattern: $MODULE.catch($_FIRST, $_SECOND, $$$REST)
|
||||
constraints:
|
||||
MAPPED:
|
||||
not:
|
||||
any:
|
||||
- kind: identifier
|
||||
- kind: parenthesized_expression
|
||||
rewriters:
|
||||
- id: unwrap-effect-fail-with-return-type
|
||||
rule:
|
||||
any:
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => Effect.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE> => { return Effect.fail($MAPPED) }"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Effect.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Effect.Effect<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Effect.fail($MAPPED) }"
|
||||
fix: "($ERROR): $ERROR_TYPE => $MAPPED"
|
||||
- id: unwrap-stream-fail-with-return-type
|
||||
rule:
|
||||
any:
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => Stream.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE> => { return Stream.fail($MAPPED) }"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => Stream.fail($MAPPED)"
|
||||
- pattern: "($ERROR): Stream.Stream<$_SUCCESS, $ERROR_TYPE, $_REQUIREMENTS> => { return Stream.fail($MAPPED) }"
|
||||
fix: "($ERROR): $ERROR_TYPE => $MAPPED"
|
||||
- id: unwrap-effect-fail
|
||||
rule:
|
||||
any:
|
||||
- pattern: ($ERROR) => Effect.fail($MAPPED)
|
||||
- pattern: $ERROR => Effect.fail($MAPPED)
|
||||
- pattern: ($ERROR) => { return Effect.fail($MAPPED) }
|
||||
- pattern: $ERROR => { return Effect.fail($MAPPED) }
|
||||
fix: ($ERROR) => $MAPPED
|
||||
- id: unwrap-stream-fail
|
||||
rule:
|
||||
any:
|
||||
- pattern: ($ERROR) => Stream.fail($MAPPED)
|
||||
- pattern: $ERROR => Stream.fail($MAPPED)
|
||||
- pattern: ($ERROR) => { return Stream.fail($MAPPED) }
|
||||
- pattern: $ERROR => { return Stream.fail($MAPPED) }
|
||||
fix: ($ERROR) => $MAPPED
|
||||
transform:
|
||||
MAPPED_ARGS:
|
||||
rewrite:
|
||||
rewriters:
|
||||
- unwrap-effect-fail-with-return-type
|
||||
- unwrap-stream-fail-with-return-type
|
||||
- unwrap-effect-fail
|
||||
- unwrap-stream-fail
|
||||
source: $$$ARGS
|
||||
fix: $MODULE.mapError($MAPPED_ARGS)
|
||||
Reference in New Issue
Block a user