-
Notifications
You must be signed in to change notification settings - Fork 158
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
Reduce Ruby warnings #124
Reduce Ruby warnings #124
Conversation
Problem === sassc-ruby displays warnings on load the gem if `-w` options is passed to ruby interpreter. ```console $ ruby -w -rsassc -e '' /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old list_get_length /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old list_get_length /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old list_get_value /home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old list_get_value ``` This pull request suppresses the warnings. Note === sassc-ruby has other warnings in test code, but this pull request does not suppress the warnings. Because they does not affect users. If you'd like to see the warning, you can execute `rake test` with `RUBYOPT=-w` environment variable.
@@ -42,7 +42,7 @@ module Native | |||
|
|||
# Remove the redundant "sass_" from the beginning of every method name | |||
def self.attach_function(*args) | |||
super if args.size != 3 | |||
return super if args.size != 3 |
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.
If args.size != 3
, the super method is called twice. It is meaningless, so it should return after super is called.
This change suppresses the following warnings.
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old version
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _make_data_context
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files
/home/pocke/.rbenv/versions/trunk/lib/ruby/gems/2.7.0/gems/ffi-1.11.1/lib/ffi/library.rb:275: warning: method redefined; discarding old _context_get_included_files
# ADDAPI size_t ADDCALL sass_list_get_length(const union Sass_Value* v) | ||
# ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i); | ||
attach_function :sass_list_get_length, [:sass_value_ptr], :size_t | ||
attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr |
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.
There are the same definitions here.
sassc-ruby/lib/sassc/native/native_functions_api.rb
Lines 59 to 60 in 266c904
# ADDAPI size_t ADDCALL sass_list_get_length (const union Sass_Value* v); | |
attach_function :sass_list_get_length, [:sass_value_ptr], :size_t |
sassc-ruby/lib/sassc/native/native_functions_api.rb
Lines 53 to 54 in 266c904
# ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i); | |
attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr |
Problem
sassc-ruby displays warnings on load the gem if
-w
options is passed to ruby interpreter.This pull request suppresses the warnings.
Note
sassc-ruby has other warnings in test code, but this pull request does not suppress the warnings. Because they does not affect users.
If you'd like to see the warning, you can execute
rake test
withRUBYOPT=-w
environment variable.