SketchUp / rubocop-sketchup

Rubocop cops for SketchUp - test against our Extension Warehouse technical requirements and other pitfalls
MIT License
14 stars 8 forks source link

Warn about usage of `sleep` #144

Closed thomthom closed 1 year ago

thomthom commented 4 years ago

Often the usage of sleep is a code smell. Consider a cop to flag this usage to guide EW reviewers for closer inspection of it's usage.

Eneroth3 commented 1 year ago

Are there examples of when sleep can be used? I'm thinking of how to phrase the message in the cop.

Reasons not to use it is how it freezes up SketchUp and UI.start_timer can maybe be used as an alternative.

thomthom commented 1 year ago

I've seen it usually as a way to deal with async behaviour. The appropriate solution would be to wait for an event that signal the completion of whatever you're waiting for. (Like HTTP requests)

Othertimes it can be animations.