xijo / reverse_markdown

Ruby gem to convert html into markdown
Do What The F*ck You Want To Public License
628 stars 118 forks source link

Reduce warnings #80

Closed pocke closed 4 years ago

pocke commented 4 years ago

This pull request reduces warnings.

Remove rubyforge_project from gemspec

https://github.com/xijo/reverse_markdown/commit/1880de49fc5dc8e5500247b5ded2803566a9c886

It removes s.rubyforge_project = "reverse_markdown". Because rubygems displays the following warning.

NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /home/pocke/ghq/github.com/xijo/reverse_markdown/reverse_markdown.gemspec:14.

Remove -rubygems from argument of IRB

https://github.com/xijo/reverse_markdown/commit/af11e53e750e388ad8db76ae327a462cd788d187

rake console displays a LoadError, since Ruby 2.5.

$ bundle exec rake console
irb -rubygems -I lib -r reverse_markdown.rb
/home/pocke/.rbenv/versions/trunk/lib/ruby/2.7.0/irb/init.rb:290: warning: LoadError: cannot load such file -- ubygems
irb(main):001:0> 

Becuase ubygems has been removed since Ruby 2.5. And it is unnecessary since Ruby 1.9. So we can just remove it. ref: https://www.engineyard.com/blog/goodbye-ubygems

By the way, I'm not sure why IRB only displays LoadError, not exits. :thinking:

Reduce Ruby warnings

https://github.com/xijo/reverse_markdown/commit/77dab445c228832651f5012fcfff947e0d962c96

Ruby displays warnings for config.rb with -w option.

$ ruby -Ilib -rreverse_markdown -w -e '' 
/home/pocke/ghq/github.com/xijo/reverse_markdown/lib/reverse_markdown/config.rb:22: warning: method redefined; discarding old unknown_tags
/home/pocke/ghq/github.com/xijo/reverse_markdown/lib/reverse_markdown/config.rb:26: warning: method redefined; discarding old github_flavored
/home/pocke/ghq/github.com/xijo/reverse_markdown/lib/reverse_markdown/config.rb:30: warning: method redefined; discarding old tag_border
/home/pocke/ghq/github.com/xijo/reverse_markdown/lib/reverse_markdown/config.rb:34: warning: method redefined; discarding old force_encoding

Config uses attr_accessor, but it also defines readers, so it warns.

# It defines `unknown_tags` and `unknown_tags=`, and so on
attr_accessor :unknown_tags, :github_flavored, :tag_border, :force_encoding

# It overrides the method defined by attr_accessor.
def unknown_tags
  # ...
end

So I replace attr_accessor with attr_writer. It does not affect behavior.


Thank you for the great product!

xijo commented 4 years ago

Sounds great, thanks! :+1: