Skip to content

Commit

Permalink
Create aliases via iteration to please Code Climate
Browse files Browse the repository at this point in the history
This class was exhibiting the following issue on Code Climate:

    Complex code in Twitter::REST::User definition outside of methods
    (complexity = 37)

Creating the aliases via iteration reduces the complexity to six.

/cc @brynary @mrb @noahd1
  • Loading branch information
sferik committed Feb 17, 2014
1 parent 21cdb74 commit 6c36831
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/twitter/user.rb
Expand Up @@ -21,16 +21,20 @@ class User < Twitter::BasicUser
:profile_sidebar_fill_color, :profile_text_color,
:profile_use_background_image, :protected, :statuses_count,
:time_zone, :utc_offset, :verified
alias_method :favorites_count, :favourites_count
remove_method :favourites_count
alias_method :profile_background_image_uri, :profile_background_image_url
alias_method :profile_background_image_uri_https, :profile_background_image_url_https
alias_method :translator?, :is_translator
alias_method :tweets_count, :statuses_count
object_attr_reader :Tweet, :status, :user
alias_method :tweet, :status
alias_method :tweet?, :status?
alias_method :tweeted?, :status?
{
:favorites_count => :favourites_count,
:profile_background_image_uri => :profile_background_image_url,
:profile_background_image_uri_https => :profile_background_image_url_https,
:translator? => :is_translator,
:tweets_count => :statuses_count,
:tweet => :status,
:tweet? => :status?,
:tweeted? => :status?,
}.each do |new_method, existing_method|
alias_method new_method, existing_method
end
remove_method :favourites_count

# @return [Array<Twitter::Entity::URI>]
def description_uris
Expand Down

0 comments on commit 6c36831

Please sign in to comment.