From 7a83669eb30e76ccf90c601946c03e1552b61fd5 Mon Sep 17 00:00:00 2001 From: Yassin Kammoun <52890329+yassin-kammoun-sonarsource@users.noreply.github.com> Date: Mon, 31 Jul 2023 19:51:39 +0200 Subject: [PATCH] Modify rule S4043: Delimite consecutive snippets with a description (#2725) --- rules/S4043/javascript/rule.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rules/S4043/javascript/rule.adoc b/rules/S4043/javascript/rule.adoc index cdbbb85bc4..782f5e90fd 100644 --- a/rules/S4043/javascript/rule.adoc +++ b/rules/S4043/javascript/rule.adoc @@ -26,13 +26,16 @@ const reversed = a.toReversed(); const sorted = b.toSorted(); ---- -Alternatively, change a mutating method into a non-mutating alternative using the spread syntax (`...`) or `slice()` to create a copy first. +Alternatively, change a mutating method into a non-mutating alternative using the spread syntax (`...`). [source,javascript,diff-id=1,diff-type=compliant] ---- const reversed = [...a].reverse(); const sorted = [...b].sort(); ---- + +Or `slice()` to create a copy first. + [source,javascript,diff-id=1,diff-type=compliant] ---- const reversed = a.slice().reverse();