Skip to content

Commit 0078453

Browse files
eordanoclaude
andauthored
fix(mcp): drop nullable local + null-forgiving suppression in press_input_action
PressInputActionTool.cs:86 copied ClickEntityTool's pre-ratchet `string? sceneId = arguments["sceneId"]?.Type == JTokenType.String ? arguments["sceneId"]!.Value<string>() : null;` into a new file, which re-triggers the diff-ratchet linter's nullable-local and null-forgiving-suppression BLOCK rules (CLAUDE.md § Anti-Patterns): the local was typed `string?` and read the same indexer expression twice, needing `!` to convince the compiler the second read was non-null after the first read's null-check. Root cause was the nullable local itself, not the `!` in isolation — removed both by never materializing a nullable local at all: the optional sceneId is now resolved with a single pattern-matched read (`arguments["sceneId"] is { Type: JTokenType.String } sceneIdToken`) inlined directly into the McpInputActionIntent constructor call, matching the ternaries already used for the adjacent eventType and holdSec arguments in the same call. No behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018c638dR1vPysCMbYt2qQg5
1 parent 3e8f051 commit 0078453

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

Explorer/Assets/DCL/McpServer/Tools/PressInputActionTool.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ public override async UniTask<McpToolResult> ExecuteAsync(JObject arguments, Can
8383

8484
float holdSec = Mathf.Clamp(arguments.GetFloat("holdSec", DEFAULT_HOLD_SEC), MIN_HOLD_SEC, MAX_HOLD_SEC);
8585
float timeoutSec = Mathf.Clamp(arguments.GetFloat("timeoutSec", DEFAULT_TIMEOUT_SEC), MIN_TIMEOUT_SEC, MAX_TIMEOUT_SEC);
86-
string? sceneId = arguments["sceneId"]?.Type == JTokenType.String ? arguments["sceneId"]!.Value<string>() : null;
8786

8887
var intent = new McpInputActionIntent(
8988
action.ToInputAction(),
90-
sceneId,
89+
arguments["sceneId"] is { Type: JTokenType.String } sceneIdToken ? sceneIdToken.Value<string>() : null,
9190
kind == PressKind.UP ? PointerEventType.PetUp : PointerEventType.PetDown,
9291
kind == PressKind.PRESS ? holdSec : null);
9392

0 commit comments

Comments
 (0)