Closed ConjuringCoffee closed 1 year ago
This is a good one, the intention of the text is much clearer this way. Shouldn't it be more general, though? This is not only applicable for inline variables, one should generally not use variables outside of the scope where they have been declared.
This is a good one, the intention of the text is much clearer this way. Shouldn't it be more general, though? This is not only applicable for inline variables, one should generally not use variables outside of the scope where they have been declared.
I haven't thought about that before and I agree. I'll rephrase it again.
Do not use variables outside of the scope they are declared in
variables can never be used outside of their scope, https://en.wikipedia.org/wiki/Scope_(computer_science)
In computer programming, the scope of a name binding (an association of a name to an entity, such as a variable) is the part of a program where the name binding is valid
suggest something like "If a variable is declared in an optional branch, only use the variable inside that optional branch"
EDIT: or "Only use variables within the branch where its defined"
variables can never be used outside of their scope, https://en.wikipedia.org/wiki/Scope_(computer_science)
In computer programming, the scope of a name binding (an association of a name to an entity, such as a variable) is the part of a program where the name binding is valid
I found "scope" to be fitting with how I personally talk about this topic, but I can't argue with the actual definition of the word.
"If a variable is declared in an optional branch, only use the variable inside that optional branch"
EDIT: or "Only use variables within the branch where its defined"
Branch does fit better in this context, but I don't think it is necessary to call it "optional" - otherwise it would not be a branch anyway. I'm going to adapt your suggestion into my next commit...
I've also rephrased the rule to be about local variables. The rule doesn't make any sense for other kinds of variables like instance attributes.
I forgot the change the body of the rule, sorry 🤦♂️ I think its time to stop for today after I've corrected that...
Fixes #272.
I've rephrased the tile and the body of the rule.