Permalink
Browse files

Remove Feature Envy code smell from Inflecto#add_irregular

  • Loading branch information...
1 parent f0a181c commit 21424145c26e30e318f33b149f49a3e5e3345e31 @dkubb dkubb committed Mar 18, 2013
Showing with 3 additions and 3 deletions.
  1. +1 −1 config/flay.yml
  2. +2 −2 lib/inflecto/inflections.rb
View
@@ -1,3 +1,3 @@
---
threshold: 14
-total_score: 74
+total_score: 71
@@ -157,11 +157,11 @@ def irregular(singular, plural)
# @api private
#
def add_irregular(rule, replacement, target)
- rule(Regexp.new("(#{rule[0,1]})#{rule[1..-1]}$", "i"), '\1' + replacement[1..-1], target)
+ head, *tail = rule.chars.to_a
+ rule(Regexp.new("(#{head})#{tail.join}$", 'i'), '\1' + replacement[1..-1], target)
end
private :add_irregular
-
# Add uncountable words
#
# Uncountable will not be inflected

0 comments on commit 2142414

Please sign in to comment.