-
Notifications
You must be signed in to change notification settings - Fork 303
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
fix ruby warnings and remove obviously unused code #526
Conversation
aiomaster
commented
Oct 30, 2017
- fixes uninitialized instance variable warnings by initializing them
- remove methods that can never be called, cause they are defined twice
* fixes uninitialized instance variable warnings by initializing them * remove methods that can never be called, cause they are defined twice
@@ -303,10 +307,6 @@ def start | |||
@transport.post_initialize_socket | |||
@transport.connect | |||
|
|||
if @socket_configurator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were these lines removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find any usage of that instance variable. How would you set it? session.set_instance_variable('@socket_configurator', ...)
?
Besides it looks, as if you can just use the configure_socket
method of the Session
class to reach the same thing. So in my opinion these lines were useless or do you have a usecase?
@@ -31,6 +31,7 @@ class Transport | |||
attr_writer :read_timeout | |||
|
|||
def initialize(session, host, port, opts) | |||
@socket = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a weird thing to do (in Ruby anyway).
Thank you for your time but this PR removes some code that is actually used and tries to make perfectly common idioms (such as the use of |
@michaelklishin Can you please tell me a little bit more what part of that code I removed is actually used? Do you have examples or snippets that don't work anymore after these changes? If you think the ruby warnings for uninitialized instance variables are useless consider following example:
I think one reason is, to safe you for misspelled class variables, if you take the warnings serious. If you don't like it, ok, but the other warnings that this PR wanted to fix, could be worth to investigate further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes are reasonable
@@ -47,7 +47,7 @@ def self.open(host, port, options = {}) | |||
# @return [String] Data read from the socket | |||
# @api public | |||
def read_fully(count, timeout = nil) | |||
return nil if @__bunny_socket_eof_flag__ | |||
return nil if defined?(@__bunny_socket_eof_flag__) && @__bunny_socket_eof_flag__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think checking if instance variables is defined is needed here
@aiomaster you are solving a problem that does not exist (in Ruby and dialects of Lisp). Uninitialized ivars are evaluated to do_something if value is a perfectly fine, extremely common idiom in Ruby. You haven't provided any details on what warnings you are trying to fix which does not help your case. |