Skip to content

Commit

Permalink
LargeClass no longer counts methods from the loaded class
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrutherford committed May 18, 2009
1 parent d4dfc70 commit e235ca9
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 55 deletions.
7 changes: 2 additions & 5 deletions config/defaults.reek
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
---
LargeClass:
max_methods: 25
exclude:
- Array
- Hash
- Module
- String
exclude: []

enabled: true
max_instance_variables: 9
LongParameterList:
Expand Down
7 changes: 1 addition & 6 deletions lib/reek/class_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
require 'reek/code_context'

class Class
def non_inherited_methods
instance_methods(false) + private_instance_methods(false)
end

def is_overriding_method?(sym)
instance_methods(false).include?(sym) and superclass.instance_methods(true).include?(sym)
end
Expand Down Expand Up @@ -47,8 +43,7 @@ def is_struct?
end

def num_methods
meths = myself ? @myself.non_inherited_methods : @parsed_methods
meths.length
@parsed_methods.length
end

def record_instance_variable(sym)
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/smells/large_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.default_config
super.adopt(
MAX_ALLOWED_METHODS_KEY => 25,
MAX_ALLOWED_IVARS_KEY => 9,
EXCLUDE_KEY => ['Array', 'Hash', 'Module', 'String']
EXCLUDE_KEY => []
)
end

Expand Down
40 changes: 0 additions & 40 deletions spec/reek/class_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,6 @@ def textile_popup_help(name, windowW, windowH) f(3);end
end
end

describe Class do

module Insert
def meth_a() end
private
def meth_b() end
protected
def meth_c() end
end

class Parent
def meth1() end
private
def meth2() end
protected
def meth3() end
end

class FullChild < Parent
include Insert
def meth7() end
private
def meth8() end
protected
def meth6() end
end

describe 'with no superclass or modules' do
it 'should report correct number of methods' do
Parent.non_inherited_methods.length.should == 3
end
end

describe 'with superclass and modules' do
it 'should report correct number of methods' do
FullChild.non_inherited_methods.length.should == 3
end
end
end

describe ClassContext, 'overridden methods' do
class Above
def above() end
Expand Down
3 changes: 1 addition & 2 deletions spec/slow/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
ruby.should reek_of(:Duplication, /Inline::self.rootdir/, /env.nil?/)
ruby.should reek_of(:Duplication, /Module#inline/, /Inline.const_get\(lang\)/)
ruby.should reek_of(:FeatureEnvy, /Inline::C#strip_comments/, /src/)
ruby.should reek_of(:LargeClass, /Inline::C/, /methods/)
ruby.should reek_of(:LargeClass, /Inline::C/, /instance variables/)
ruby.should reek_of(:LongMethod, /File#self.write_with_backup/)
ruby.should reek_of(:LongMethod, /Inline::C#build/)
Expand All @@ -39,6 +38,6 @@
ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'x'/)
ruby.should reek_of(:UncommunicativeName, /Inline::C#parse_signature/, /'x'/)
ruby.should reek_of(:UtilityFunction, /Inline::C#strip_comments/)
ruby.report.should have_at_most(36).smells
ruby.report.should have_at_most(35).smells
end
end
2 changes: 1 addition & 1 deletion tasks/deployment.rake
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ::Rake::SshDirPublisher
attr_reader :host, :remote_dir, :local_dir
end

file GEMSPEC => [GEM_MANIFEST, VERSION_FILE, __FILE__] do
file GEMSPEC => [GEM_MANIFEST, HISTORY_FILE, VERSION_FILE, __FILE__] do
GEMSPEC.touch($gemspec.to_ruby)
end

Expand Down

0 comments on commit e235ca9

Please sign in to comment.