diff --git a/lib/mutant/cli/classifier.rb b/lib/mutant/cli/classifier.rb index f7749758..8bbaf6e9 100644 --- a/lib/mutant/cli/classifier.rb +++ b/lib/mutant/cli/classifier.rb @@ -8,8 +8,10 @@ module Mutant SCOPE_NAME_PATTERN = /[A-Za-z][A-Za-z_0-9]*/.freeze OPERATOR_PATTERN = Regexp.union(*OPERATOR_METHODS.map(&:to_s)).freeze - METHOD_NAME_PATTERN = /([_A-Za-z][A-Za-z0-9_]*[!?=]?|#{OPERATOR_PATTERN})/.freeze - SCOPE_PATTERN = /(?:::)?#{SCOPE_NAME_PATTERN}(?:::#{SCOPE_NAME_PATTERN})*/.freeze + METHOD_NAME_PATTERN = + /([_A-Za-z][A-Za-z0-9_]*[!?=]?|#{OPERATOR_PATTERN})/.freeze + SCOPE_PATTERN = + /(?:::)?#{SCOPE_NAME_PATTERN}(?:::#{SCOPE_NAME_PATTERN})*/.freeze CBASE_PATTERN = /\A::/.freeze SCOPE_OPERATOR = '::'.freeze SINGLETON_PATTERN = /\A(#{SCOPE_PATTERN})\z/.freeze @@ -36,9 +38,12 @@ module Mutant # @api private # def self.constant_lookup(location) - location.gsub(CBASE_PATTERN, EMPTY_STRING).split(SCOPE_OPERATOR).reduce(Object) do |parent, name| - parent.const_get(name) - end + location + .gsub(CBASE_PATTERN, EMPTY_STRING) + .split(SCOPE_OPERATOR) + .reduce(Object) do |parent, name| + parent.const_get(name) + end end # Return matchers for input diff --git a/lib/mutant/cli/classifier/method.rb b/lib/mutant/cli/classifier/method.rb index ff1df8bd..c4353a0e 100644 --- a/lib/mutant/cli/classifier/method.rb +++ b/lib/mutant/cli/classifier/method.rb @@ -10,7 +10,8 @@ module Mutant '#' => Matcher::Methods::Instance }.freeze - REGEXP = /\A(#{SCOPE_PATTERN})([.#])(#{METHOD_NAME_PATTERN}\z)/.freeze + REGEXP = + %r(\A(#{SCOPE_PATTERN})([.#])(#{METHOD_NAME_PATTERN}\z)).freeze # Positions of captured regexp groups SCOPE_NAME_POSITION = 1