Browse files

Cleaned up naming after moving to ruby_parser.

  • Loading branch information...
1 parent db0c64d commit afa4f4317e5f3d3492e883bcb00de21dfef0afab @martinjandrews martinjandrews committed May 7, 2009
View
2 README.txt
@@ -29,7 +29,7 @@ Check one controller and all model files in a rails app:
Check all ruby files in a rails app with a custom configuration file:
roodi -config=my_roodi_config.yml "rails_app/**/*.rb"
-If you're writing a check, it is useful to see the structure of a file the way that Roodi tokenizes it (via ParseTree). Use:
+If you're writing a check, it is useful to see the structure of a file the way that Roodi tokenizes it (via ruby_parser). Use:
roodi-describe [filename]
== CUSTOM CONFIGURATION
View
2 Rakefile
@@ -8,7 +8,7 @@ require 'roodi'
Hoe.new('roodi', Roodi::VERSION) do |p|
p.developer('Marty Andrews', 'marty@cogentconsulting.com.au')
- p.extra_deps = ['ParseTree', 'facets']
+ p.extra_deps = ['ruby_parser', 'facets']
p.remote_rdoc_dir = ''
end
View
2 bin/roodi
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'roodi'
-runner = Roodi::Core::ParseTreeRunner.new
+runner = Roodi::Core::Runner.new
config_param = ARGV.detect {|arg| arg =~ /-config=.*/}
runner.config = config_param.split("=")[1] if config_param
View
2 bin/roodi-describe
@@ -3,5 +3,5 @@
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
require 'roodi'
-roodi = Roodi::Core::ParseTreeRunner.new
+roodi = Roodi::Core::Runner.new
roodi.print_file(ARGV[0])
View
3 lib/roodi/core.rb
@@ -1,2 +1 @@
-require 'roodi/core/parse_tree_runner'
-require 'roodi/core/ruby_parser_runner'
+require 'roodi/core/runner'
View
77 lib/roodi/core/parse_tree_runner.rb
@@ -1,77 +0,0 @@
-require 'pp'
-require 'yaml'
-
-require 'roodi/core/checking_visitor'
-require 'roodi/core/iterator_visitor'
-require 'roodi/core/parse_tree_parser'
-require 'roodi/core/visitable_sexp'
-
-module Roodi
- module Core
- class ParseTreeRunner
- DEFAULT_CONFIG = File.join(File.dirname(__FILE__), "..", "..", "..", "roodi.yml")
-
- attr_writer :config
-
- def initialize(*checks)
- @config = DEFAULT_CONFIG
- @checks = checks unless checks.empty?
- @parser = ParseTreeParser.new
- end
-
- def check(filename, content)
- @checks ||= load_checks
- node = parse(filename, content)
- node.accept(IteratorVisitor.new(CheckingVisitor.new(@checks))) if node
- end
-
- def check_content(content)
- check("dummy-file.rb", content)
- end
-
- def check_file(filename)
- check(filename, File.read(filename))
- end
-
- def print(filename, content)
- node = @parser.parse(content, filename)
- pp node
- end
-
- def print_content(content)
- print("dummy-file.rb", content)
- end
-
- def print_file(filename)
- print(filename, File.read(filename))
- end
-
- def errors
- @checks ||= []
- all_errors = @checks.collect {|check| check.errors}
- all_errors.flatten
- end
-
- private
-
- def parse(filename, content)
- begin
- @parser.parse(content, filename)
- rescue Exception => e
- puts "#{filename} looks like it's not a valid Ruby file. Skipping..." if ENV["ROODI_DEBUG"]
- nil
- end
- end
-
- def load_checks
- check_objects = []
- checks = YAML.load_file @config
- checks.each do |check|
- klass = eval("Roodi::Checks::#{check[0]}")
- check_objects << (check[1].empty? ? klass.new : klass.new(check[1]))
- end
- check_objects
- end
- end
- end
-end
View
2 lib/roodi/core/ruby_parser_parser.rb → lib/roodi/core/parser.rb
@@ -5,7 +5,7 @@
module Roodi
module Core
- class RubyParserParser
+ class Parser
def parse(content, filename)
silence_stream(STDERR) do
return silent_parse(content, filename)
View
6 lib/roodi/core/ruby_parser_runner.rb → lib/roodi/core/runner.rb
@@ -3,20 +3,20 @@
require 'roodi/core/checking_visitor'
require 'roodi/core/iterator_visitor'
-require 'roodi/core/ruby_parser_parser'
+require 'roodi/core/parser'
require 'roodi/core/visitable_sexp'
module Roodi
module Core
- class RubyParserRunner
+ class Runner
DEFAULT_CONFIG = File.join(File.dirname(__FILE__), "..", "..", "..", "roodi.yml")
attr_writer :config
def initialize(*checks)
@config = DEFAULT_CONFIG
@checks = checks unless checks.empty?
- @parser = RubyParserParser.new
+ @parser = Parser.new
end
def check(filename, content)
View
2 lib/roodi_task.rb
@@ -18,7 +18,7 @@ def initialize name = :roodi, patterns = nil, config = nil
def define
desc "Check for design issues in: #{patterns.join(', ')}"
task name do
- runner = Roodi::Core::ParseTreeRunner.new
+ runner = Roodi::Core::Runner.new
runner.config = config if config
View
2 spec/roodi/checks/abc_metric_method_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::AbcMetricMethodCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::AbcMetricMethodCheck.new({'score' => 0}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::AbcMetricMethodCheck.new({'score' => 0}))
end
def verify_content_score(content, a, b, c)
View
2 spec/roodi/checks/assignment_in_conditional_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::AssignmentInConditionalCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::AssignmentInConditionalCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::AssignmentInConditionalCheck.new)
end
it "should accept an assignment before an if clause" do
View
2 spec/roodi/checks/case_missing_else_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::CaseMissingElseCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::CaseMissingElseCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::CaseMissingElseCheck.new)
end
it "should accept case statements that do have an else" do
View
2 spec/roodi/checks/class_line_count_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ClassLineCountCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ClassLineCountCheck.new({'line_count' => 1}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassLineCountCheck.new({'line_count' => 1}))
end
it "should accept classes with less lines than the threshold" do
View
2 spec/roodi/checks/class_name_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ClassNameCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ClassNameCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassNameCheck.new)
end
it "should accept camel case class names starting in capitals" do
View
2 spec/roodi/checks/class_variable_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ClassVariableCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ClassVariableCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ClassVariableCheck.new)
end
it "should reject class variables" do
View
2 spec/roodi/checks/control_coupling_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ControlCouplingCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ControlCouplingCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ControlCouplingCheck.new)
end
it "should reject methods with if checks using a parameter" do
View
2 spec/roodi/checks/cyclomatic_complexity_block_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::CyclomaticComplexityBlockCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::CyclomaticComplexityBlockCheck.new({'complexity' => 0}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityBlockCheck.new({'complexity' => 0}))
end
def verify_content_complexity(content, complexity)
View
2 spec/roodi/checks/cyclomatic_complexity_method_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::CyclomaticComplexityMethodCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::CyclomaticComplexityMethodCheck.new({'complexity' => 0}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::CyclomaticComplexityMethodCheck.new({'complexity' => 0}))
end
def verify_content_complexity(content, complexity)
View
2 spec/roodi/checks/empty_rescue_body_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::EmptyRescueBodyCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::EmptyRescueBodyCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::EmptyRescueBodyCheck.new)
end
it "should accept a rescue body with content and no parameter" do
View
2 spec/roodi/checks/for_loop_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ForLoopCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ForLoopCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ForLoopCheck.new)
end
it "should reject for loops" do
View
2 spec/roodi/checks/method_line_count_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::MethodLineCountCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::MethodLineCountCheck.new({'line_count' => 1}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodLineCountCheck.new({'line_count' => 1}))
end
it "should accept methods with less lines than the threshold" do
View
2 spec/roodi/checks/method_name_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::MethodNameCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::MethodNameCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::MethodNameCheck.new)
end
it "should accept method names with underscores" do
View
2 spec/roodi/checks/module_line_count_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ModuleLineCountCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ModuleLineCountCheck.new({'line_count' => 1}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleLineCountCheck.new({'line_count' => 1}))
end
it "should accept modules with less lines than the threshold" do
View
2 spec/roodi/checks/module_name_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ModuleNameCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ModuleNameCheck.new)
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ModuleNameCheck.new)
end
it "should accept camel case module names starting in capitals" do
View
2 spec/roodi/checks/parameter_number_check_spec.rb
@@ -2,7 +2,7 @@
describe Roodi::Checks::ParameterNumberCheck do
before(:each) do
- @roodi = Roodi::Core::RubyParserRunner.new(Roodi::Checks::ParameterNumberCheck.new({'parameter_count' => 1}))
+ @roodi = Roodi::Core::Runner.new(Roodi::Checks::ParameterNumberCheck.new({'parameter_count' => 1}))
end
it "should accept methods with less lines than the threshold" do

0 comments on commit afa4f43

Please sign in to comment.