kevinrutherford-reek 1.1.3.10 → 1.1.3.11

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 (60) hide show
  1. data/History.txt +5 -1
  2. data/bin/reek +2 -17
  3. data/features/masking_smells.feature +22 -8
  4. data/features/options.feature +12 -5
  5. data/features/reports.feature +22 -12
  6. data/features/samples.feature +66 -66
  7. data/lib/reek/adapters/application.rb +47 -0
  8. data/lib/reek/{config_file.rb → adapters/config_file.rb} +0 -0
  9. data/lib/reek/adapters/core_extras.rb +72 -0
  10. data/lib/reek/{object_source.rb → adapters/object_source.rb} +7 -6
  11. data/lib/reek/{rake_task.rb → adapters/rake_task.rb} +2 -2
  12. data/lib/reek/adapters/report.rb +91 -0
  13. data/lib/reek/adapters/source.rb +49 -0
  14. data/lib/reek/{spec.rb → adapters/spec.rb} +20 -9
  15. data/lib/reek/block_context.rb +1 -1
  16. data/lib/reek/class_context.rb +3 -2
  17. data/lib/reek/code_parser.rb +4 -0
  18. data/lib/reek/command_line.rb +85 -0
  19. data/lib/reek/detector_stack.rb +23 -6
  20. data/lib/reek/exceptions.reek +5 -1
  21. data/lib/reek/smell_warning.rb +5 -1
  22. data/lib/reek/smells/duplication.rb +5 -3
  23. data/lib/reek/smells/smell_detector.rb +15 -1
  24. data/lib/reek/smells/uncommunicative_name.rb +1 -1
  25. data/lib/reek/sniffer.rb +34 -66
  26. data/lib/reek.rb +1 -1
  27. data/reek.gemspec +3 -3
  28. data/spec/quality/reek_source_spec.rb +15 -0
  29. data/spec/reek/adapters/report_spec.rb +48 -0
  30. data/spec/reek/{should_reek_of_spec.rb → adapters/should_reek_of_spec.rb} +14 -11
  31. data/spec/reek/{should_reek_only_of_spec.rb → adapters/should_reek_only_of_spec.rb} +6 -4
  32. data/spec/reek/{should_reek_spec.rb → adapters/should_reek_spec.rb} +13 -10
  33. data/spec/reek/block_context_spec.rb +6 -0
  34. data/spec/reek/code_parser_spec.rb +6 -1
  35. data/spec/reek/config_spec.rb +3 -3
  36. data/spec/reek/smell_warning_spec.rb +2 -1
  37. data/spec/reek/smells/duplication_spec.rb +1 -1
  38. data/spec/reek/smells/large_class_spec.rb +3 -2
  39. data/spec/reek/smells/long_method_spec.rb +4 -3
  40. data/spec/reek/smells/long_parameter_list_spec.rb +0 -2
  41. data/spec/reek/smells/smell_detector_spec.rb +2 -16
  42. data/spec/reek/smells/uncommunicative_name_spec.rb +1 -2
  43. data/spec/reek/smells/utility_function_spec.rb +4 -0
  44. data/spec/samples/not_quite_masked/dirty.rb +8 -0
  45. data/spec/samples/not_quite_masked/masked.reek +5 -0
  46. data/spec/spec_helper.rb +1 -1
  47. data/tasks/reek.rake +2 -2
  48. data/tasks/test.rake +8 -8
  49. metadata +18 -20
  50. data/features/rake_task.feature +0 -9
  51. data/lib/reek/core_extras.rb +0 -50
  52. data/lib/reek/options.rb +0 -103
  53. data/lib/reek/report.rb +0 -115
  54. data/lib/reek/source.rb +0 -36
  55. data/spec/reek/options_spec.rb +0 -13
  56. data/spec/reek/report_spec.rb +0 -49
  57. data/spec/slow/inline_spec.rb +0 -44
  58. data/spec/slow/optparse_spec.rb +0 -112
  59. data/spec/slow/redcloth_spec.rb +0 -105
  60. data/spec/slow/reek_source_spec.rb +0 -13
@@ -1,50 +0,0 @@
1
- require 'reek/source' # SMELL: should refer to Sniffer
2
- require 'reek/sniffer'
3
-
4
- class File
5
- #
6
- # Creates a new +Sniffer+ that assumes this File contains Ruby source
7
- # code and examines that code for smells.
8
- #
9
- def sniff
10
- result = Reek::Sniffer.new
11
- Reek::Source.from_path(self.path, result)
12
- result
13
- end
14
- end
15
-
16
- class IO
17
- #
18
- # Creates a new +Sniffer+ that assumes this IO stream contains Ruby source
19
- # code and examines that code for smells.
20
- #
21
- def sniff(description = 'io')
22
- code = self.readlines.join
23
- result = Reek::Sniffer.new
24
- Reek::Source.new(code, description, result)
25
- result
26
- end
27
- end
28
-
29
- class String
30
- #
31
- # Creates a new +Sniffer+ that assumes this String contains Ruby source
32
- # code and examines that code for smells.
33
- #
34
- def sniff
35
- result = Reek::Sniffer.new
36
- Reek::Source.new(self, 'string', result)
37
- result
38
- end
39
- end
40
-
41
- class Array
42
- #
43
- # Creates a new +Sniffer+ that assumes this Array contains the names
44
- # of Ruby source files and examines those files for smells.
45
- #
46
- def sniff
47
- sniffers = self.map {|path| File.new(path).sniff }
48
- Reek::SnifferSet.new(sniffers, 'dir')
49
- end
50
- end
data/lib/reek/options.rb DELETED
@@ -1,103 +0,0 @@
1
- require 'optparse'
2
- require 'reek'
3
- require 'reek/source'
4
- require 'reek/core_extras' # SMELL
5
-
6
- module Reek
7
-
8
- class Options
9
-
10
- CTX_SORT = '%m%c %w (%s)'
11
- SMELL_SORT = '%m[%s] %c %w'
12
-
13
- def self.default_options
14
- {
15
- :format => CTX_SORT,
16
- :show_all => false,
17
- :quiet => false
18
- }
19
- end
20
-
21
- @@opts = default_options
22
-
23
- def self.[](key)
24
- @@opts[key]
25
- end
26
-
27
- def self.parse_args(args)
28
- result = default_options
29
- parser = OptionParser.new { |opts| set_options(opts, result) }
30
- parser.parse!(args)
31
- result
32
- end
33
-
34
- def self.set_options(opts, config)
35
- opts.banner = <<EOB
36
- Usage: #{opts.program_name} [options] files...
37
-
38
- If no files are given, Reek reads source code from standard input.
39
- See http://wiki.github.com/kevinrutherford/reek for detailed help.
40
- EOB
41
-
42
- opts.separator "\nOptions:"
43
- set_all_options(opts, config)
44
- end
45
-
46
- # SMELL: Greedy Module
47
- # This creates the command-line parser AND invokes it. And for the
48
- # -v and -h options it also executes them. And it holds the config
49
- # options for the rest of the application.
50
- def self.parse(args)
51
- @@opts = parse_args(args)
52
- if args.length > 0
53
- return args.sniff
54
- else
55
- return $stdin.sniff('$stdin')
56
- end
57
- end
58
-
59
- private
60
-
61
- def self.set_all_options(opts, config)
62
- set_show_all_option(opts, config)
63
- set_help_option(opts)
64
- set_sort_option(config, opts)
65
- set_version_option(opts)
66
- end
67
-
68
- def self.set_version_option(opts)
69
- opts.on("-v", "--version", "Show version") do
70
- puts "#{opts.program_name} #{Reek::VERSION}"
71
- exit(0)
72
- end
73
- end
74
-
75
- def self.set_show_all_option(opts, config)
76
- opts.on("-a", "--[no-]show-all", "Show all smells, including those masked by config settings") do |opt|
77
- config[:show_all] = opt
78
- end
79
- opts.on("-q", "--quiet", "Suppress headings for smell-free source files") do
80
- config[:quiet] = true
81
- end
82
- end
83
-
84
- def self.set_help_option(opts)
85
- opts.on("-h", "--help", "Show this message") do
86
- puts opts
87
- exit(0)
88
- end
89
- end
90
-
91
- def self.set_sort_option(config, opts)
92
- opts.on('-f', "--format FORMAT", 'Specify the format of smell warnings') do |arg|
93
- config[:format] = arg unless arg.nil?
94
- end
95
- opts.on('-c', '--context-first', "Sort by context; sets the format string to \"#{CTX_SORT}\"") do
96
- config[:format] = CTX_SORT
97
- end
98
- opts.on('-s', '--smell-first', "Sort by smell; sets the format string to \"#{SMELL_SORT}\"") do
99
- config[:format] = SMELL_SORT
100
- end
101
- end
102
- end
103
- end
data/lib/reek/report.rb DELETED
@@ -1,115 +0,0 @@
1
- require 'set'
2
- require 'reek/sniffer'
3
-
4
- module Reek
5
- class Report
6
- include Enumerable
7
-
8
- def initialize(sniffer) # :nodoc:
9
- @masked_warnings = SortedSet.new
10
- @warnings = SortedSet.new
11
- @desc = sniffer.desc
12
- sniffer.report_on(self)
13
- end
14
-
15
- #
16
- # Checks this report for instances of +smell_class+, and returns +true+
17
- # only if one of them has a report string matching all of the +patterns+.
18
- #
19
- def has_smell?(smell_class, patterns)
20
- @warnings.any? { |smell| smell.matches?(smell_class, patterns) }
21
- end
22
-
23
- def <<(smell) # :nodoc:
24
- @warnings << smell
25
- true
26
- end
27
-
28
- def record_masked_smell(smell)
29
- @masked_warnings << smell
30
- end
31
-
32
- def num_masked_smells
33
- @masked_warnings.length
34
- end
35
-
36
- def empty?
37
- @warnings.empty?
38
- end
39
-
40
- def length
41
- @warnings.length
42
- end
43
-
44
- alias size length
45
-
46
- # Creates a formatted report of all the +Smells::SmellWarning+ objects recorded in
47
- # this report, with a heading.
48
- def full_report
49
- return quiet_report if Options[:quiet]
50
- result = header(@warnings.length)
51
- result += ":\n#{smell_list}" if should_report
52
- result += "\n"
53
- result
54
- end
55
-
56
- def quiet_report
57
- return '' unless should_report
58
- "#{header(@warnings.length)}:\n#{smell_list}\n"
59
- end
60
-
61
- def should_report
62
- @warnings.length > 0 or (Options[:show_all] and @masked_warnings.length > 0)
63
- end
64
-
65
- def header(num_smells)
66
- result = "#{@desc} -- #{num_smells} warning"
67
- result += 's' unless num_smells == 1
68
- result += " (+#{@masked_warnings.length} masked)" unless @masked_warnings.empty?
69
- result
70
- end
71
-
72
- # Creates a formatted report of all the +Smells::SmellWarning+ objects recorded in
73
- # this report.
74
- def smell_list
75
- all = SortedSet.new(@warnings)
76
- all.merge(@masked_warnings) if Options[:show_all]
77
- all.map {|smell| " #{smell.report}"}.join("\n")
78
- end
79
- end
80
-
81
- class ReportList
82
- include Enumerable
83
-
84
- def initialize(sniffers)
85
- @sniffers = sniffers
86
- end
87
-
88
- def empty?
89
- length == 0
90
- end
91
-
92
- def length
93
- @sniffers.inject(0) {|sum, sniffer| sum + sniffer.num_smells }
94
- end
95
-
96
- # SMELL: Shotgun Surgery
97
- # This method and the next will have to be repeated for every new
98
- # kind of report.
99
- def full_report
100
- @sniffers.map { |sniffer| sniffer.full_report }.join
101
- end
102
-
103
- def quiet_report
104
- @sniffers.map { |sniffer| sniffer.quiet_report }.join
105
- end
106
-
107
- #
108
- # Checks this report for instances of +smell_class+, and returns +true+
109
- # only if one of them has a report string matching all of the +patterns+.
110
- #
111
- def has_smell?(smell_class, patterns)
112
- @sniffers.any? { |sniffer| sniffer.has_smell?(smell_class, patterns) }
113
- end
114
- end
115
- end
data/lib/reek/source.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'reek/sniffer'
2
-
3
- module Reek
4
-
5
- #
6
- # A +Source+ object represents a chunk of Ruby source code.
7
- #
8
- class Source
9
-
10
- #
11
- # Factory method: creates a +Source+ object by reading Ruby code from
12
- # the named file. The source code is not parsed until +report+ is called.
13
- #
14
- def self.from_path(filename, sniffer)
15
- code = IO.readlines(filename).join
16
- # SMELL: Greedy Method
17
- # The Sniffer should ask this source to configure it.
18
- sniffer.configure_along_path(filename)
19
- return new(code, filename, sniffer)
20
- end
21
-
22
- attr_reader :desc
23
- attr_reader :sniffer # SMELL -- bidirectional link
24
-
25
- def initialize(code, desc, sniffer) # :nodoc:
26
- @source = code
27
- @desc = desc
28
- @sniffer = sniffer
29
- @sniffer.source = self
30
- end
31
-
32
- def syntax_tree
33
- RubyParser.new.parse(@source, @desc) || s()
34
- end
35
- end
36
- end
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/options'
4
-
5
- include Reek
6
-
7
- describe Options, ' when given no arguments' do
8
- it "should retain the default sort order" do
9
- default_order = Options[:format]
10
- Options.parse_args(['nosuchfile.rb'])
11
- Options[:format].should == default_order
12
- end
13
- end
@@ -1,49 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/smells/smell_detector'
4
- require 'reek/report'
5
- require 'reek/source'
6
- require 'reek/smells/feature_envy'
7
-
8
- include Reek
9
-
10
- describe Report, " when empty" do
11
- before(:each) do
12
- @rpt = Report.new(Sniffer.new)
13
- end
14
-
15
- it 'should have zero length' do
16
- @rpt.length.should == 0
17
- end
18
-
19
- it 'should claim to be empty' do
20
- @rpt.should be_empty
21
- end
22
-
23
- it 'has an empty quiet_report' do
24
- @rpt.quiet_report.should == ''
25
- end
26
- end
27
-
28
- describe Report, "smell_list" do
29
- before(:each) do
30
- rpt = 'def simple(a) a[3] end'.sniff.report
31
- @report = rpt.smell_list.split("\n")
32
- end
33
-
34
- it 'should mention every smell name' do
35
- @report.should have_at_least(2).lines
36
- @report[0].should match(/[Utility Function]/)
37
- @report[1].should match(/[Feature Envy]/)
38
- end
39
- end
40
-
41
- describe Report, " as a SortedSet" do
42
- it 'should only add a smell once' do
43
- rpt = Report.new(Sniffer.new)
44
- rpt << SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!')
45
- rpt.length.should == 1
46
- rpt << SmellWarning.new(Smells::FeatureEnvy.new, "self", 'too many!')
47
- rpt.length.should == 1
48
- end
49
- end
@@ -1,44 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/report'
4
-
5
- include Reek
6
-
7
- describe 'sample gem source code' do
8
- it "reports the correct smells in inline.rb" do
9
- ruby = File.new("#{SAMPLES_DIR}/inline.rb").sniff
10
- ruby.should reek_of(:ControlCouple, /Inline::C#parse_signature/, /raw/)
11
- ruby.should reek_of(:ControlCouple, /Module#inline/, /options/)
12
- ruby.should reek_of(:Duplication, /Inline::C#build/, /\(\$\?\ == 0\)/)
13
- ruby.should reek_of(:Duplication, /Inline::C#build/, /Inline.directory/)
14
- ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts/)
15
- ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\("#endif"\)/)
16
- ruby.should reek_of(:Duplication, /Inline::C#build/, /io.puts\("#ifdef __cplusplus"\)/)
17
- ruby.should reek_of(:Duplication, /Inline::C#build/, /module_name/)
18
- ruby.should reek_of(:Duplication, /Inline::C#build/, /warn\("Output:\\n\#\{result\}"\)/)
19
- ruby.should reek_of(:Duplication, /Inline::C#crap_for_windoze/, /Config::CONFIG\["libdir"\]/)
20
- ruby.should reek_of(:Duplication, /Inline::C#generate/, /result.sub!\(\/\\A\\n\/, ""\)/)
21
- ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\["args"\]/)
22
- ruby.should reek_of(:Duplication, /Inline::C#generate/, /signature\["args"\].map/)
23
- ruby.should reek_of(:Duplication, /Inline::C#initialize/, /stack.empty?/)
24
- ruby.should reek_of(:Duplication, /Inline::C#load/, /so_name/)
25
- ruby.should reek_of(:Duplication, /Inline::self.rootdir/, /env.nil?/)
26
- ruby.should reek_of(:Duplication, /Module#inline/, /Inline.const_get\(lang\)/)
27
- ruby.should reek_of(:FeatureEnvy, /Inline::C#strip_comments/, /src/)
28
- ruby.should reek_of(:LargeClass, /Inline::C/, /instance variables/)
29
- ruby.should reek_of(:LongMethod, /Inline::C#build/)
30
- ruby.should reek_of(:LongMethod, /Inline::C#generate/)
31
- ruby.should reek_of(:LongMethod, /Inline::C#parse_signature/)
32
- ruby.should reek_of(:LongMethod, /Inline::self.rootdir/)
33
- ruby.should reek_of(:LongMethod, /Module#inline/)
34
- ruby.should reek_of(:NestedIterators, /Inline::C#build/)
35
- ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'t'/)
36
- ruby.should reek_of(:UncommunicativeName, /Inline::C#build/, /'n'/)
37
- ruby.should reek_of(:UncommunicativeName, /Inline::C#c/, /'c'/)
38
- ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'m'/)
39
- ruby.should reek_of(:UncommunicativeName, /Inline::C#module_name/, /'x'/)
40
- ruby.should reek_of(:UncommunicativeName, /Inline::C#parse_signature/, /'x'/)
41
- ruby.should reek_of(:UtilityFunction, /Inline::C#strip_comments/)
42
- Report.new(ruby).length.should == 32
43
- end
44
- end
@@ -1,112 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/report'
4
-
5
- include Reek
6
-
7
- describe 'sample gem source code' do
8
- it "reports the correct smells in optparse.rb" do
9
- ruby = File.new("#{SAMPLES_DIR}/optparse.rb").sniff
10
- ruby.should reek_of(:ControlCouple, /OptionParser#List#accept/, /pat/)
11
- ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /lopts/)
12
- ruby.should reek_of(:ControlCouple, /OptionParser#List#update/, /sopts/)
13
- ruby.should reek_of(:ControlCouple, /OptionParser#ParseError#set_option/, /eq/)
14
- ruby.should reek_of(:ControlCouple, /OptionParser#Switch#NoArgument#parse/, /arg/)
15
- ruby.should reek_of(:ControlCouple, /OptionParser#Switch#OptionalArgument#parse/, /arg/)
16
- ruby.should reek_of(:ControlCouple, /OptionParser#Switch#RequiredArgument#parse/, /arg/)
17
- ruby.should reek_of(:ControlCouple, /OptionParser#block/, /o/)
18
- ruby.should reek_of(:ControlCouple, /OptionParser#block/, /s/)
19
- ruby.should reek_of(:ControlCouple, /OptionParser#block\/block/, /pkg/)
20
- ruby.should reek_of(:ControlCouple, /OptionParser#getopts\/block/, /val/)
21
- ruby.should reek_of(:ControlCouple, /OptionParser#parse_in_order/, /setter/)
22
- ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /candidates.size/)
23
- ruby.should reek_of(:Duplication, /OptionParser#Completion::complete/, /k.id2name/)
24
- ruby.should reek_of(:Duplication, /OptionParser#Switch#parse_arg/, /s.length/)
25
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect \{ \|s\| s\.length \}\.max/)
26
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect \{ \|s\| s\.length \}\.max\.to_i/)
27
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /\(indent \+ l\)/)
28
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.collect/)
29
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left.shift/)
30
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /left\[-1\]/)
31
- ruby.should reek_of(:Duplication, /OptionParser#Switch#summarize/, /s.length/)
32
- ruby.should reek_of(:Duplication, /OptionParser#getopts/, /result\[opt\] = false/)
33
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /default_style.guess\(arg = a\)/)
34
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /\(long << o = q.downcase\)/)
35
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /notwice\(a \? \(Object\) : \(TrueClass\), klass, "type"\)/)
36
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /notwice\(NilClass, klass, "type"\)/)
37
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(:convert\)/)
38
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.method\(:convert\).to_proc/)
39
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /pattern.respond_to\?\(:convert\)/)
40
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /q.downcase/)
41
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /search\(:atype, o\)/)
42
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /search\(:atype, FalseClass\)/)
43
- ruby.should reek_of(:Duplication, /OptionParser#make_switch/, /\(sdesc << "-\#\{q\}"\)/)
44
- ruby.should reek_of(:Duplication, /OptionParser#order/, /argv\[0\]/)
45
- ruby.should reek_of(:Duplication, /OptionParser#parse/, /argv\[0\]/)
46
- ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /\$\!.set_option\(arg, true\)/)
47
- ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /cb.call\(val\)/)
48
- ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /setter.call\(sw.switch_name, val\)/)
49
- ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.block/)
50
- ruby.should reek_of(:Duplication, /OptionParser#parse_in_order/, /sw.switch_name/)
51
- ruby.should reek_of(:Duplication, /OptionParser#permute/, /argv\[0\]/)
52
- ruby.should reek_of(:FeatureEnvy, /OptionParser#Completion::complete/, /candidates/)
53
- ruby.should reek_of(:FeatureEnvy, /OptionParser#List#accept/, /pat/)
54
- ruby.should reek_of(:FeatureEnvy, /OptionParser#Switch#summarize/, /left/)
55
- ruby.should reek_of(:FeatureEnvy, /OptionParser#order/, /argv/)
56
- ruby.should reek_of(:FeatureEnvy, /OptionParser#parse/, /argv/)
57
- ruby.should reek_of(:FeatureEnvy, /OptionParser#permute/, /argv/)
58
- ruby.should reek_of(:LargeClass, /OptionParser/)
59
- ruby.should reek_of(:LongMethod, /OptionParser#Completion::complete/)
60
- ruby.should reek_of(:LongMethod, /OptionParser#List#update/)
61
- ruby.should reek_of(:LongMethod, /OptionParser#Switch#PlacedArgument#parse/)
62
- ruby.should reek_of(:LongMethod, /OptionParser#Switch#parse_arg/)
63
- ruby.should reek_of(:LongMethod, /OptionParser#Switch#summarize/)
64
- ruby.should reek_of(:LongMethod, /OptionParser#getopts/)
65
- ruby.should reek_of(:LongMethod, /OptionParser#make_switch/)
66
- ruby.should reek_of(:LongMethod, /OptionParser#parse_in_order/)
67
- ruby.should reek_of(:LongParameterList, /OptionParser#List#complete/)
68
- ruby.should reek_of(:LongParameterList, /OptionParser#List#update/)
69
- ruby.should reek_of(:LongParameterList, /OptionParser#Switch#summarize/)
70
- ruby.should reek_of(:LongParameterList, /OptionParser#complete/)
71
- ruby.should reek_of(:LongParameterList, /OptionParser#summarize/)
72
- ruby.should reek_of(:NestedIterators, /OptionParser#CompletingHash#match/)
73
- ruby.should reek_of(:NestedIterators, /OptionParser#Switch#summarize/)
74
- ruby.should reek_of(:NestedIterators, /OptionParser#block/)
75
- ruby.should reek_of(:NestedIterators, /OptionParser#complete/)
76
- ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
77
- ruby.should reek_of(:NestedIterators, /OptionParser#make_switch/)
78
- ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
79
- ruby.should reek_of(:NestedIterators, /OptionParser#parse_in_order/)
80
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'k'/)
81
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Completion::complete/, /'v'/)
82
- ruby.should reek_of(:UncommunicativeName, /OptionParser#List#accept/, /'t'/)
83
- ruby.should reek_of(:UncommunicativeName, /OptionParser#List#reject/, /'t'/)
84
- ruby.should reek_of(:UncommunicativeName, /OptionParser#List#update/, /'o'/)
85
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#add_banner/, /'s'/)
86
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'m'/)
87
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#parse_arg/, /'s'/)
88
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.guess/, /'t'/)
89
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#self.incompatible_argument_styles/, /'t'/)
90
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'l'/)
91
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'r'/)
92
- ruby.should reek_of(:UncommunicativeName, /OptionParser#Switch#summarize/, /'s'/)
93
- ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'f'/)
94
- ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'k'/)
95
- ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'o'/)
96
- ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'s'/)
97
- ruby.should reek_of(:UncommunicativeName, /OptionParser#block/, /'v'/)
98
- ruby.should reek_of(:UncommunicativeName, /OptionParser#load/, /'s'/)
99
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'a'/)
100
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'n'/)
101
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'o'/)
102
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'q'/)
103
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'s'/)
104
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'c'/)
105
- ruby.should reek_of(:UncommunicativeName, /OptionParser#make_switch/, /'v'/)
106
- ruby.should reek_of(:UncommunicativeName, /OptionParser#search/, /'k'/)
107
- ruby.should reek_of(:UncommunicativeName, /OptionParser#summarize/, /'l'/)
108
- ruby.should reek_of(:UncommunicativeName, /OptionParser#ver/, /'v'/)
109
- ruby.should reek_of(:UncommunicativeName, /block/, /'q'/)
110
- Report.new(ruby).length.should == 117
111
- end
112
- end
@@ -1,105 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- require 'reek/report'
4
-
5
- include Reek
6
-
7
- describe 'sample gem source code' do
8
- it "reports the correct smells in redcloth.rb" do
9
- ruby = File.new("#{SAMPLES_DIR}/redcloth.rb").sniff
10
- ruby.should reek_of(:ControlCouple, /RedCloth#blocks\/block/, /deep_code/)
11
- ruby.should reek_of(:ControlCouple, /RedCloth#check_refs/, /text/)
12
- ruby.should reek_of(:ControlCouple, /RedCloth#pba/, /text_in/)
13
- ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /atts/)
14
- ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /cite/)
15
- ruby.should reek_of(:ControlCouple, /RedCloth#textile_fn_/, /atts/)
16
- ruby.should reek_of(:ControlCouple, /RedCloth#textile_p/, /atts/)
17
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last/)
18
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last.length/)
19
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth\[i\]/)
20
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /\(line_id - 1\)/)
21
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /lines\[\(line_id - 1\)\]/)
22
- ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /tl.length/)
23
- ruby.should reek_of(:Duplication, /RedCloth#clean_html/, /tags\[tag\]/)
24
- ruby.should reek_of(:Duplication, /RedCloth#pba/, /\$1.length/)
25
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /@pre_list.last/)
26
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(@pre_list.last << line\)/)
27
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(codepre - used_offtags.length\)/)
28
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(\(codepre - used_offtags.length\) > 0\)/)
29
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.zero?/)
30
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /htmlesc\(line, :NoQuotes\)/)
31
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags.length/)
32
- ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags\["notextile"\]/)
33
- ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_atx/, /text/)
34
- ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_rule/, /text/)
35
- ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_setext/, /text/)
36
- ruby.should reek_of(:FeatureEnvy, /RedCloth#block_textile_lists/, /depth/)
37
- ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /raw/)
38
- ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /tags/)
39
- ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_white_space/, /text/)
40
- ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /indt/)
41
- ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /text/)
42
- ruby.should reek_of(:FeatureEnvy, /RedCloth#footnote_ref/, /text/)
43
- ruby.should reek_of(:FeatureEnvy, /RedCloth#htmlesc/, /str/)
44
- ruby.should reek_of(:FeatureEnvy, /RedCloth#incoming_entities/, /text/)
45
- ruby.should reek_of(:FeatureEnvy, /RedCloth#no_textile/, /text/)
46
- ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /style/)
47
- ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /text/)
48
- ruby.should reek_of(:LargeClass, /RedCloth/)
49
- ruby.should reek_of(:LongMethod, /RedCloth#block_markdown_bq/)
50
- ruby.should reek_of(:LongMethod, /RedCloth#block_textile_lists/)
51
- ruby.should reek_of(:LongMethod, /RedCloth#block_textile_table/)
52
- ruby.should reek_of(:LongMethod, /RedCloth#blocks/)
53
- ruby.should reek_of(:LongMethod, /RedCloth#clean_html/)
54
- ruby.should reek_of(:LongMethod, /RedCloth#clean_white_space/)
55
- ruby.should reek_of(:LongMethod, /RedCloth#glyphs_textile/)
56
- ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_link/)
57
- ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_reflink/)
58
- ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_image/)
59
- ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_link/)
60
- ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_span/)
61
- ruby.should reek_of(:LongMethod, /RedCloth#pba/)
62
- ruby.should reek_of(:LongMethod, /RedCloth#rip_offtags/)
63
- ruby.should reek_of(:LongMethod, /RedCloth#to_html/)
64
- ruby.should reek_of(:LongParameterList, /RedCloth#textile_bq/)
65
- ruby.should reek_of(:LongParameterList, /RedCloth#textile_fn_/)
66
- ruby.should reek_of(:LongParameterList, /RedCloth#textile_p/)
67
- ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
68
- ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/)
69
- ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
70
- ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/)
71
- ruby.should reek_of(:NestedIterators, /RedCloth#blocks/)
72
- ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
73
- ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/)
74
- ruby.should reek_of(:NestedIterators, /RedCloth#inline/)
75
- ruby.should reek_of(:NestedIterators, /RedCloth#inline_textile_span/)
76
- ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'a'/)
77
- ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'b'/)
78
- ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'i'/)
79
- ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'v'/)
80
- ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_table/, /'x'/)
81
- ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q'/)
82
- ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q2'/)
83
- ruby.should reek_of(:UncommunicativeName, /RedCloth#initialize/, /'r'/)
84
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_link/, /'m'/)
85
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_reflink/, /'m'/)
86
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_code/, /'m'/)
87
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_image/, /'m'/)
88
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_link/, /'m'/)
89
- ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_span/, /'m'/)
90
- ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_markdown/, /'m'/)
91
- ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_textile/, /'m'/)
92
- ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'i'/)
93
- ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'r'/)
94
- ruby.should reek_of(:UtilityFunction, /RedCloth#block_markdown_rule/)
95
- ruby.should reek_of(:UtilityFunction, /RedCloth#clean_html/)
96
- ruby.should reek_of(:UtilityFunction, /RedCloth#flush_left/)
97
- ruby.should reek_of(:UtilityFunction, /RedCloth#footnote_ref/)
98
- ruby.should reek_of(:UtilityFunction, /RedCloth#h_align/)
99
- ruby.should reek_of(:UtilityFunction, /RedCloth#htmlesc/)
100
- ruby.should reek_of(:UtilityFunction, /RedCloth#incoming_entities/)
101
- ruby.should reek_of(:UtilityFunction, /RedCloth#no_textile/)
102
- ruby.should reek_of(:UtilityFunction, /RedCloth#v_align/)
103
- Report.new(ruby).length.should == 93
104
- end
105
- end
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe 'Reek source code:' do
4
- Dir['lib/**/*.rb'].each do |path|
5
- it "reports no smells in #{path}" do
6
- File.new(path).should_not reek
7
- end
8
- end
9
-
10
- it 'reports no smells via the Dir matcher' do
11
- Dir['lib/**/*.rb'].should_not reek
12
- end
13
- end