From a5e4a95b0de5c8dbc036d38402c96df2dddc0a2c Mon Sep 17 00:00:00 2001 From: Gabriel Darbord <78592838+Gabriel-Darbord@users.noreply.github.com> Date: Mon, 20 Jul 2026 17:29:18 +0200 Subject: [PATCH] Add assignment-in-block compile critique --- src/MCP-Tests/MCPToolMethodMutationTest.class.st | 16 ++++++++++++++++ src/MCP/MCPToolMethodMutation.class.st | 1 + 2 files changed, 17 insertions(+) diff --git a/src/MCP-Tests/MCPToolMethodMutationTest.class.st b/src/MCP-Tests/MCPToolMethodMutationTest.class.st index 3c3b911..424624a 100644 --- a/src/MCP-Tests/MCPToolMethodMutationTest.class.st +++ b/src/MCP-Tests/MCPToolMethodMutationTest.class.st @@ -826,6 +826,22 @@ MCPToolMethodMutationTest >> testCompileReturnsAllowlistedWarningCritiques [ self removeSelector: selector from: MCPToolGetMethodTestTarget ] ] +{ #category : 'tests' } +MCPToolMethodMutationTest >> testCompileReturnsAssignmentInBlockCritique [ + + | selector | + selector := #assignmentInBlockProbe. + self removeSelector: selector from: MCPToolMethodMutationTestTarget. + [ + self + assertCompileForClassName: 'MCPToolMethodMutationTestTarget' + methodSource: 'assignmentInBlockProbe | value | [ value := 1 ] ensure: [ ] . ^ value' + protocol: 'tests' + returnsSingleCritiqueRuleClass: 'ReAssignmentInBlockRule' + titledLike: 'Unnecessary assignment or return in block' ] ensure: [ + self removeSelector: selector from: MCPToolMethodMutationTestTarget ] +] + { #category : 'tests' } MCPToolMethodMutationTest >> testCompileReturnsCollectionThenDoCritique [ diff --git a/src/MCP/MCPToolMethodMutation.class.st b/src/MCP/MCPToolMethodMutation.class.st index a7c1729..a5feaf8 100644 --- a/src/MCP/MCPToolMethodMutation.class.st +++ b/src/MCP/MCPToolMethodMutation.class.st @@ -57,6 +57,7 @@ MCPToolMethodMutation >> allowedNonErrorCritiqueRuleClasses [ MCPRespondsToUsageRule. MCPSelectSizeCountRule. MCPSortedCollectionConversionRule. + ReAssignmentInBlockRule. ReEquivalentSuperclassMethodsRule. ReExcessiveArgumentsRule. ReMissingSuperSendsRule.