-
Notifications
You must be signed in to change notification settings - Fork 27
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
Shall we add an item to the code review that forbids setTimeout and setInterval? #59
Comments
We could catch these even more eagerly if we forbid them with lint rules. |
I'd prefer a lint rule to yet-another checklist item. |
I wonder what is best here. I see many setTimeout calls in places that seem fine to me. In aqua, the sonification wrappers, yotta. We use the same lint rules to lint those repos as we do sim code.
I wonder if @jonathanolson can speak to what these "reasons" are. I see tons of usages in joist, as well as implementations in some Timer types in common code. I think it warrants discussion before a blanket lint rule is implemented that isn't helpful because it creates too many false negatives. |
The reasons are that if window.setTimeout or window.setInterval are used, then generally it means the sim can't accurately be used to play back event streams in an identical fashion, since it depends on external timing (the setTimeout/setInterval will potentially execute at a different time, particularly if it shouldn't have been executed at all, e.g. if a sim is paused). In aqua/yotta (and potentially the sonification wrappers), it isn't in the sim, so it wouldn't affect playback. |
Makes sense thanks. I'm in favor of adding this item to the checklist, or somehow branching some eslint code into a Sim only and all lint rules. |
If there aren't too many occurrences outside of sim code, those cases could use |
I think we should explore a lint rule. |
There is already an item in the CRC. It was added by @samreid on 12/1/17. The commit message does not indicate that it was added to address this issue.
Adding these to bad-text.js lint rule seems problematic, since we may use those tokens elsewhere. |
Having a code-review item seems to have been sufficient for the past 2 years, so I propose that we close this issue and take no further action on the lint rule. |
I agree, but also thought I'd mention that there is bad text for only sims if you want to investigate adding them there. I'm a proponent of more list rules and less checklist items. This is both for Devs that have been here for ages, but also in helping the onboarding process. |
I agree that lint rules are preferred in general. But I do not think that they are always worth the cost in practice, or in this specific case. |
10/3/19 dev meeting: @zepumph is going to check for these in bad-text.js:
|
See also phetsims/chipper#737 if a regex is easier (I don't think it will be). |
Fixed in Area Builder, checked above. Unassigning myself. |
I'm all set, thanks @zepumph. Over to you @jonathanolson |
Apologies about the delay! Handled the above cases. A few have come up, and I'm not confident in handling them myself:
@jessegreenberg are you familiar with these cases? |
Thanks, these were easy to convert to stepTimer. These were the last ones so I added what was commented out in bad-sim-text in phetsims/chipper@56e2504. @samreid @zepumph is there anything else to do for this issue? |
Very exciting! Thanks |
In phetsims/energy-skate-park-basics#380 (comment) @jonathanolson said:
Should we add entries to the code review checklist forbidding
setTimeout
andsetInterval
?The text was updated successfully, but these errors were encountered: