-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Don't write code that generates warnings #282
Conversation
I agree with this, although it basically implies that you're either running tests with the --warnings flag on, and/or that you're using the syntastic plugin. Both of these seem like reasonable assumptions, but I just wanted to point that out. |
Yup, good point. At least a couple of Rubocop's warnings (which we also catch with Hound) are designed based on |
👍 from me. I agree that actually ensuring you're notified of warnings as you work isn't as easy in Ruby as other languages, but I think that shouldn't stop us from having this explicit guide anyway. |
I like this too. Running your rails app with |
Is there a good list of things which will generate warnings in Ruby? Since you can't actually run with the warnings on, I think we either need to reference the list or list them out ourselves. |
I don't think there's a full list anywhere that I know of. Easiest way is to add
Ruby 2.2 also introduced an annoying new one "possible reference to past scope" which appears to occur any time you assign a variable with the same name as an argument for any block which existed in the same scope. Haven't seen it enough to know the full details of it, but there's an issue on redmine about it being hurtful in certain contexts. |
Here's an article that talks about how Ruby's verbose mode is broken: |
Yeah, I know from shoulda-matchers that warnings are painful and no one likes to turn them on because they're everywhere. I have them enabled but I actually had to write something to basically hide all non-related-shoulda warnings. Anyways, 👍 from me for this guideline. |
I'm going to 👍 writing warning-free code, we should atleast strive towards that all of the libraries we maintain/write should be warning free. I agree that it's painful with running with warnings on all of the time, so I usually warning-check my code every now and then like this: for file in $(find {app,spec,lib} -type f -iname "*.rb"); do
ruby -wc $file
done Is hounds list of warnings complete, or do we need to do some research to make it so? |
I don't see value in this guideline. The actual guide should be e.g. "avoid circular dependencies because it can cause loading issues" or "initialize instance variables before using them to avoid |
Hmm on second thought I actually agree with @mike-burns here. Seems like it would definitely be more useful to include guides that are more specific. |
That's what I did first in #280 but we ended up here. If there's a strong feeling for that one, I'll open that up and merge it but I don't feel strongly enough about this either way to manage the discussion so I'm going to close this one without merging. |
Lol. Okay. We are definitely silly sometimes. |
No description provided.