Skip to content

Conversation

@haslinghuis
Copy link
Member

Fixes: #2359

@mikeller
Copy link
Member

Can you please explain why all of this is required to fix what seems to be a relatively small bug?

@haslinghuis haslinghuis force-pushed the fix-ledstrip branch 3 times, most recently from 9d503df to d94f015 Compare December 30, 2020 00:37
@haslinghuis haslinghuis marked this pull request as draft December 30, 2020 01:08
@mikeller mikeller added this to the 10.8.0 milestone Dec 30, 2020
@haslinghuis haslinghuis force-pushed the fix-ledstrip branch 2 times, most recently from 668455b to 1b0197d Compare January 3, 2021 20:19
@haslinghuis haslinghuis marked this pull request as ready for review January 3, 2021 22:23
mask |= (led.x << 4);

for (const functionLetterIndex of led.functions) {
for (const functionLetterIndex in led.functions) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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

}

for (const overlayLetterIndex of led.functions) {
for (const overlayLetterIndex in led.functions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

mask |= (led.color << 18);

for (const directionLetterIndex of led.directions) {
for (const directionLetterIndex in led.directions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 33 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mikeller mikeller merged commit f42cefc into betaflight:master Jan 5, 2021
@haslinghuis haslinghuis deleted the fix-ledstrip branch January 5, 2021 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LED Tab is broken

2 participants