Skip to content

Conversation

@romainbrenguier
Copy link
Contributor

Summary

  • Added exception to shell rule S1481 for variables passed by reference to functions containing by_ref in their name
  • Documents that plain word arguments (not $var expansions) to by_ref functions are counted as legitimate variable usages
  • Prevents false positives in bash completion functions and similar patterns where variables are modified indirectly

Context

The S1481 rule ("Unused local variables should be removed") was reporting false positives for bash patterns where variables are passed by reference to functions. In patterns like:

local result status
get_values_by_ref result status

The variables result and status appear as plain words (not $result or $status), which are not detected as variable usages by the tree-sitter grammar. The documentation now reflects that the rule recognizes this idiom by checking if the function name contains by_ref and counting word arguments matching declared variable names as legitimate usages.

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 <[email protected]>
@hashicorp-vault-sonar-prod
Copy link
Contributor

hashicorp-vault-sonar-prod bot commented Dec 3, 2025

SKUNK-1029

@sonarqube-next
Copy link

sonarqube-next bot commented Dec 3, 2025

Quality Gate passed Quality Gate passed for 'rspec-frontend'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@sonarqube-next
Copy link

sonarqube-next bot commented Dec 3, 2025

Quality Gate passed Quality Gate passed for 'rspec-tools'

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
0 Dependency risks
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant