kevinrutherford-reek 1.1.3.12 → 1.1.3.13

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.
data/History.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  == 1.2 (in progress -- see github)
2
2
 
3
3
  === Major Changes
4
+ * Reek passes all its tests under ruby 1.8.6, 1.8.7 and 1.9.1 (fixed #16)
4
5
  * Reek's output reports are now formatted differently:
5
6
  ** Reek is no longer silent about smell-free source code
6
7
  ** Output now reports on all files examined, even if they have no smells
data/lib/reek.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
3
  module Reek # :doc:
4
- VERSION = '1.1.3.12'
4
+ VERSION = '1.1.3.13'
5
5
  end
@@ -2,8 +2,11 @@ require 'set'
2
2
  require 'reek/code_context'
3
3
 
4
4
  class Class
5
- def is_overriding_method?(sym)
6
- instance_methods(false).include?(sym) and superclass.instance_methods(true).include?(sym)
5
+ def is_overriding_method?(name)
6
+ sym = name.to_sym
7
+ mine = instance_methods(false)
8
+ dads = superclass.instance_methods(true)
9
+ (mine.include?(sym) and dads.include?(sym)) or (mine.include?(name) and dads.include?(name))
7
10
  end
8
11
  end
9
12
 
@@ -21,6 +24,7 @@ module Reek
21
24
  CodeParser.new(sniffer).process_class(source.syntax_tree)
22
25
  end
23
26
 
27
+ # SMELL: inconsistent with other contexts (not linked to the sexp)
24
28
  def initialize(outer, name, superclass = nil)
25
29
  super(outer, nil)
26
30
  @name = name
@@ -23,6 +23,7 @@ module Reek
23
23
  @myself = nil
24
24
  end
25
25
 
26
+ # SMELL: Temporary Field -- @name isn't always initialized
26
27
  def matches?(strings)
27
28
  me = @name.to_s
28
29
  strings.any? do |str|
data/reek.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reek}
5
- s.version = "1.1.3.12"
5
+ s.version = "1.1.3.13"
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-07-25}
9
+ s.date = %q{2009-07-26}
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"]
@@ -20,7 +20,7 @@ For more information on reek, see http://wiki.github.com/kevinrutherford/reek
20
20
  s.rdoc_options = ["--main", "README.txt"]
21
21
  s.require_paths = ["lib"]
22
22
  s.rubyforge_project = %q{reek}
23
- s.rubygems_version = %q{1.3.4}
23
+ s.rubygems_version = %q{1.3.5}
24
24
  s.summary = %q{Code smell detector for Ruby}
25
25
 
26
26
  if s.respond_to? :specification_version then
@@ -8,7 +8,7 @@ describe 'Reek source code' do
8
8
  nucleus = Dir['lib/reek/**.rb'] - Dir['lib/reek/adapters/**/*.rb']
9
9
  nucleus.each do |src|
10
10
  it "#{src} contains no references from the nucleus out to the adapters" do
11
- File.new(src).lines.grep(/adapters/).should be_empty
11
+ IO.readlines(src).grep(/adapters/).should be_empty
12
12
  end
13
13
  end
14
14
 
@@ -20,6 +20,7 @@ class Fred
20
20
  def simply(arga, argb, argc, argd) f(3);false end
21
21
  end
22
22
  EOEX
23
+
23
24
  src.should reek_of(:LongParameterList, /Fred/, /simple/)
24
25
  src.should reek_of(:LongParameterList, /Fred/, /simply/)
25
26
  end
@@ -33,23 +34,24 @@ class Fred
33
34
  def textile_popup_help(name, windowW, windowH) f(3);end
34
35
  end
35
36
  EOEX
37
+
36
38
  src.should reek_of(:LongParameterList, /Fred/, /textile_bq/)
37
39
  src.should reek_of(:LongParameterList, /Fred/, /textile_fn_/)
38
40
  src.should reek_of(:LongParameterList, /Fred/, /textile_p/)
39
41
  end
40
42
  end
41
43
 
44
+ class Above
45
+ def above() end
46
+ def both() end
47
+ end
48
+
49
+ class Below < Above
50
+ def both() end
51
+ def below() end
52
+ end
53
+
42
54
  describe ClassContext, 'overridden methods' do
43
- class Above
44
- def above() end
45
- def both() end
46
- end
47
-
48
- class Below < Above
49
- def both() end
50
- def below() end
51
- end
52
-
53
55
  describe 'of loaded class' do
54
56
  before :each do
55
57
  @ctx = ClassContext.create(StopContext.new, [0, :Below])
@@ -97,16 +99,16 @@ describe 'Integration defect:' do
97
99
  end
98
100
  end
99
101
 
100
- describe CodeContext, 'find class' do
101
- module Mod1
102
- class Klass1
103
- module Mod2
104
- class Klass2
105
- end
102
+ module Mod1
103
+ class Klass1
104
+ module Mod2
105
+ class Klass2
106
106
  end
107
107
  end
108
108
  end
109
+ end
109
110
 
111
+ describe CodeContext, 'find class' do
110
112
  before :each do
111
113
  @stop = StopContext.new
112
114
  @mod1 = ModuleContext.create(@stop, [0, :Mod1])
@@ -13,7 +13,7 @@ describe CodeContext, 'to_s' do
13
13
 
14
14
  it "should report full context" do
15
15
  element = StopContext.new
16
- element = ModuleContext.new(element, [0, :mod])
16
+ element = ModuleContext.new(element, Name.new(:mod))
17
17
  element = ClassContext.new(element, [0, :klass])
18
18
  element = MethodContext.new(element, [0, :bad])
19
19
  element = BlockContext.new(element, nil)
@@ -40,7 +40,7 @@ end
40
40
  describe CodeContext, 'instance variables' do
41
41
  it 'should pass instance variables down to the first class' do
42
42
  element = StopContext.new
43
- element = ModuleContext.new(element, [0, :mod])
43
+ element = ModuleContext.new(element, Name.new(:mod))
44
44
  class_element = ClassContext.new(element, [0, :klass])
45
45
  element = MethodContext.new(class_element, [0, :bad])
46
46
  element = BlockContext.new(element, nil)
@@ -54,7 +54,7 @@ describe CodeContext, 'generics' do
54
54
  it 'should pass unknown method calls down the stack' do
55
55
  stop = StopContext.new
56
56
  def stop.bananas(arg1, arg2) arg1 + arg2 + 43 end
57
- element = ModuleContext.new(stop, [0, :mod])
57
+ element = ModuleContext.new(stop, Name.new(:mod))
58
58
  class_element = ClassContext.new(element, [0, :klass])
59
59
  element = MethodContext.new(class_element, [0, :bad])
60
60
  element = BlockContext.new(element, nil)
@@ -65,19 +65,19 @@ end
65
65
  describe CodeContext do
66
66
  it 'should recognise itself in a collection of names' do
67
67
  element = StopContext.new
68
- element = ModuleContext.new(element, [0, :mod])
68
+ element = ModuleContext.new(element, Name.new(:mod))
69
69
  element.matches?(['banana', 'mod']).should == true
70
70
  end
71
71
 
72
72
  it 'should recognise itself in a collection of REs' do
73
73
  element = StopContext.new
74
- element = ModuleContext.new(element, [0, :mod])
74
+ element = ModuleContext.new(element, Name.new(:mod))
75
75
  element.matches?([/banana/, /mod/]).should == true
76
76
  end
77
77
 
78
78
  it 'should recognise its fq name in a collection of names' do
79
79
  element = StopContext.new
80
- element = ModuleContext.new(element, [0, :mod])
80
+ element = ModuleContext.new(element, Name.new(:mod))
81
81
  element = ClassContext.create(element, [0, :klass])
82
82
  element.matches?(['banana', 'mod']).should == true
83
83
  element.matches?(['banana', 'mod::klass']).should == true
@@ -85,7 +85,7 @@ describe CodeContext do
85
85
 
86
86
  it 'should recognise its fq name in a collection of names' do
87
87
  element = StopContext.new
88
- element = ModuleContext.new(element, [0, :mod])
88
+ element = ModuleContext.new(element, Name.new(:mod))
89
89
  element = ClassContext.create(element, [0, :klass])
90
90
  element.matches?([/banana/, /mod/]).should == true
91
91
  element.matches?([/banana/, /mod::klass/]).should == true
@@ -24,8 +24,8 @@ end
24
24
  describe MethodContext, 'matching fq names' do
25
25
  before :each do
26
26
  element = StopContext.new
27
- element = ModuleContext.new(element, [0, :mod])
28
- element = ClassContext.new(element, [0, :klass])
27
+ element = ModuleContext.new(element, Name.new(:mod))
28
+ element = ClassContext.new(element, Name.new(:klass))
29
29
  @element = MethodContext.new(element, [0, :meth])
30
30
  end
31
31
 
@@ -10,7 +10,7 @@ describe SingletonMethodContext, 'outer_name' do
10
10
 
11
11
  it "should report full context" do
12
12
  element = StopContext.new
13
- element = ModuleContext.new(element, [0, :mod])
13
+ element = ModuleContext.new(element, Name.new(:mod))
14
14
  element = SingletonMethodContext.new(element, [:defs, [:call, nil, :a, [:arglist]], :b, nil])
15
15
  element.outer_name.should match(/mod::a\.b/)
16
16
  end
@@ -73,7 +73,7 @@ describe UtilityFunction do
73
73
  end
74
74
  Fred.should_not reek
75
75
  end
76
-
76
+
77
77
  it 'should not report overriding methods' do
78
78
  pending('test requires ParseTree') unless ObjectSource.can_parse_objects?
79
79
  class Father
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kevinrutherford-reek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3.12
4
+ version: 1.1.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Rutherford
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-25 00:00:00 -07:00
12
+ date: 2009-07-26 00:00:00 -07:00
13
13
  default_executable: reek
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency