kevinrutherford-reek 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/History.txt +42 -22
  2. data/config/defaults.reek +1 -0
  3. data/lib/reek.rb +1 -1
  4. data/lib/reek/block_context.rb +27 -5
  5. data/lib/reek/class_context.rb +5 -4
  6. data/lib/reek/code_parser.rb +26 -11
  7. data/lib/reek/method_context.rb +18 -12
  8. data/lib/reek/module_context.rb +1 -1
  9. data/lib/reek/name.rb +8 -1
  10. data/lib/reek/object_refs.rb +2 -3
  11. data/lib/reek/report.rb +11 -4
  12. data/lib/reek/sexp_formatter.rb +4 -46
  13. data/lib/reek/smells/large_class.rb +26 -7
  14. data/lib/reek/smells/long_parameter_list.rb +1 -1
  15. data/lib/reek/smells/smells.rb +4 -8
  16. data/lib/reek/source.rb +31 -4
  17. data/lib/reek/spec.rb +6 -0
  18. data/lib/reek/stop_context.rb +4 -16
  19. data/lib/reek/yield_call_context.rb +1 -3
  20. data/reek.gemspec +8 -5
  21. data/spec/reek/block_context_spec.rb +40 -0
  22. data/spec/reek/class_context_spec.rb +11 -0
  23. data/spec/reek/code_context_spec.rb +2 -1
  24. data/spec/reek/code_parser_spec.rb +0 -10
  25. data/spec/reek/config_spec.rb +2 -2
  26. data/spec/reek/method_context_spec.rb +14 -0
  27. data/spec/reek/name_spec.rb +13 -0
  28. data/spec/reek/object_refs_spec.rb +11 -9
  29. data/spec/reek/report_spec.rb +1 -1
  30. data/spec/reek/sexp_formatter_spec.rb +5 -4
  31. data/spec/reek/singleton_method_context_spec.rb +1 -1
  32. data/spec/reek/smells/duplication_spec.rb +2 -2
  33. data/spec/reek/smells/feature_envy_spec.rb +132 -36
  34. data/spec/reek/smells/large_class_spec.rb +48 -47
  35. data/spec/reek/smells/long_method_spec.rb +1 -1
  36. data/spec/reek/smells/long_parameter_list_spec.rb +4 -11
  37. data/spec/reek/smells/uncommunicative_name_spec.rb +6 -1
  38. data/spec/reek/smells/utility_function_spec.rb +6 -9
  39. data/spec/{samples → slow}/inline_spec.rb +14 -10
  40. data/spec/{samples → slow}/optparse_spec.rb +20 -12
  41. data/spec/{samples → slow}/redcloth_spec.rb +16 -8
  42. data/spec/{integration → slow}/reek_source_spec.rb +0 -0
  43. data/spec/{samples → slow/samples}/inline.rb +0 -0
  44. data/spec/{samples → slow/samples}/optparse.rb +0 -0
  45. data/spec/{samples → slow/samples}/redcloth.rb +0 -0
  46. data/spec/{integration → slow}/script_spec.rb +0 -0
  47. data/spec/{reek/source_spec.rb → slow/source_list_spec.rb} +3 -3
  48. data/spec/spec_helper.rb +2 -0
  49. data/tasks/rspec.rake +1 -1
  50. metadata +24 -12
@@ -9,8 +9,9 @@ module Reek
9
9
  # instance variables, methods or lines of code.
10
10
  #
11
11
  # Currently +LargeClass+ only reports classes having more than a
12
- # configurable number of methods. This includes public, protected and
13
- # private methods, but excludes methods inherited from superclasses or
12
+ # configurable number of methods or instance variables. The method count
13
+ # includes public, protected and
14
+ # private methods, and excludes methods inherited from superclasses or
14
15
  # included modules.
15
16
  #
16
17
  class LargeClass < SmellDetector
@@ -19,6 +20,10 @@ module Reek
19
20
  # permitted in a class.
20
21
  MAX_ALLOWED_METHODS_KEY = 'max_methods'
21
22
 
23
+ # The name of the config field that sets the maximum number of instance
24
+ # variables permitted in a class.
25
+ MAX_ALLOWED_IVARS_KEY = 'max_instance_variables'
26
+
22
27
  def self.contexts # :nodoc:
23
28
  [:class]
24
29
  end
@@ -26,6 +31,7 @@ module Reek
26
31
  def self.default_config
27
32
  super.adopt(
28
33
  MAX_ALLOWED_METHODS_KEY => 25,
34
+ MAX_ALLOWED_IVARS_KEY => 9,
29
35
  EXCLUDE_KEY => ['Array', 'Hash', 'Module', 'String']
30
36
  )
31
37
  end
@@ -33,17 +39,30 @@ module Reek
33
39
  def initialize(config = LargeClass.default_config)
34
40
  super
35
41
  @max_methods = config[MAX_ALLOWED_METHODS_KEY]
42
+ @max_instance_variables = config[MAX_ALLOWED_IVARS_KEY]
43
+ end
44
+
45
+ def check_num_methods(klass, report) # :nodoc:
46
+ count = klass.num_methods
47
+ return if count <= @max_methods
48
+ report << SmellWarning.new(self, klass,
49
+ "has at least #{count} methods")
50
+ end
51
+
52
+ def check_num_ivars(klass, report) # :nodoc:
53
+ count = klass.variable_names.length
54
+ return if count <= @max_instance_variables
55
+ report << SmellWarning.new(self, klass,
56
+ "has at least #{count} instance variables")
36
57
  end
37
58
 
38
59
  #
39
- # Checks the length of the given +klass+.
60
+ # Checks +klass+ for too many methods or too many instance variables.
40
61
  # Any smells found are added to the +report+.
41
62
  #
42
63
  def examine_context(klass, report)
43
- num_methods = klass.num_methods
44
- return false if num_methods <= @max_methods
45
- report << SmellWarning.new(self, klass,
46
- "has at least #{num_methods} methods")
64
+ check_num_methods(klass, report)
65
+ check_num_ivars(klass, report)
47
66
  end
48
67
  end
49
68
  end
@@ -27,7 +27,7 @@ module Reek
27
27
  @max_params = config['max_params']
28
28
  @action = 'has'
29
29
  end
30
-
30
+
31
31
  #
32
32
  # Checks the number of parameters in the given scope.
33
33
  # Any smells found are added to the +report+.
@@ -11,13 +11,10 @@ require 'reek/smells/utility_function'
11
11
  require 'yaml'
12
12
 
13
13
  class Hash
14
- def value_merge!(other)
15
- other.keys.each do |key|
16
- self[key].adopt!(other[key])
17
- end
18
- self
14
+ def push_keys(hash)
15
+ keys.each {|key| hash[key].adopt!(self[key]) }
19
16
  end
20
-
17
+
21
18
  def adopt!(other)
22
19
  other.keys.each do |key|
23
20
  ov = other[key]
@@ -69,8 +66,7 @@ module Reek
69
66
  def load_local(file)
70
67
  path = File.expand_path(file)
71
68
  all_reekfiles(path).each do |rfile|
72
- cf = YAML.load_file(rfile)
73
- @config.value_merge!(cf)
69
+ YAML.load_file(rfile).push_keys(@config)
74
70
  end
75
71
  self
76
72
  end
data/lib/reek/source.rb CHANGED
@@ -12,6 +12,14 @@ module Reek
12
12
  #
13
13
  class Source
14
14
 
15
+ #
16
+ # Factory method: creates a +Source+ from obj.
17
+ # The code is not parsed until +report+ is called.
18
+ #
19
+ def self.from_object(obj)
20
+ return ObjectSource.new(obj, obj.to_s)
21
+ end
22
+
15
23
  #
16
24
  # Factory method: creates a +Source+ object by reading Ruby code from
17
25
  # the +IO+ stream. The stream is consumed upto end-of-file, but the
@@ -57,10 +65,15 @@ module Reek
57
65
  SourceList.new(sources)
58
66
  end
59
67
 
60
- def initialize(code, desc, dir = '.') # :nodoc:
68
+ def initialize(code, desc, dir = nil) # :nodoc:
61
69
  @source = code
62
- @dir = dir
63
70
  @desc = desc
71
+ @cf = SmellConfig.new
72
+ @cf = @cf.load_local(dir) if dir
73
+ end
74
+
75
+ def check(parser) # :nodoc:
76
+ parser.check_source(@source)
64
77
  end
65
78
 
66
79
  #
@@ -71,8 +84,7 @@ module Reek
71
84
  def report
72
85
  unless @report
73
86
  @report = Report.new
74
- smells = SmellConfig.new.load_local(@dir).smell_listeners
75
- CodeParser.new(@report, smells).check_source(@source)
87
+ check(CodeParser.new(@report, @cf.smell_listeners))
76
88
  end
77
89
  @report
78
90
  end
@@ -89,6 +101,12 @@ module Reek
89
101
  report.any? { |smell| smell.matches?(smell_class, patterns) }
90
102
  end
91
103
 
104
+ # Creates a formatted report of all the +Smells::SmellWarning+ objects recorded in
105
+ # this report, with a heading.
106
+ def full_report
107
+ report.full_report(@desc)
108
+ end
109
+
92
110
  def to_s
93
111
  @desc
94
112
  end
@@ -110,4 +128,13 @@ module Reek
110
128
  ReportList.new(@sources)
111
129
  end
112
130
  end
131
+
132
+ #
133
+ # Represents an in-memory object that will be checked for smells.
134
+ #
135
+ class ObjectSource < Source
136
+ def check(parser) # :nodoc:
137
+ parser.check_object(@source)
138
+ end
139
+ end
113
140
  end
data/lib/reek/spec.rb CHANGED
@@ -113,6 +113,12 @@ module Reek
113
113
  end
114
114
  end
115
115
 
116
+ class Object
117
+ def to_source
118
+ Reek::Source.from_object(self)
119
+ end
120
+ end
121
+
116
122
  class File
117
123
  def to_source
118
124
  Reek::Source.from_f(self)
@@ -5,6 +5,10 @@ module Reek
5
5
  @refs = ObjectRefs.new
6
6
  @myself = Object
7
7
  end
8
+ def method_missing(method, *args)
9
+ nil
10
+ end
11
+
8
12
 
9
13
  def count_statements(num)
10
14
  0
@@ -39,22 +43,6 @@ module Reek
39
43
  false
40
44
  end
41
45
 
42
- def record_call_to(exp)
43
- nil
44
- end
45
-
46
- def record_method(name)
47
- end
48
-
49
- def record_parameter(sym)
50
- end
51
-
52
- def record_instance_variable(sym)
53
- end
54
-
55
- def record_local_variable(sym)
56
- end
57
-
58
46
  def outer_name
59
47
  ''
60
48
  end
@@ -6,9 +6,7 @@ module Reek
6
6
 
7
7
  def initialize(outer, exp)
8
8
  super
9
- @parameters = []
10
- args = exp[1]
11
- @parameters = args[0...-1] if args
9
+ @parameters = exp[1..-1]
12
10
  end
13
11
  end
14
12
  end
data/reek.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reek}
5
- s.version = "1.0.1"
5
+ s.version = "1.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Kevin Rutherford"]
9
- s.date = %q{2009-04-06}
9
+ s.date = %q{2009-05-08}
10
10
  s.default_executable = %q{reek}
11
11
  s.description = %q{Code smell detector for Ruby}
12
12
  s.email = ["kevin@rutherford-software.com"]
13
13
  s.executables = ["reek"]
14
14
  s.extra_rdoc_files = ["History.txt", "README.txt"]
15
- s.files = ["History.txt", "README.txt", "Rakefile", "bin/reek", "config/defaults.reek", "lib/reek.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/exceptions.reek", "lib/reek/if_context.rb", "lib/reek/method_context.rb", "lib/reek/module_context.rb", "lib/reek/name.rb", "lib/reek/object_refs.rb", "lib/reek/options.rb", "lib/reek/rake_task.rb", "lib/reek/report.rb", "lib/reek/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/duplication.rb", "lib/reek/smells/feature_envy.rb", "lib/reek/smells/large_class.rb", "lib/reek/smells/long_method.rb", "lib/reek/smells/long_parameter_list.rb", "lib/reek/smells/long_yield_list.rb", "lib/reek/smells/nested_iterators.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/smells.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/source.rb", "lib/reek/spec.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/integration/reek_source_spec.rb", "spec/integration/script_spec.rb", "spec/reek/class_context_spec.rb", "spec/reek/code_context_spec.rb", "spec/reek/code_parser_spec.rb", "spec/reek/config_spec.rb", "spec/reek/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/options_spec.rb", "spec/reek/report_spec.rb", "spec/reek/sexp_formatter_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/duplication_spec.rb", "spec/reek/smells/feature_envy_spec.rb", "spec/reek/smells/large_class_spec.rb", "spec/reek/smells/long_method_spec.rb", "spec/reek/smells/long_parameter_list_spec.rb", "spec/reek/smells/nested_iterators_spec.rb", "spec/reek/smells/smell_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/source_spec.rb", "spec/samples/inline.rb", "spec/samples/inline_spec.rb", "spec/samples/optparse.rb", "spec/samples/optparse_spec.rb", "spec/samples/redcloth.rb", "spec/samples/redcloth_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/rspec.rake"]
15
+ s.files = ["History.txt", "README.txt", "Rakefile", "bin/reek", "config/defaults.reek", "lib/reek.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/exceptions.reek", "lib/reek/if_context.rb", "lib/reek/method_context.rb", "lib/reek/module_context.rb", "lib/reek/name.rb", "lib/reek/object_refs.rb", "lib/reek/options.rb", "lib/reek/rake_task.rb", "lib/reek/report.rb", "lib/reek/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/duplication.rb", "lib/reek/smells/feature_envy.rb", "lib/reek/smells/large_class.rb", "lib/reek/smells/long_method.rb", "lib/reek/smells/long_parameter_list.rb", "lib/reek/smells/long_yield_list.rb", "lib/reek/smells/nested_iterators.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/smells.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/source.rb", "lib/reek/spec.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/reek/block_context_spec.rb", "spec/reek/class_context_spec.rb", "spec/reek/code_context_spec.rb", "spec/reek/code_parser_spec.rb", "spec/reek/config_spec.rb", "spec/reek/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/name_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/options_spec.rb", "spec/reek/report_spec.rb", "spec/reek/sexp_formatter_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/duplication_spec.rb", "spec/reek/smells/feature_envy_spec.rb", "spec/reek/smells/large_class_spec.rb", "spec/reek/smells/long_method_spec.rb", "spec/reek/smells/long_parameter_list_spec.rb", "spec/reek/smells/nested_iterators_spec.rb", "spec/reek/smells/smell_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/slow/inline_spec.rb", "spec/slow/optparse_spec.rb", "spec/slow/redcloth_spec.rb", "spec/slow/reek_source_spec.rb", "spec/slow/samples/inline.rb", "spec/slow/samples/optparse.rb", "spec/slow/samples/redcloth.rb", "spec/slow/script_spec.rb", "spec/slow/source_list_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/rspec.rake"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://wiki.github.com/kevinrutherford/reek}
18
18
  s.post_install_message = %q{
@@ -21,22 +21,25 @@ For more information on reek, see http://wiki.github.com/kevinrutherford/reek
21
21
  s.rdoc_options = ["--main", "README.txt"]
22
22
  s.require_paths = ["lib"]
23
23
  s.rubyforge_project = %q{reek}
24
- s.rubygems_version = %q{1.3.1}
24
+ s.rubygems_version = %q{1.3.2}
25
25
  s.summary = %q{Code smell detector for Ruby}
26
26
 
27
27
  if s.respond_to? :specification_version then
28
28
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
29
- s.specification_version = 2
29
+ s.specification_version = 3
30
30
 
31
31
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
32
32
  s.add_runtime_dependency(%q<ParseTree>, ["~> 3.0"])
33
+ s.add_runtime_dependency(%q<ruby2ruby>, ["~> 1.2"])
33
34
  s.add_runtime_dependency(%q<sexp_processor>, ["~> 3.0"])
34
35
  else
35
36
  s.add_dependency(%q<ParseTree>, ["~> 3.0"])
37
+ s.add_dependency(%q<ruby2ruby>, ["~> 1.2"])
36
38
  s.add_dependency(%q<sexp_processor>, ["~> 3.0"])
37
39
  end
38
40
  else
39
41
  s.add_dependency(%q<ParseTree>, ["~> 3.0"])
42
+ s.add_dependency(%q<ruby2ruby>, ["~> 1.2"])
40
43
  s.add_dependency(%q<sexp_processor>, ["~> 3.0"])
41
44
  end
42
45
  end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ require 'reek/block_context'
4
+ require 'reek/method_context'
5
+
6
+ include Reek
7
+
8
+ describe BlockContext do
9
+
10
+ it "should record single parameter" do
11
+ element = StopContext.new
12
+ element = BlockContext.new(element, s(s(:lasgn, :x), nil))
13
+ element.variable_names.should == [Name.new(:x)]
14
+ end
15
+
16
+ it "should record single parameter within a method" do
17
+ element = StopContext.new
18
+ element = MethodContext.new(element, s(:defn, :help))
19
+ element = BlockContext.new(element, s(s(:lasgn, :x), nil))
20
+ element.variable_names.should == [Name.new(:x)]
21
+ end
22
+
23
+ it "records multiple parameters" do
24
+ element = StopContext.new
25
+ element = BlockContext.new(element, s(s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))), nil))
26
+ element.variable_names.should == [Name.new(:x), Name.new(:y)]
27
+ end
28
+
29
+ it "should not pass parameters upward" do
30
+ mc = MethodContext.new(StopContext.new, s(:defn, :help))
31
+ element = BlockContext.new(mc, s(s(:lasgn, :x)))
32
+ mc.variable_names.should be_empty
33
+ end
34
+
35
+ it 'records local variables' do
36
+ bctx = BlockContext.new(StopContext.new, nil)
37
+ bctx.record_local_variable(:q2)
38
+ bctx.variable_names.should include(Name.new(:q2))
39
+ end
40
+ end
@@ -196,3 +196,14 @@ describe CodeContext, 'find class' do
196
196
  end
197
197
  end
198
198
  end
199
+
200
+ describe ClassContext do
201
+ it 'should not report empty class in another module' do
202
+ 'class Treetop::Runtime::SyntaxNode; end'.should_not reek
203
+ end
204
+
205
+ it 'should deal with :: scoped names' do
206
+ element = ClassContext.create(StopContext.new, [:colon2, [:colon2, [:const, :Treetop], :Runtime], :SyntaxNode])
207
+ element.num_methods.should == 0
208
+ end
209
+ end
@@ -45,7 +45,8 @@ describe CodeContext, 'instance variables' do
45
45
  element = MethodContext.new(class_element, [0, :bad])
46
46
  element = BlockContext.new(element, nil)
47
47
  element.record_instance_variable(:fred)
48
- class_element.variable_names.should == [Name.new(:fred)]
48
+ class_element.variable_names.size.should == 1
49
+ class_element.variable_names.should include(Name.new(:fred))
49
50
  end
50
51
  end
51
52
 
@@ -20,16 +20,6 @@ describe CodeParser, 'with a global method definition' do
20
20
  end
21
21
  end
22
22
 
23
- describe CodeParser, 'when given a C extension' do
24
- before(:each) do
25
- @cchk = CodeParser.new(Report.new, SmellConfig.new.smell_listeners)
26
- end
27
-
28
- it 'should ignore :cfunc' do
29
- @cchk.check_object(Enumerable)
30
- end
31
- end
32
-
33
23
  describe CodeParser, 'when a yield is the receiver' do
34
24
  it 'should report no problems' do
35
25
  source = 'def values(*args)
@@ -17,7 +17,7 @@ describe 'Config' do
17
17
  other = Hash.new {|hash,key| hash[key] = {} }
18
18
  other['one']['gunk'] = 45
19
19
  other['two']['four'] = false
20
- @first.value_merge!(other).to_yaml
20
+ other.push_keys(@first)
21
21
  @first['two']['four'].should == false
22
22
  @first['one'].keys.length.should == 3
23
23
  end
@@ -36,7 +36,7 @@ describe Config, 'merging arrays' do
36
36
  it 'should merge array values' do
37
37
  first = {'key' => {'one' => [1,2,3]}}
38
38
  second = {'key' => {'one' => [4,5]}}
39
- first.value_merge!(second)
39
+ second.push_keys(first)
40
40
  first['key']['one'].should == [1,2,3,4,5]
41
41
  end
42
42
  end
@@ -49,4 +49,18 @@ describe MethodContext do
49
49
  mctx.record_call_to([:call, [:ivar, :@cow], :feed_to])
50
50
  mctx.envious_receivers.should == []
51
51
  end
52
+
53
+ it 'should count calls to self' do
54
+ mctx = MethodContext.new(StopContext.new, [:defn, :equals])
55
+ mctx.refs.record_ref([:lvar, :other])
56
+ mctx.record_call_to([:call, [:self], :thing])
57
+ mctx.envious_receivers.should be_empty
58
+ end
59
+
60
+ it 'should recognise a call on self' do
61
+ mc = MethodContext.new(StopContext.new, s(:defn, :deep))
62
+ mc.record_call_to(s(:call, s(:lvar, :text), :each, s(:arglist)))
63
+ mc.record_call_to(s(:call, nil, :shelve, s(:arglist)))
64
+ mc.envious_receivers.should be_empty
65
+ end
52
66
  end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require 'reek/name'
3
+
4
+ include Reek
5
+
6
+ describe Name, 'resolving symbols' do
7
+ it 'finds fq loaded class' do
8
+ exp = [:class, :"Reek::Smells::LargeClass", nil]
9
+ ctx = StopContext.new
10
+ res = Name.resolve(exp[1], ctx)
11
+ res[1].should == "LargeClass"
12
+ end
13
+ end
@@ -9,8 +9,8 @@ describe ObjectRefs, 'when empty' do
9
9
  @refs = ObjectRefs.new
10
10
  end
11
11
 
12
- it 'should report one ref to self' do
13
- @refs.refs_to_self.should == 1
12
+ it 'should report no refs to self' do
13
+ @refs.refs_to_self.should == 0
14
14
  end
15
15
  end
16
16
 
@@ -23,7 +23,7 @@ describe ObjectRefs, 'with no refs to self' do
23
23
  end
24
24
 
25
25
  it 'should report no refs to self' do
26
- @refs.refs_to_self.should == 1
26
+ @refs.refs_to_self.should == 0
27
27
  end
28
28
 
29
29
  it 'should report :a as the max' do
@@ -45,16 +45,16 @@ describe ObjectRefs, 'with one ref to self' do
45
45
  end
46
46
 
47
47
  it 'should report 1 ref to self' do
48
- @refs.refs_to_self.should == 2
48
+ @refs.refs_to_self.should == 1
49
49
  end
50
50
 
51
- it 'should report self among the max' do
51
+ it 'should not report self among the max' do
52
52
  @refs.max_keys.should be_include('a')
53
- @refs.max_keys.should be_include(Sexp.from_array([:lit, :self]))
53
+ @refs.max_keys.should_not include(Sexp.from_array([:lit, :self]))
54
54
  end
55
55
 
56
- it 'should report self as the max' do
57
- @refs.self_is_max?.should == true
56
+ it 'should not report self as the max' do
57
+ @refs.self_is_max?.should == false
58
58
  end
59
59
  end
60
60
 
@@ -62,6 +62,7 @@ describe ObjectRefs, 'with many refs to self' do
62
62
  before(:each) do
63
63
  @refs = ObjectRefs.new
64
64
  @refs.record_reference_to_self
65
+ @refs.record_reference_to_self
65
66
  @refs.record_ref('a')
66
67
  @refs.record_reference_to_self
67
68
  @refs.record_ref('b')
@@ -87,6 +88,7 @@ describe ObjectRefs, 'when self is not the only max' do
87
88
  @refs = ObjectRefs.new
88
89
  @refs.record_ref('a')
89
90
  @refs.record_reference_to_self
91
+ @refs.record_reference_to_self
90
92
  @refs.record_ref('b')
91
93
  @refs.record_ref('a')
92
94
  end
@@ -115,7 +117,7 @@ describe ObjectRefs, 'when self is not among the max' do
115
117
  end
116
118
 
117
119
  it 'should report all refs to self' do
118
- @refs.refs_to_self.should == 1
120
+ @refs.refs_to_self.should == 0
119
121
  end
120
122
 
121
123
  it 'should not report self among the max' do