-
-
Couldn't load subscription status.
- Fork 1k
Fix led_strip overlay #2362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix led_strip overlay #2362
Conversation
|
Can you please explain why all of this is required to fix what seems to be a relatively small bug? |
9d503df to
d94f015
Compare
668455b to
1b0197d
Compare
src/js/msp/MSPHelper.js
Outdated
| mask |= (led.x << 4); | ||
|
|
||
| for (const functionLetterIndex of led.functions) { | ||
| for (const functionLetterIndex in led.functions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to include all non-array properties of led.functions in this? If not then this is wrong, and the line below should be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed back to standard for loop is much more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using for ( of ) would be perfectly fine in these cases:
for (const directionLetter of led.directions) {
 const bitIndex = ledDirectionLetters.indexOf(directionLetter);
 if (bitIndex >= 0) {
 directionMask = bit_set(directionMask, bitIndex);
}
}
However, for ( in ) is not ok, as it iterates over a different set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow for ( of ) didn't work here, and for ( in ) did, but it's recommended not to use it as index while iterating over an array:
https://stackoverflow.com/questions/500504/why-is-using-for-in-for-array-iteration-a-bad-idea
src/js/msp/MSPHelper.js
Outdated
| } | ||
|
|
||
| for (const overlayLetterIndex of led.functions) { | ||
| for (const overlayLetterIndex in led.functions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
src/js/msp/MSPHelper.js
Outdated
| mask |= (led.color << 18); | ||
|
|
||
| for (const directionLetterIndex of led.directions) { | ||
| for (const directionLetterIndex in led.directions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
1b0197d to
8e8a15c
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
Fixes: #2359