Skip to content

Commit

Permalink
Merge pull request #399 from troessner/rename-codeparser-to-treewalker
Browse files Browse the repository at this point in the history
Rename `CodeParser` to `TreeWalker`.
  • Loading branch information
mvz committed Mar 3, 2015
2 parents 9609147 + a426e47 commit 172c855
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Metrics/AbcSize:
# FIXME: Make the class shorter
Metrics/ClassLength:
Exclude:
- lib/reek/core/code_parser.rb
- lib/reek/core/tree_walker.rb

# FIXME: Lower the method length by fixing the biggest offenders
Metrics/MethodLength:
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/core/code_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CodeContext
#
# class Omg; def foo(x); puts x; end; end
#
# the first time this is instantianted from CodeParser `context` is a StopContext:
# the first time this is instantianted from TreeWalker `context` is a StopContext:
#
# #<Reek::Core::StopContext:0x00000002231098 @name="">
#
Expand All @@ -35,7 +35,7 @@ class CodeContext
# (send nil :puts
# (lvar :x))))
#
# The next time we instantiate a CodeContext via CodeParser `context` would be:
# The next time we instantiate a CodeContext via TreeWalker `context` would be:
#
# Reek::Core::ModuleContext
#
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/core/sniffer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'reek/core/code_parser'
require 'reek/core/tree_walker'
require 'reek/core/smell_repository'
require 'reek/configuration/app_configuration'

Expand All @@ -17,7 +17,7 @@ def initialize(source, # Either Source::SourceFile or Source::SourceCode
end

def report_on(listener)
CodeParser.new(@smell_repository).process(syntax_tree) if syntax_tree
TreeWalker.new(@smell_repository).process(syntax_tree) if syntax_tree
@smell_repository.report_on(listener)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Core
# SMELL: This class is responsible for counting statements and for feeding
# each context to the smell repository.
# SMELL: This class has a name that doesn't match its responsibility.
class CodeParser
class TreeWalker
def initialize(smell_repository)
@smell_repository = smell_repository
@element = StopContext.new
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/source/sexp_node.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Reek
module Source
#
# Extensions to +AstNode+ to allow +CodeParser+ to navigate the abstract
# Extensions to +Sexp+ to allow +TreeWalker+ to navigate the abstract
# syntax tree more easily.
#
module SexpNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'spec_helper'
require 'reek/core/code_parser'
require 'reek/core/tree_walker'

include Reek::Core

describe CodeParser, 'with no method definitions' do
describe TreeWalker, 'with no method definitions' do
it 'reports no problems for empty source code' do
expect('').not_to reek
end
Expand All @@ -13,14 +13,14 @@ class Fred; end').not_to reek
end
end

describe CodeParser, 'with a global method definition' do
describe TreeWalker, 'with a global method definition' do
it 'reports no problems for simple method' do
src = 'def Outermost::fred() true; end'
expect(src).not_to reek
end
end

describe CodeParser, 'when a yield is the receiver' do
describe TreeWalker, 'when a yield is the receiver' do
it 'reports no problems' do
src = <<EOS
def values(*args)
Expand Down
2 changes: 1 addition & 1 deletion spec/reek/smells/duplicate_method_call_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'reek/smells/duplicate_method_call'
require 'reek/core/code_context'
require 'reek/core/code_parser'
require 'reek/core/tree_walker'
require 'reek/core/sniffer'
require 'reek/smells/smell_detector_shared'

Expand Down
4 changes: 2 additions & 2 deletions spec/reek/smells/feature_envy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def report
@report = Report.new
cf = SmellConfig.new
cf = cf.load_local(@dir) if @dir
CodeParser.new(@report, cf.smell_listeners).check_source(@source)
TreeWalker.new(@report, cf.smell_listeners).check_source(@source)
end
@report
end
Expand Down Expand Up @@ -231,7 +231,7 @@ def envious(other)
EOS
source = src.to_reek_source
sniffer = Reek::Core::Sniffer.new(source)
@mctx = Reek::Core::CodeParser.new(sniffer).process_def(source.syntax_tree)
@mctx = Reek::Core::TreeWalker.new(sniffer).process_def(source.syntax_tree)
@smells = @detector.examine_context(@mctx)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/reek/smells/too_many_statements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
def process_method(src)
source = src.to_reek_source
sniffer = Reek::Core::Sniffer.new(source)
Reek::Core::CodeParser.new(sniffer).process_def(source.syntax_tree)
Reek::Core::TreeWalker.new(sniffer).process_def(source.syntax_tree)
end

def process_singleton_method(src)
source = src.to_reek_source
sniffer = Reek::Core::Sniffer.new(source)
Reek::Core::CodeParser.new(sniffer).process_defs(source.syntax_tree)
Reek::Core::TreeWalker.new(sniffer).process_defs(source.syntax_tree)
end

describe Reek::Smells::TooManyStatements do
Expand Down
2 changes: 1 addition & 1 deletion spec/reek/smells/utility_function_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def simple(arga)
EOS
source = src.to_reek_source
sniffer = Reek::Core::Sniffer.new(source)
mctx = Reek::Core::CodeParser.new(sniffer).process_def(source.syntax_tree)
mctx = Reek::Core::TreeWalker.new(sniffer).process_def(source.syntax_tree)
@warning = @detector.examine_context(mctx)[0] # SMELL: too cumbersome!
end

Expand Down

0 comments on commit 172c855

Please sign in to comment.