Skip to content

Commit ccf0d39

Browse files
committed
Fix cognitive complexity
1 parent 237b9c3 commit ccf0d39

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Plugin/Sharding/Table.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,12 @@ protected static function parseShards(string $shards): Set {
773773
* @param Map<string,Cluster> $clusterMap
774774
* @return void
775775
*/
776-
protected function handleShardCreationForRebalancing(Queue $queue, Vector $oldSchema, Vector $newSchema, Map $clusterMap): void {
776+
protected function handleShardCreationForRebalancing(
777+
Queue $queue,
778+
Vector $oldSchema,
779+
Vector $newSchema,
780+
Map $clusterMap
781+
): void {
777782
// Calculate original replication factor to ensure safe operations
778783
$originalRf = $this->calculateReplicationFactor($oldSchema);
779784

test/Buddy/src/Sharding/UtilTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testCreateShardingSchemaBalanced(): void {
5555
/**
5656
* Test rebalancing with RF=1 when adding new nodes - should NOT move shards
5757
*/
58+
// phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
5859
public function testRebalanceWithRf1AddingNodes(): void {
5960
// Create original schema with RF=1: 6 shards on 2 nodes
6061
$originalNodes = new Set(['node1', 'node2']);
@@ -98,7 +99,10 @@ public function testRebalanceWithRf1AddingNodes(): void {
9899
$this->assertNotNull($newNodeRow, 'New node should be present in rebalanced schema');
99100

100101
// CRITICAL: New node should have NO shards (RF=1 prevents data movement)
101-
$this->assertTrue($newNodeRow['shards']->isEmpty(), 'New node should have no shards with RF=1 to prevent data loss');
102+
$this->assertTrue(
103+
$newNodeRow['shards']->isEmpty(),
104+
'New node should have no shards with RF=1 to prevent data loss'
105+
);
102106

103107
// CRITICAL: Existing nodes should keep their EXACT original shards (no movement)
104108
foreach ($originalSchema as $originalRow) {
@@ -113,7 +117,8 @@ public function testRebalanceWithRf1AddingNodes(): void {
113117
$this->assertEquals(
114118
$originalRow['shards']->toArray(),
115119
$rebalancedRow['shards']->toArray(),
116-
"Node {$originalRow['node']} should keep its EXACT original shards with RF=1 - moving shards would cause data loss!"
120+
"Node {$originalRow['node']} should keep its EXACT original"
121+
. 'shards with RF=1 - moving shards would cause data loss!'
117122
);
118123
}
119124

0 commit comments

Comments
 (0)