Logic checking for return codes is incorrect #5

Closed
opened 2023-05-08 07:03:45 +00:00 by whosit · 3 comments

init.lua Line 79 in 679023774d
if not result.completed or not result.succeeded or not result.code == 200 then

init.lua Line 110 in 679023774d
if not result.completed or not result.succeeded or not result.code == 200 then

not has higher precedence than ==, so 200 will always be compared with false/true.

https://gitea.your-land.de/AliasAlreadyTaken/yl_matterbridge/src/commit/679023774d91ac3c2022bb1e60a81210a067cc4d/init.lua#L79 https://gitea.your-land.de/AliasAlreadyTaken/yl_matterbridge/src/commit/679023774d91ac3c2022bb1e60a81210a067cc4d/init.lua#L110 `not` has higher precedence than `==`, so `200` will always be compared with `false`/`true`.

Fixed in 095614a6b6

Fixed in https://gitea.your-land.de/AliasAlreadyTaken/yl_matterbridge/commit/095614a6b6c8c1c5dec0eb61b05ed5da88cb14b1
Author

if not result.completed or is OK

not (result.code == 200) can just be result.code ~= 200 it's more idiomatic that way.

I code in python more often than lua, so this caught me off guard too...

`if not result.completed or` is OK `not (result.code == 200)` can just be `result.code ~= 200` it's more idiomatic that way. I code in python more often than lua, so this caught me off guard too...

luaheck found that one, too, so I quickly fixed it :D

I'm not used to it either and I have no idea about python

luaheck found that one, too, so I quickly fixed it :D I'm not used to it either and I have no idea about python
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: AliasAlreadyTaken/yl_matterbridge#5
No description provided.