Skip to content

Commit 83d31e1

Browse files
SKUNK-1029 Document by_ref exception for shell rule S1481 (#5952)
* Document by_ref exception for shell rule S1481 Add exception to S1481 shell rule documenting that variables passed by reference to functions containing 'by_ref' in their name are considered used. This prevents false positives when variables are passed as plain word arguments to functions that modify them indirectly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Use "Special Cases" rather than exception This is not exactly an exception, we still check that it is used, but in another way. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e47d6d5 commit 83d31e1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

rules/S1481/shell/rule.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
include::../rationale.adoc[]
22

3+
=== Special Cases
4+
5+
Variables passed by reference to functions whose name contains `by_ref` are considered used. In bash, some functions accept variable names as plain word arguments (not `$var` expansions) and modify them indirectly. When such a function name contains `by_ref`, word arguments matching declared variable names are counted as legitimate usages.
6+
7+
[source,bash]
8+
----
9+
function process_data() {
10+
local result status # Compliant: result and status are used by reference
11+
get_values_by_ref result status
12+
}
13+
----
14+
315
include::../how-to-fix-it.adoc[]
416

517
=== Code examples

0 commit comments

Comments
 (0)