reek 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +20 -0
- data/README.txt +4 -80
- data/Rakefile +15 -4
- data/bin/reek +10 -16
- data/config/defaults.reek +53 -0
- data/lib/reek.rb +1 -21
- data/lib/reek/block_context.rb +37 -0
- data/lib/reek/class_context.rb +73 -0
- data/lib/reek/code_context.rb +47 -0
- data/lib/reek/code_parser.rb +204 -0
- data/lib/reek/exceptions.reek +13 -0
- data/lib/reek/if_context.rb +25 -0
- data/lib/reek/method_context.rb +85 -0
- data/lib/reek/module_context.rb +34 -0
- data/lib/reek/name.rb +42 -0
- data/lib/reek/object_refs.rb +3 -6
- data/lib/reek/options.rb +60 -40
- data/lib/reek/rake_task.rb +20 -29
- data/lib/reek/report.rb +16 -27
- data/lib/reek/sexp_formatter.rb +52 -0
- data/lib/reek/singleton_method_context.rb +27 -0
- data/lib/reek/smell_warning.rb +49 -0
- data/lib/reek/smells/control_couple.rb +21 -13
- data/lib/reek/smells/duplication.rb +23 -27
- data/lib/reek/smells/feature_envy.rb +18 -25
- data/lib/reek/smells/large_class.rb +32 -17
- data/lib/reek/smells/long_method.rb +24 -16
- data/lib/reek/smells/long_parameter_list.rb +25 -18
- data/lib/reek/smells/long_yield_list.rb +7 -9
- data/lib/reek/smells/nested_iterators.rb +13 -9
- data/lib/reek/smells/smell_detector.rb +66 -0
- data/lib/reek/smells/smells.rb +71 -10
- data/lib/reek/smells/uncommunicative_name.rb +49 -41
- data/lib/reek/smells/utility_function.rb +18 -18
- data/lib/reek/source.rb +116 -0
- data/lib/reek/spec.rb +146 -0
- data/lib/reek/stop_context.rb +62 -0
- data/lib/reek/yield_call_context.rb +14 -0
- data/reek.gemspec +42 -0
- data/spec/integration/reek_source_spec.rb +20 -0
- data/spec/{script_spec.rb → integration/script_spec.rb} +11 -24
- data/spec/reek/class_context_spec.rb +198 -0
- data/spec/reek/code_context_spec.rb +92 -0
- data/spec/reek/code_parser_spec.rb +44 -0
- data/spec/reek/config_spec.rb +42 -0
- data/spec/reek/if_context_spec.rb +17 -0
- data/spec/reek/method_context_spec.rb +52 -0
- data/spec/reek/module_context_spec.rb +38 -0
- data/spec/reek/options_spec.rb +2 -28
- data/spec/reek/report_spec.rb +6 -40
- data/spec/reek/sexp_formatter_spec.rb +31 -0
- data/spec/reek/singleton_method_context_spec.rb +17 -0
- data/spec/reek/smells/control_couple_spec.rb +10 -18
- data/spec/reek/smells/duplication_spec.rb +53 -32
- data/spec/reek/smells/feature_envy_spec.rb +87 -49
- data/spec/reek/smells/large_class_spec.rb +45 -4
- data/spec/reek/smells/long_method_spec.rb +25 -41
- data/spec/reek/smells/long_parameter_list_spec.rb +30 -76
- data/spec/reek/smells/nested_iterators_spec.rb +19 -29
- data/spec/reek/smells/smell_spec.rb +9 -18
- data/spec/reek/smells/uncommunicative_name_spec.rb +88 -53
- data/spec/reek/smells/utility_function_spec.rb +45 -44
- data/spec/samples/inline_spec.rb +40 -0
- data/spec/samples/optparse_spec.rb +100 -0
- data/spec/samples/redcloth_spec.rb +93 -0
- data/spec/spec_helper.rb +3 -1
- data/tasks/reek.rake +1 -10
- data/tasks/rspec.rake +16 -35
- metadata +43 -46
- data/lib/reek/checker.rb +0 -66
- data/lib/reek/class_checker.rb +0 -25
- data/lib/reek/file_checker.rb +0 -20
- data/lib/reek/method_checker.rb +0 -198
- data/lib/reek/printer.rb +0 -154
- data/lib/reek/smells/smell.rb +0 -56
- data/lib/reek/version.rb +0 -9
- data/setup.rb +0 -1585
- data/spec/integration_spec.rb +0 -30
- data/spec/reek/class_checker_spec.rb +0 -48
- data/spec/reek/method_checker_spec.rb +0 -67
- data/spec/reek/printer_spec.rb +0 -30
- data/spec/reek_source_spec.rb +0 -12
- data/spec/samples/inline.reek +0 -27
- data/spec/samples/optparse.reek +0 -79
- data/spec/samples/optparse/date.rb +0 -17
- data/spec/samples/optparse/shellwords.rb +0 -6
- data/spec/samples/optparse/time.rb +0 -10
- data/spec/samples/optparse/uri.rb +0 -6
- data/spec/samples/optparse/version.rb +0 -70
- data/spec/samples/redcloth.reek +0 -65
- data/tasks/samples.rake +0 -17
- data/website/index.html +0 -71
- data/website/index.txt +0 -40
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
data/spec/integration_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'Integration test:' do
|
4
|
-
Dir['spec/samples/*.rb'].each do |source|
|
5
|
-
describe source do
|
6
|
-
before :each do
|
7
|
-
@expected = IO.readlines(source.sub(/\.rb/, '.reek'))
|
8
|
-
@expected.each {|line| line.chomp!}
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should report the correct smells' do
|
12
|
-
actual = `ruby -Ilib bin/reek #{source} 2>/dev/null`.split(/\n/)
|
13
|
-
@expected.zip(actual).each do |p|
|
14
|
-
actual_line = p[1] ? p[1].chomp : p[1]
|
15
|
-
actual_line.should == p[0]
|
16
|
-
end
|
17
|
-
actual.length.should == @expected.length
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should report the correct smells in smell order' do
|
21
|
-
actual = `ruby -Ilib bin/reek --sort smell #{source} 2>/dev/null`.split(/\n/)
|
22
|
-
@expected.sort.zip(actual).each do |p|
|
23
|
-
actual_line = p[1] ? p[1].chomp : p[1]
|
24
|
-
actual_line.should == p[0]
|
25
|
-
end
|
26
|
-
actual.length.should == @expected.length
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
require 'reek/class_checker'
|
4
|
-
|
5
|
-
include Reek
|
6
|
-
|
7
|
-
describe ClassChecker do
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@rpt = []
|
11
|
-
@cchk = ClassChecker.new(@rpt)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should report Long Parameter List' do
|
15
|
-
@cchk.check_source('class Inner; def simple(arga, argb, argc, argd) f(3);true end end')
|
16
|
-
@rpt.length.should == 1
|
17
|
-
@rpt[0].report.should match(/Inner#simple/)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should report two different methods' do
|
21
|
-
src = <<EOEX
|
22
|
-
class Fred
|
23
|
-
def simple(arga, argb, argc, argd) f(3);true end
|
24
|
-
def simply(arga, argb, argc, argd) f(3);false end
|
25
|
-
end
|
26
|
-
EOEX
|
27
|
-
@cchk.check_source(src)
|
28
|
-
@rpt.length.should == 2
|
29
|
-
@rpt[0].report.should match(/Fred#simple/)
|
30
|
-
@rpt[1].report.should match(/Fred#simply/)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should report many different methods' do
|
34
|
-
src = <<EOEX
|
35
|
-
class Fred
|
36
|
-
def textile_bq(tag, atts, cite, content) f(3);end
|
37
|
-
def textile_p(tag, atts, cite, content) f(3);end
|
38
|
-
def textile_fn_(tag, num, atts, cite, content) f(3);end
|
39
|
-
def textile_popup_help(name, windowW, windowH) f(3);end
|
40
|
-
end
|
41
|
-
EOEX
|
42
|
-
@cchk.check_source(src)
|
43
|
-
@rpt.length.should == 3
|
44
|
-
@rpt[0].report.should match(/Fred#textile_bq/)
|
45
|
-
@rpt[1].report.should match(/Fred#textile_p/)
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
require 'reek/method_checker'
|
4
|
-
require 'reek/report'
|
5
|
-
|
6
|
-
include Reek
|
7
|
-
|
8
|
-
describe MethodChecker, "with no method definitions" do
|
9
|
-
before(:each) do
|
10
|
-
@rpt = Report.new
|
11
|
-
@cchk = MethodChecker.new(@rpt, 'Thing')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should report no problems for empty source code' do
|
15
|
-
@cchk.check_source('')
|
16
|
-
@rpt.should be_empty
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should report no problems for empty class' do
|
20
|
-
@cchk.check_source('class Fred; end')
|
21
|
-
@rpt.should be_empty
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe MethodChecker, 'when given a C extension' do
|
26
|
-
before(:each) do
|
27
|
-
@cchk = MethodChecker.new(Report.new, 'Thing')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should ignore :cfunc' do
|
31
|
-
@cchk.check_object(Enumerable)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe MethodChecker, 'when a yield is the receiver' do
|
36
|
-
it 'should report no problems' do
|
37
|
-
source = 'def values(*args)
|
38
|
-
@to_sql += case
|
39
|
-
when block_given? then " #{yield.to_sql}"
|
40
|
-
else " values (#{args.to_sql})"
|
41
|
-
end
|
42
|
-
self
|
43
|
-
end'
|
44
|
-
rpt = Report.new
|
45
|
-
chk = MethodChecker.new(rpt, 'Thing')
|
46
|
-
chk.check_source(source)
|
47
|
-
rpt.should be_empty
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe MethodChecker, '#is_override?' do
|
52
|
-
it 'should be false for non-override method' do
|
53
|
-
MethodChecker.is_override?('String', 'gsub').should == false
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should be true for overriding method' do
|
57
|
-
MethodChecker.is_override?('MethodChecker', 'to_s').should == true
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should be false for non-existent class' do
|
61
|
-
MethodChecker.is_override?('Flibble', 'to_s').should == false
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should be true for smells' do
|
65
|
-
MethodChecker.is_override?('UtilityFunction', 'recognise?').should == true
|
66
|
-
end
|
67
|
-
end
|
data/spec/reek/printer_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
require 'reek/checker'
|
4
|
-
require 'reek/printer'
|
5
|
-
|
6
|
-
include Reek
|
7
|
-
|
8
|
-
def check(examples)
|
9
|
-
examples.each do |actual|
|
10
|
-
it "should format #{actual} correctly" do
|
11
|
-
sexp = Checker.parse_tree_for(actual)[0]
|
12
|
-
Printer.print(sexp).should == actual
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe Printer do
|
18
|
-
check 'Alpha'
|
19
|
-
check 'Alpha::Beta'
|
20
|
-
check '@@fred'
|
21
|
-
check '`ls`'
|
22
|
-
check 'array[0]'
|
23
|
-
check 'array[0, 1, 2]'
|
24
|
-
check 'obj.method(arg1, arg2)'
|
25
|
-
check 'obj.method'
|
26
|
-
check '$1'
|
27
|
-
check 'o=q.downcase'
|
28
|
-
check 'true'
|
29
|
-
check '"-#{q}xxx#{z.size}"'
|
30
|
-
end
|
data/spec/reek_source_spec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
-
|
3
|
-
describe 'Reek source code:' do
|
4
|
-
Dir['lib/**/*.rb'].each do |source|
|
5
|
-
describe source do
|
6
|
-
it 'should report no smells' do
|
7
|
-
`ruby -Ilib bin/reek #{source}`.should == ''
|
8
|
-
$?.exitstatus.should == 0
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/spec/samples/inline.reek
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
[Duplication] C#build calls $?.==(0) more than once
|
2
|
-
[Duplication] C#build calls Inline.directory more than once
|
3
|
-
[Duplication] C#build calls io.puts more than once
|
4
|
-
[Duplication] C#build calls io.puts(#endif) more than once
|
5
|
-
[Duplication] C#build calls io.puts(#ifdef __cplusplus) more than once
|
6
|
-
[Long Method] C#build has approx 61 statements
|
7
|
-
[Nested Iterators] C#build has nested iterators
|
8
|
-
[Uncommunicative Name] C#build uses the local variable name 't'
|
9
|
-
[Uncommunicative Name] C#c uses the method name 'c'
|
10
|
-
[Duplication] C#crap_for_windoze calls Config::CONFIG[libdir] more than once
|
11
|
-
[Duplication] C#generate calls result.sub!((?-mix:\A\n), ) more than once
|
12
|
-
[Duplication] C#generate calls signature[args] more than once
|
13
|
-
[Duplication] C#generate calls signature[args].map more than once
|
14
|
-
[Long Method] C#generate has approx 33 statements
|
15
|
-
[Duplication] C#initialize calls stack.empty? more than once
|
16
|
-
[Long Method] C#load_cache has approx 7 statements
|
17
|
-
[Long Method] C#module_name has approx 6 statements
|
18
|
-
[Feature Envy] C#module_name refers to md5 more than self
|
19
|
-
[Long Method] C#parse_signature has approx 15 statements
|
20
|
-
[Control Couple] C#parse_signature is controlled by argument raw
|
21
|
-
[Utility Function] C#strip_comments doesn't depend on instance state
|
22
|
-
[Feature Envy] C#strip_comments refers to src more than self
|
23
|
-
[Large Class] Dir has 31 methods
|
24
|
-
[Large Class] Module has 34 methods
|
25
|
-
[Duplication] Module#inline calls Inline.const_get(lang) more than once
|
26
|
-
[Long Method] Module#inline has approx 12 statements
|
27
|
-
[Control Couple] Module#inline is controlled by argument options
|
data/spec/samples/optparse.reek
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
[Large Class] AmbiguousArgument has 52 methods
|
2
|
-
[Long Parameter List] CompletingHash#complete has 4 parameters
|
3
|
-
[Nested Iterators] CompletingHash#complete has nested iterators
|
4
|
-
[Long Method] CompletingHash#getopts has approx 17 statements
|
5
|
-
[Duplication] CompletingHash#make_switch calls default_style.guess(arg=a) more than once
|
6
|
-
[Duplication] CompletingHash#make_switch calls long.<<(o=q.downcase) more than once
|
7
|
-
[Duplication] CompletingHash#make_switch calls pattern.method(convert) more than once
|
8
|
-
[Duplication] CompletingHash#make_switch calls pattern.method(convert).to_proc more than once
|
9
|
-
[Duplication] CompletingHash#make_switch calls pattern.respond_to?(convert) more than once
|
10
|
-
[Duplication] CompletingHash#make_switch calls q.downcase more than once
|
11
|
-
[Duplication] CompletingHash#make_switch calls sdesc.<<("-#{q}") more than once
|
12
|
-
[Long Method] CompletingHash#make_switch has approx 69 statements
|
13
|
-
[Nested Iterators] CompletingHash#make_switch has nested iterators
|
14
|
-
[Uncommunicative Name] CompletingHash#make_switch uses the local variable name 'a'
|
15
|
-
[Uncommunicative Name] CompletingHash#make_switch uses the local variable name 'n'
|
16
|
-
[Uncommunicative Name] CompletingHash#make_switch uses the local variable name 'o'
|
17
|
-
[Uncommunicative Name] CompletingHash#make_switch uses the local variable name 'q'
|
18
|
-
[Uncommunicative Name] CompletingHash#make_switch uses the local variable name 's'
|
19
|
-
[Nested Iterators] CompletingHash#match has nested iterators
|
20
|
-
[Duplication] CompletingHash#order calls argv[0] more than once
|
21
|
-
[Feature Envy] CompletingHash#order refers to argv more than self
|
22
|
-
[Duplication] CompletingHash#parse calls argv[0] more than once
|
23
|
-
[Feature Envy] CompletingHash#parse refers to argv more than self
|
24
|
-
[Duplication] CompletingHash#parse_in_order calls $!.set_option(arg, true) more than once
|
25
|
-
[Duplication] CompletingHash#parse_in_order calls cb.call(val) more than once
|
26
|
-
[Duplication] CompletingHash#parse_in_order calls setter.call(sw.switch_name, val) more than once
|
27
|
-
[Duplication] CompletingHash#parse_in_order calls sw.block more than once
|
28
|
-
[Duplication] CompletingHash#parse_in_order calls sw.switch_name more than once
|
29
|
-
[Long Method] CompletingHash#parse_in_order has approx 30 statements
|
30
|
-
[Nested Iterators] CompletingHash#parse_in_order has nested iterators
|
31
|
-
[Control Couple] CompletingHash#parse_in_order is controlled by argument setter
|
32
|
-
[Duplication] CompletingHash#permute calls argv[0] more than once
|
33
|
-
[Feature Envy] CompletingHash#permute refers to argv more than self
|
34
|
-
[Long Parameter List] CompletingHash#summarize has 4 parameters
|
35
|
-
[Uncommunicative Name] CompletingHash#ver uses the local variable name 'v'
|
36
|
-
[Control Couple] List#accept is controlled by argument pat
|
37
|
-
[Feature Envy] List#accept refers to pat more than self
|
38
|
-
[Uncommunicative Name] List#accept uses the parameter name 't'
|
39
|
-
[Long Parameter List] List#complete has 4 parameters
|
40
|
-
[Uncommunicative Name] List#reject uses the parameter name 't'
|
41
|
-
[Long Parameter List] List#update has 5 parameters
|
42
|
-
[Long Method] List#update has approx 6 statements
|
43
|
-
[Control Couple] List#update is controlled by argument lopts
|
44
|
-
[Control Couple] List#update is controlled by argument sopts
|
45
|
-
[Uncommunicative Name] List#update uses the local variable name 'o'
|
46
|
-
[Control Couple] NoArgument#parse is controlled by argument arg
|
47
|
-
[Duplication] OptionParser#complete calls candidates.size more than once
|
48
|
-
[Duplication] OptionParser#complete calls k.id2name more than once
|
49
|
-
[Long Method] OptionParser#complete has approx 23 statements
|
50
|
-
[Feature Envy] OptionParser#complete refers to candidates more than self
|
51
|
-
[Uncommunicative Name] OptionParser#complete uses the local variable name 'k'
|
52
|
-
[Uncommunicative Name] OptionParser#complete uses the local variable name 'v'
|
53
|
-
[Utility Function] OptionParser#convert doesn't depend on instance state
|
54
|
-
[Control Couple] OptionalArgument#parse is controlled by argument arg
|
55
|
-
[Control Couple] ParseError#set_option is controlled by argument eq
|
56
|
-
[Long Method] PlacedArgument#parse has approx 6 statements
|
57
|
-
[Control Couple] RequiredArgument#parse is controlled by argument arg
|
58
|
-
[Uncommunicative Name] Switch#add_banner uses the local variable name 's'
|
59
|
-
[Long Parameter List] Switch#initialize has 7 parameters
|
60
|
-
[Duplication] Switch#parse_arg calls s.length more than once
|
61
|
-
[Long Method] Switch#parse_arg has approx 12 statements
|
62
|
-
[Feature Envy] Switch#parse_arg refers to arg more than self
|
63
|
-
[Uncommunicative Name] Switch#parse_arg uses the local variable name 'm'
|
64
|
-
[Uncommunicative Name] Switch#parse_arg uses the local variable name 's'
|
65
|
-
[Duplication] Switch#summarize calls block.max more than once
|
66
|
-
[Duplication] Switch#summarize calls block.max.to_i more than once
|
67
|
-
[Duplication] Switch#summarize calls indent.+(l) more than once
|
68
|
-
[Duplication] Switch#summarize calls left.collect more than once
|
69
|
-
[Duplication] Switch#summarize calls left.shift more than once
|
70
|
-
[Duplication] Switch#summarize calls left[-1] more than once
|
71
|
-
[Duplication] Switch#summarize calls s.length more than once
|
72
|
-
[Long Parameter List] Switch#summarize has 5 parameters
|
73
|
-
[Long Method] Switch#summarize has approx 27 statements
|
74
|
-
[Nested Iterators] Switch#summarize has nested iterators
|
75
|
-
[Feature Envy] Switch#summarize refers to left more than self
|
76
|
-
[Uncommunicative Name] Switch#summarize uses the local variable name 'l'
|
77
|
-
[Uncommunicative Name] Switch#summarize uses the local variable name 'r'
|
78
|
-
[Uncommunicative Name] Switch#summarize uses the local variable name 's'
|
79
|
-
[Long Yield List] Switch#summarize yields 4 parameters
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'date'
|
3
|
-
|
4
|
-
OptionParser.accept(DateTime) do |s,|
|
5
|
-
begin
|
6
|
-
DateTime.parse(s) if s
|
7
|
-
rescue ArgumentError
|
8
|
-
raise OptionParser::InvalidArgument, s
|
9
|
-
end
|
10
|
-
end
|
11
|
-
OptionParser.accept(Date) do |s,|
|
12
|
-
begin
|
13
|
-
Date.parse(s) if s
|
14
|
-
rescue ArgumentError
|
15
|
-
raise OptionParser::InvalidArgument, s
|
16
|
-
end
|
17
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# OptionParser internal utility
|
2
|
-
|
3
|
-
class << OptionParser
|
4
|
-
def show_version(*pkg)
|
5
|
-
progname = ARGV.options.program_name
|
6
|
-
result = false
|
7
|
-
show = proc do |klass, cname, version|
|
8
|
-
str = "#{progname}"
|
9
|
-
unless klass == ::Object and cname == :VERSION
|
10
|
-
version = version.join(".") if Array === version
|
11
|
-
str << ": #{klass}" unless klass == Object
|
12
|
-
str << " version #{version}"
|
13
|
-
end
|
14
|
-
[:Release, :RELEASE].find do |rel|
|
15
|
-
if klass.const_defined?(rel)
|
16
|
-
str << " (#{klass.const_get(rel)})"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
puts str
|
20
|
-
result = true
|
21
|
-
end
|
22
|
-
if pkg.size == 1 and pkg[0] == "all"
|
23
|
-
self.search_const(::Object, /\AV(?:ERSION|ersion)\z/) do |klass, cname, version|
|
24
|
-
unless cname[1] == ?e and klass.const_defined?(:Version)
|
25
|
-
show.call(klass, cname.intern, version)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
else
|
29
|
-
pkg.each do |pkg|
|
30
|
-
begin
|
31
|
-
pkg = pkg.split(/::|\//).inject(::Object) {|m, c| m.const_get(c)}
|
32
|
-
v = case
|
33
|
-
when pkg.const_defined?(:Version)
|
34
|
-
pkg.const_get(n = :Version)
|
35
|
-
when pkg.const_defined?(:VERSION)
|
36
|
-
pkg.const_get(n = :VERSION)
|
37
|
-
else
|
38
|
-
n = nil
|
39
|
-
"unknown"
|
40
|
-
end
|
41
|
-
show.call(pkg, n, v)
|
42
|
-
rescue NameError
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
result
|
47
|
-
end
|
48
|
-
|
49
|
-
def each_const(path, klass = ::Object)
|
50
|
-
path.split(/::|\//).inject(klass) do |klass, name|
|
51
|
-
raise NameError, path unless Module === klass
|
52
|
-
klass.constants.grep(/#{name}/i) do |c|
|
53
|
-
klass.const_defined?(c) or next
|
54
|
-
c = klass.const_get(c)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def search_const(klass, name)
|
60
|
-
klasses = [klass]
|
61
|
-
while klass = klasses.shift
|
62
|
-
klass.constants.each do |cname|
|
63
|
-
klass.const_defined?(cname) or next
|
64
|
-
const = klass.const_get(cname)
|
65
|
-
yield klass, cname, const if name === cname
|
66
|
-
klasses << const if Module === const and const != ::Object
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/spec/samples/redcloth.reek
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
[Long Method] RedCloth#block_markdown_bq has approx 6 statements
|
2
|
-
[Utility Function] RedCloth#block_markdown_rule doesn't depend on instance state
|
3
|
-
[Duplication] RedCloth#block_textile_lists calls depth.last more than once
|
4
|
-
[Duplication] RedCloth#block_textile_lists calls depth.last.length more than once
|
5
|
-
[Duplication] RedCloth#block_textile_lists calls depth[i] more than once
|
6
|
-
[Duplication] RedCloth#block_textile_lists calls line_id.-(1) more than once
|
7
|
-
[Duplication] RedCloth#block_textile_lists calls lines[line_id.-(1)] more than once
|
8
|
-
[Duplication] RedCloth#block_textile_lists calls tl.length more than once
|
9
|
-
[Long Method] RedCloth#block_textile_lists has approx 21 statements
|
10
|
-
[Nested Iterators] RedCloth#block_textile_lists has nested iterators
|
11
|
-
[Long Method] RedCloth#block_textile_table has approx 19 statements
|
12
|
-
[Nested Iterators] RedCloth#block_textile_table has nested iterators
|
13
|
-
[Long Method] RedCloth#blocks has approx 17 statements
|
14
|
-
[Nested Iterators] RedCloth#blocks has nested iterators
|
15
|
-
[Control Couple] RedCloth#blocks is controlled by argument deep_code
|
16
|
-
[Control Couple] RedCloth#check_refs is controlled by argument text
|
17
|
-
[Duplication] RedCloth#clean_html calls tags[tag] more than once
|
18
|
-
[Utility Function] RedCloth#clean_html doesn't depend on instance state
|
19
|
-
[Long Method] RedCloth#clean_html has approx 14 statements
|
20
|
-
[Nested Iterators] RedCloth#clean_html has nested iterators
|
21
|
-
[Feature Envy] RedCloth#clean_html refers to tags more than self
|
22
|
-
[Long Method] RedCloth#clean_white_space has approx 7 statements
|
23
|
-
[Feature Envy] RedCloth#clean_white_space refers to text more than self
|
24
|
-
[Utility Function] RedCloth#flush_left doesn't depend on instance state
|
25
|
-
[Feature Envy] RedCloth#flush_left refers to indt more than self
|
26
|
-
[Feature Envy] RedCloth#flush_left refers to text more than self
|
27
|
-
[Utility Function] RedCloth#footnote_ref doesn't depend on instance state
|
28
|
-
[Long Method] RedCloth#glyphs_textile has approx 9 statements
|
29
|
-
[Utility Function] RedCloth#h_align doesn't depend on instance state
|
30
|
-
[Utility Function] RedCloth#htmlesc doesn't depend on instance state
|
31
|
-
[Feature Envy] RedCloth#htmlesc refers to str more than self
|
32
|
-
[Utility Function] RedCloth#incoming_entities doesn't depend on instance state
|
33
|
-
[Nested Iterators] RedCloth#inline has nested iterators
|
34
|
-
[Long Method] RedCloth#inline_markdown_link has approx 6 statements
|
35
|
-
[Long Method] RedCloth#inline_markdown_reflink has approx 7 statements
|
36
|
-
[Long Method] RedCloth#inline_textile_image has approx 16 statements
|
37
|
-
[Long Method] RedCloth#inline_textile_link has approx 9 statements
|
38
|
-
[Long Method] RedCloth#inline_textile_span has approx 8 statements
|
39
|
-
[Nested Iterators] RedCloth#inline_textile_span has nested iterators
|
40
|
-
[Utility Function] RedCloth#lT doesn't depend on instance state
|
41
|
-
[Utility Function] RedCloth#no_textile doesn't depend on instance state
|
42
|
-
[Feature Envy] RedCloth#no_textile refers to text more than self
|
43
|
-
[Duplication] RedCloth#pba calls $1.length more than once
|
44
|
-
[Long Method] RedCloth#pba has approx 22 statements
|
45
|
-
[Control Couple] RedCloth#pba is controlled by argument text_in
|
46
|
-
[Feature Envy] RedCloth#pba refers to style more than self
|
47
|
-
[Feature Envy] RedCloth#pba refers to text more than self
|
48
|
-
[Duplication] RedCloth#rip_offtags calls @pre_list.last more than once
|
49
|
-
[Duplication] RedCloth#rip_offtags calls @pre_list.last.<<(line) more than once
|
50
|
-
[Duplication] RedCloth#rip_offtags calls codepre.-(used_offtags.length) more than once
|
51
|
-
[Duplication] RedCloth#rip_offtags calls codepre.-(used_offtags.length).>(0) more than once
|
52
|
-
[Duplication] RedCloth#rip_offtags calls codepre.zero? more than once
|
53
|
-
[Duplication] RedCloth#rip_offtags calls used_offtags.length more than once
|
54
|
-
[Duplication] RedCloth#rip_offtags calls used_offtags[notextile] more than once
|
55
|
-
[Long Method] RedCloth#rip_offtags has approx 22 statements
|
56
|
-
[Feature Envy] RedCloth#rip_offtags refers to codepre more than self
|
57
|
-
[Long Parameter List] RedCloth#textile_bq has 4 parameters
|
58
|
-
[Control Couple] RedCloth#textile_bq is controlled by argument atts
|
59
|
-
[Control Couple] RedCloth#textile_bq is controlled by argument cite
|
60
|
-
[Long Parameter List] RedCloth#textile_fn_ has 5 parameters
|
61
|
-
[Control Couple] RedCloth#textile_fn_ is controlled by argument atts
|
62
|
-
[Long Parameter List] RedCloth#textile_p has 4 parameters
|
63
|
-
[Control Couple] RedCloth#textile_p is controlled by argument atts
|
64
|
-
[Long Method] RedCloth#to_html has approx 24 statements
|
65
|
-
[Utility Function] RedCloth#v_align doesn't depend on instance state
|