Move parser node list to a separate file

* This should fix the "high complexity" codeclimate reports.
This commit is contained in:
Markus Schirp 2014-01-12 00:10:16 +01:00
parent a65c7bf36d
commit 0df898b0ef
2 changed files with 26 additions and 25 deletions

View file

@ -12,6 +12,7 @@ require 'digest/sha1'
require 'inflecto' require 'inflecto'
require 'parser' require 'parser'
require 'parser/current' require 'parser/current'
require 'parser-node-list'
require 'unparser' require 'unparser'
require 'ice_nine' require 'ice_nine'
require 'diff/lcs' require 'diff/lcs'
@ -21,31 +22,6 @@ require 'anima'
require 'concord' require 'concord'
require 'rspec' require 'rspec'
# Monkeypatch on parser with a list of allowed nodes.
# Will be pushed upstream once turning out to be correct.
module Parser
module Meta
NODE_TYPES =
%w(
true false nil int float str dstr str
sym dsym xstr regopt regexp array splat
array pair kwsplat hash irange erange self
lvar ivar cvar gvar const defined? lvasgn
ivasgn cvasgn gvasgn casgn mlhs masgn op_asgn
op_asgn and_asgn ensure rescue arg_expr
or_asgn and_asgn or_asgn back_ref nth_ref
match_with_lvasgn match_current_line
module class sclass def defs undef alias args
cbase arg optarg restarg blockarg block_pass args def kwarg kwoptarg
kwrestarg send super zsuper yield block send
and not or if when case while until while_post
until_post for break next redo return resbody
kwbegin begin retry preexe postexe iflipflop eflipflop
shadowarg
).map(&:to_sym).to_set.freeze
end # Meta
end # Parser
# Library namespace # Library namespace
module Mutant module Mutant
# The empty string used within this namespace # The empty string used within this namespace

25
lib/parser-node-list.rb Normal file
View file

@ -0,0 +1,25 @@
# Monkeypatch on parser with a list of allowed nodes.
# Will be pushed upstream once turning out to be correct.
module Parser
module Meta
NODE_TYPES =
%w(
true false nil int float str dstr str
sym dsym xstr regopt regexp array splat
array pair kwsplat hash irange erange self
lvar ivar cvar gvar const defined? lvasgn
ivasgn cvasgn gvasgn casgn mlhs masgn op_asgn
op_asgn and_asgn ensure rescue arg_expr
or_asgn and_asgn or_asgn back_ref nth_ref
match_with_lvasgn match_current_line
module class sclass def defs undef alias args
cbase arg optarg restarg blockarg block_pass args def kwarg kwoptarg
kwrestarg send super zsuper yield block send
and not or if when case while until while_post
until_post for break next redo return resbody
kwbegin begin retry preexe postexe iflipflop eflipflop
shadowarg
).map(&:to_sym).to_set.freeze
end # Meta
end # Parser