njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
541 stars 135 forks source link

Add Rubocop and cleanup #96

Closed avellable closed 7 years ago

avellable commented 7 years ago

First of all, thank you so much for this gem. It saved a lot of time and effort for me. I was going through the code and thought, it can use some code cleanup. These changes simply apply the widely used ruby style guide using Rubocop. In my opinion, this will be helpful in maintaining and refactoring (if needed/planned).

I have broken up the commits very granular based on each type of offense fix, for ease of review. Please go through the commit one by one and let me know your feedback. Once changes are approved, I'll squash them in 3-4 commits.

avellable commented 7 years ago

Seems like the build is failing for older ruby versions. But since, the official support has been dropped for >= 1.9.3 rubies since Feb 2015, can we bump up the gem version please?

njh commented 7 years ago

Hello,

Thanks for doing this - it would be good to standardise the mqtt code.

Is it possible to only run rubocop for specific versions?

I am aware of people running ruby-mqtt on RedHat Enterprise Linux / CentOS.

RHEL 6 is still in its support period and amazingly is Ruby 1.8. Although Ruby 1.9 is available via Software Collections.

nick.

avellable commented 7 years ago

Hi @njh , Thank you for your feedback. I've made rubocop to be run only on versions > 2.0.0. Also, I've reverted few changes to support older ruby versions. All builds have passed now. Please take a look. Thanks.

njh commented 7 years ago

Thanks for doing this!