Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP, not submitted upstream. Alternative to / follow-up for koalaman#3541, which exempts
yqfrom SC2016 entirely (same asjq).A single-quoted
$namein a yq expression is either a yq variable (.a as $id | $id) or a shell variable the user expected to expand ('.x = "$VAR"'). mikefarah/yq variables only exist if the expression declares them, and an undeclared one is silentlynull:So instead of exempting yq, warn only on
$names the command doesn't declare withas $name/ref $name, or pass with--arg/--argjson(kislyuk/yq). Other$forms (${...},$(...),$1) still warn. Declarations are collected across all single-quoted parts of the command, so a spliced value ('a as $x | '"$shell"' | $x') doesn't break it.yq '.metadata.name as $id | $id' deployment.yamlyq -i '.a ref $r | $r = 1' f.yamlyq '.x = "$VAR"' f.yamlyq '.x = $VAR' f.yamlyq '.a' '$HOME/f.yaml'Testing
prop_checkSingleQuotedVariables26–37;cabal testpasses.--norcon instrumentl/ai-servicedeploy/tests/*.sh: 0 SC2016 (0.11.0 reports 8).Open questions
$xdeclared in one argument allows$xin another.$ENV,$__loc__) and destructuring (. as {"a": $x}) still warn, same as today.strenv()is the right advice.-- could also check that user provides --arg), but that changes existing behavior.Written by Claude on behalf of @gkrimer.