kevinrutherford-reek 1.1.3.15 → 1.1.3.16

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
@@ -29,7 +29,10 @@
29
29
  ** LongMethod no longer counts control structures, only their contained stmts
30
30
  ** See http://wiki.github.com/kevinrutherford/reek/long-method for details
31
31
  * UncommunicativeName warns about any name ending in a number (fixed #18)
32
- * UtilityFunction no longer reports methods that call 'super' (fixed #39)
32
+ * UtilityFunction has been relaxed somewhat:
33
+ ** no longer reports methods that call 'super' (fixed #39)
34
+ ** no longer reports simple helper methods
35
+ ** can be configured based on number of calls out
33
36
  * Now reports an error for corrupt config files
34
37
  * Empty config files are ignored
35
38
  * Smells can be configured with scope-specific overrides for any config item
data/README.rdoc ADDED
@@ -0,0 +1,83 @@
1
+ = Reek -- code smell detection for Ruby
2
+
3
+ Reek is a tool that examines Ruby classes, modules and methods and
4
+ reports any code smells it finds. Install it like this:
5
+
6
+ $ gem install reek
7
+
8
+ and run it like this:
9
+
10
+ $ reek [options] [dir_or_source_file]*
11
+
12
+ For a full list of command-line options see the Reek
13
+ wiki[http://wiki.github.com/kevinrutherford/reek/command-line-options]
14
+ or run
15
+
16
+ $ reek --help
17
+
18
+ == Example
19
+
20
+ Imagine a source file <tt>csv_writer.rb</tt> containing:
21
+
22
+ class CsvWriter
23
+ def write_line(fields)
24
+ if (fields.length == 0)
25
+ puts
26
+ else
27
+ write_field(fields[0])
28
+ 1.upto(fields.length-1) do |i|
29
+ print ","
30
+ write_field(fields[i])
31
+ end
32
+ puts
33
+ end
34
+ end
35
+
36
+ #...
37
+ end
38
+
39
+ Reek will report the following code smells in this file:
40
+
41
+ $ reek csv_writer.rb
42
+ CsvWriter#write_line calls fields.length multiple times (Duplication)
43
+ CsvWriter#write_line has approx 6 statements (Long Method)
44
+ CsvWriter#write_line/block has the variable name 'i' (Uncommunicative Name)
45
+
46
+ == Features
47
+
48
+ Reek currently includes checks for some aspects of the following smells:
49
+
50
+ * {Control Couple}[http://wiki.github.com/kevinrutherford/reek/control-couple]
51
+ * {Data Clump}[http://wiki.github.com/kevinrutherford/reek/data-clump]
52
+ * {Feature Envy}[http://wiki.github.com/kevinrutherford/reek/feature-envy]
53
+ * {Large Class}[http://wiki.github.com/kevinrutherford/reek/large-class]
54
+ * {Long Method}[http://wiki.github.com/kevinrutherford/reek/long-method]
55
+ * {Long Parameter List}[http://wiki.github.com/kevinrutherford/reek/long-parameter-list]
56
+ * {Simulated Polymorphism}[http://wiki.github.com/kevinrutherford/reek/simulated-polymorphism]
57
+ * {Uncommunicative Name}[http://wiki.github.com/kevinrutherford/reek/uncommunicative-name]
58
+
59
+ ...and more. See the Reek wiki[http://wiki.github.com/kevinrutherford/reek/code-smells]
60
+ for up to date details of exactly what Reek will check in your code.
61
+
62
+ === Tool Integration
63
+
64
+ Reek integrates with many of your favourite tools:
65
+
66
+ * Use <tt>Reek::RakeTask</tt> to easily add Reek to your Rakefile
67
+ * Use <tt>Reek::Spec</tt> to add the <tt>should_not reek</tt> custom matcher to your Rspec examples
68
+ * Reek is fully compliant with Ruby 1.8.6, 1.8.7 and 1.9.1
69
+
70
+ === Dependencies
71
+
72
+ Reek makes use of the following other gems:
73
+
74
+ * ruby_parser
75
+ * sexp_processor
76
+
77
+ == Learn More
78
+
79
+ Find out more about Reek from any of the following sources:
80
+
81
+ * Browse the Reek documentation at http://wiki.github.com/kevinrutherford/reek
82
+ * Browse the code or install the latest cutting-edge beta version from http://github.com/kevinrutherford/reek/tree
83
+ * Read the code API at http://rdoc.info/projects/kevinrutherford/reek
data/config/defaults.reek CHANGED
@@ -27,7 +27,7 @@ UncommunicativeName:
27
27
  - !ruby/regexp /^.$/
28
28
  - !ruby/regexp /[0-9]$/
29
29
  NestedIterators:
30
- exclude: &id001 []
30
+ exclude: []
31
31
 
32
32
  enabled: true
33
33
  LongMethod:
@@ -41,7 +41,9 @@ Duplication:
41
41
  enabled: true
42
42
  max_calls: 1
43
43
  UtilityFunction:
44
- exclude: *id001
44
+ max_helper_calls: 1
45
+ exclude: []
46
+
45
47
  enabled: true
46
48
  SimulatedPolymorphism:
47
49
  exclude: []
@@ -184,7 +184,7 @@ Feature: Basic smell detection
184
184
  Then it fails with exit status 2
185
185
  And it reports:
186
186
  """
187
- spec/samples/redcloth.rb -- 100 warnings:
187
+ spec/samples/redcloth.rb -- 95 warnings:
188
188
  RedCloth has at least 44 methods (Large Class)
189
189
  RedCloth takes parameters [atts, cite, content, tag] to 3 methods (Data Clump)
190
190
  RedCloth tests atts at least 6 times (Simulated Polymorphism)
@@ -195,7 +195,6 @@ Feature: Basic smell detection
195
195
  RedCloth#block has the variable name 'b' (Uncommunicative Name)
196
196
  RedCloth#block_markdown_atx refers to text more than self (Feature Envy)
197
197
  RedCloth#block_markdown_bq has approx 6 statements (Long Method)
198
- RedCloth#block_markdown_rule doesn't depend on instance state (Utility Function)
199
198
  RedCloth#block_markdown_rule refers to text more than self (Feature Envy)
200
199
  RedCloth#block_markdown_setext refers to text more than self (Feature Envy)
201
200
  RedCloth#block_textile_lists calls (line_id - 1) twice (Duplication)
@@ -232,13 +231,10 @@ Feature: Basic smell detection
232
231
  RedCloth#flush_left doesn't depend on instance state (Utility Function)
233
232
  RedCloth#flush_left refers to indt more than self (Feature Envy)
234
233
  RedCloth#flush_left refers to text more than self (Feature Envy)
235
- RedCloth#footnote_ref doesn't depend on instance state (Utility Function)
236
234
  RedCloth#footnote_ref refers to text more than self (Feature Envy)
237
235
  RedCloth#glyphs_textile has approx 10 statements (Long Method)
238
- RedCloth#h_align doesn't depend on instance state (Utility Function)
239
236
  RedCloth#htmlesc doesn't depend on instance state (Utility Function)
240
237
  RedCloth#htmlesc refers to str more than self (Feature Envy)
241
- RedCloth#incoming_entities doesn't depend on instance state (Utility Function)
242
238
  RedCloth#incoming_entities refers to text more than self (Feature Envy)
243
239
  RedCloth#initialize/block has the variable name 'r' (Uncommunicative Name)
244
240
  RedCloth#inline/block/block is nested (Nested Iterators)
@@ -284,6 +280,5 @@ Feature: Basic smell detection
284
280
  RedCloth#textile_p has 4 parameters (Long Parameter List)
285
281
  RedCloth#textile_p is controlled by argument atts (Control Couple)
286
282
  RedCloth#to_html has approx 24 statements (Long Method)
287
- RedCloth#v_align doesn't depend on instance state (Utility Function)
288
283
 
289
284
  """
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.15'
4
+ VERSION = '1.1.3.16'
5
5
  end
@@ -48,7 +48,7 @@ module Reek
48
48
  end
49
49
  end
50
50
 
51
- def initialize(config = SmellDetector.default_config)
51
+ def initialize(config = self.class.default_config)
52
52
  @config = SmellConfiguration.new(config)
53
53
  @smells_found = Set.new
54
54
  @masked = false
@@ -10,22 +10,39 @@ module Reek
10
10
  #
11
11
  # Currently +UtilityFunction+ will warn about any method that:
12
12
  #
13
- # * is non-empty
14
- # * does not override an inherited method
15
- # * calls at least one method on another object
16
- # * doesn't use any of self's instance variables
13
+ # * is non-empty, and
14
+ # * does not override an inherited method, and
15
+ # * calls at least one method on another object, and
16
+ # * doesn't use any of self's instance variables, and
17
17
  # * doesn't use any of self's methods
18
18
  #
19
19
  class UtilityFunction < SmellDetector
20
20
 
21
+ # The name of the config field that sets the maximum number of
22
+ # calls permitted within a helper method. Any method with more than
23
+ # this number of method calls on other objects will be considered a
24
+ # candidate Utility Function.
25
+ HELPER_CALLS_LIMIT_KEY = 'max_helper_calls'
26
+
27
+ DEFAULT_HELPER_CALLS_LIMIT = 1
28
+
29
+ def self.default_config
30
+ super.adopt(HELPER_CALLS_LIMIT_KEY => DEFAULT_HELPER_CALLS_LIMIT)
31
+ end
32
+
33
+ def initialize(config = Duplication.default_config)
34
+ super(config)
35
+ end
36
+
21
37
  #
22
38
  # Checks whether the given +method+ is a utility function.
23
39
  # Remembers any smells found.
24
40
  #
25
41
  def examine_context(method)
26
- return false if method.calls.keys.length == 0 or
27
- method.num_statements == 0 or
28
- method.depends_on_instance?
42
+ return false if method.num_statements == 0 or
43
+ method.depends_on_instance? or
44
+ method.calls.keys.length <= value(HELPER_CALLS_LIMIT_KEY, method, DEFAULT_HELPER_CALLS_LIMIT)
45
+ # SMELL: loads of calls to value{} with the above pattern
29
46
  found(method, "doesn't depend on instance state")
30
47
  end
31
48
  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.1.3.15"
5
+ s.version = "1.1.3.16"
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-09-03}
9
+ s.date = %q{2009-09-19}
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
- s.extra_rdoc_files = ["History.txt", "License.txt", "README.txt"]
15
- s.files = ["History.txt", "License.txt", "README.txt", "Rakefile", "bin/reek", "config/defaults.reek", "features/masking_smells.feature", "features/options.feature", "features/reports.feature", "features/samples.feature", "features/stdin.feature", "features/step_definitions/reek_steps.rb", "features/support/env.rb", "lib/reek.rb", "lib/reek/adapters/application.rb", "lib/reek/adapters/config_file.rb", "lib/reek/adapters/core_extras.rb", "lib/reek/adapters/object_source.rb", "lib/reek/adapters/rake_task.rb", "lib/reek/adapters/report.rb", "lib/reek/adapters/source.rb", "lib/reek/adapters/spec.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/command_line.rb", "lib/reek/configuration.rb", "lib/reek/detector_stack.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/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/data_clump.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/simulated_polymorphism.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/sniffer.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/quality/reek_source_spec.rb", "spec/reek/adapters/report_spec.rb", "spec/reek/adapters/should_reek_of_spec.rb", "spec/reek/adapters/should_reek_only_of_spec.rb", "spec/reek/adapters/should_reek_spec.rb", "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/configuration_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/object_source_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smell_warning_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/data_clump_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/simulated_polymorphism_spec.rb", "spec/reek/smells/smell_detector_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/sniffer_spec.rb", "spec/samples/all_but_one_masked/clean_one.rb", "spec/samples/all_but_one_masked/dirty.rb", "spec/samples/all_but_one_masked/masked.reek", "spec/samples/clean_due_to_masking/clean_one.rb", "spec/samples/clean_due_to_masking/clean_three.rb", "spec/samples/clean_due_to_masking/clean_two.rb", "spec/samples/clean_due_to_masking/dirty_one.rb", "spec/samples/clean_due_to_masking/dirty_two.rb", "spec/samples/clean_due_to_masking/masked.reek", "spec/samples/corrupt_config_file/corrupt.reek", "spec/samples/corrupt_config_file/dirty.rb", "spec/samples/empty_config_file/dirty.rb", "spec/samples/empty_config_file/empty.reek", "spec/samples/exceptions.reek", "spec/samples/inline.rb", "spec/samples/masked/dirty.rb", "spec/samples/masked/masked.reek", "spec/samples/mixed_results/clean_one.rb", "spec/samples/mixed_results/clean_three.rb", "spec/samples/mixed_results/clean_two.rb", "spec/samples/mixed_results/dirty_one.rb", "spec/samples/mixed_results/dirty_two.rb", "spec/samples/not_quite_masked/dirty.rb", "spec/samples/not_quite_masked/masked.reek", "spec/samples/optparse.rb", "spec/samples/overrides/masked/dirty.rb", "spec/samples/overrides/masked/lower.reek", "spec/samples/overrides/upper.reek", "spec/samples/redcloth.rb", "spec/samples/three_clean_files/clean_one.rb", "spec/samples/three_clean_files/clean_three.rb", "spec/samples/three_clean_files/clean_two.rb", "spec/samples/two_smelly_files/dirty_one.rb", "spec/samples/two_smelly_files/dirty_two.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/test.rake"]
14
+ s.extra_rdoc_files = ["History.txt", "License.txt", "README.rdoc"]
15
+ s.files = ["History.txt", "License.txt", "README.rdoc", "Rakefile", "bin/reek", "config/defaults.reek", "features/masking_smells.feature", "features/options.feature", "features/reports.feature", "features/samples.feature", "features/stdin.feature", "features/step_definitions/reek_steps.rb", "features/support/env.rb", "lib/reek.rb", "lib/reek/adapters/application.rb", "lib/reek/adapters/config_file.rb", "lib/reek/adapters/core_extras.rb", "lib/reek/adapters/object_source.rb", "lib/reek/adapters/rake_task.rb", "lib/reek/adapters/report.rb", "lib/reek/adapters/source.rb", "lib/reek/adapters/spec.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.rb", "lib/reek/command_line.rb", "lib/reek/configuration.rb", "lib/reek/detector_stack.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/sexp_formatter.rb", "lib/reek/singleton_method_context.rb", "lib/reek/smell_warning.rb", "lib/reek/smells/control_couple.rb", "lib/reek/smells/data_clump.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/simulated_polymorphism.rb", "lib/reek/smells/smell_detector.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/sniffer.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/quality/reek_source_spec.rb", "spec/reek/adapters/report_spec.rb", "spec/reek/adapters/should_reek_of_spec.rb", "spec/reek/adapters/should_reek_only_of_spec.rb", "spec/reek/adapters/should_reek_spec.rb", "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/configuration_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/object_source_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smell_warning_spec.rb", "spec/reek/smells/control_couple_spec.rb", "spec/reek/smells/data_clump_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/simulated_polymorphism_spec.rb", "spec/reek/smells/smell_detector_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/sniffer_spec.rb", "spec/samples/all_but_one_masked/clean_one.rb", "spec/samples/all_but_one_masked/dirty.rb", "spec/samples/all_but_one_masked/masked.reek", "spec/samples/clean_due_to_masking/clean_one.rb", "spec/samples/clean_due_to_masking/clean_three.rb", "spec/samples/clean_due_to_masking/clean_two.rb", "spec/samples/clean_due_to_masking/dirty_one.rb", "spec/samples/clean_due_to_masking/dirty_two.rb", "spec/samples/clean_due_to_masking/masked.reek", "spec/samples/corrupt_config_file/corrupt.reek", "spec/samples/corrupt_config_file/dirty.rb", "spec/samples/empty_config_file/dirty.rb", "spec/samples/empty_config_file/empty.reek", "spec/samples/exceptions.reek", "spec/samples/inline.rb", "spec/samples/masked/dirty.rb", "spec/samples/masked/masked.reek", "spec/samples/mixed_results/clean_one.rb", "spec/samples/mixed_results/clean_three.rb", "spec/samples/mixed_results/clean_two.rb", "spec/samples/mixed_results/dirty_one.rb", "spec/samples/mixed_results/dirty_two.rb", "spec/samples/not_quite_masked/dirty.rb", "spec/samples/not_quite_masked/masked.reek", "spec/samples/optparse.rb", "spec/samples/overrides/masked/dirty.rb", "spec/samples/overrides/masked/lower.reek", "spec/samples/overrides/upper.reek", "spec/samples/redcloth.rb", "spec/samples/three_clean_files/clean_one.rb", "spec/samples/three_clean_files/clean_three.rb", "spec/samples/three_clean_files/clean_two.rb", "spec/samples/two_smelly_files/dirty_one.rb", "spec/samples/two_smelly_files/dirty_two.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/test.rake"]
16
16
  s.homepage = %q{http://wiki.github.com/kevinrutherford/reek}
17
17
  s.post_install_message = %q{
18
18
  For more information on reek, see http://wiki.github.com/kevinrutherford/reek
@@ -27,9 +27,9 @@ describe FeatureEnvy do
27
27
 
28
28
  it 'should not report return value' do
29
29
  'def no_envy(arga)
30
- arga.barg(@item)
31
- arga
32
- end'.should_not reek
30
+ arga.barg(@item)
31
+ arga
32
+ end'.should_not reek
33
33
  end
34
34
 
35
35
  it 'should report many calls to parameter' do
@@ -6,62 +6,77 @@ include Reek
6
6
  include Reek::Smells
7
7
 
8
8
  describe UtilityFunction do
9
-
10
- it 'should count usages of self'do
11
- 'def <=>(other) Options[:sort_order].compare(self, other) end'.should_not reek
12
- end
13
- it 'should count self reference within a dstr' do
14
- 'def as(alias_name); "#{self} as #{alias_name}".to_sym; end'.should_not reek
15
- end
16
- it 'should count calls to self within a dstr' do
17
- 'def to_sql; "\'#{self.gsub(/\'/, "\'\'")}\'"; end'.should_not reek
18
- end
19
- it 'should report simple parameter call' do
20
- 'def simple(arga) arga.to_s end'.should reek_of(:UtilityFunction, /simple/)
21
- end
22
- it 'should report message chain' do
23
- 'def simple(arga) arga.b.c end'.should reek_of(:UtilityFunction, /simple/)
9
+ context 'with no calls' do
10
+ it 'does not report empty method' do
11
+ 'def simple(arga) end'.should_not reek
12
+ end
13
+ it 'does not report literal' do
14
+ 'def simple(arga) 3; end'.should_not reek
15
+ end
16
+ it 'does not report instance variable reference' do
17
+ 'def simple(arga) @yellow end'.should_not reek
18
+ end
19
+ it 'does not report vcall' do
20
+ 'def simple(arga) y end'.should_not reek
21
+ end
22
+ it 'does not report references to self' do
23
+ 'def into; self; end'.should_not reek
24
+ end
25
+ it 'recognises an ivar reference within a block' do
26
+ 'def clean(text) text.each { @fred = 3} end'.should_not reek
27
+ end
24
28
  end
25
29
 
26
- it 'does not report a method that calls super' do
27
- 'def child(arg) super; arg.to_s; end'.should_not reek
28
- end
29
-
30
- it 'should recognise a deep call' do
31
- src = <<EOS
32
- class Red
33
- def deep(text)
34
- text.each { |mod| atts = shelve(mod) }
30
+ context 'with only one call' do
31
+ it 'does not report a call to a parameter' do
32
+ 'def simple(arga)
33
+ arga.to_s
34
+ end'.should_not reek_of(:UtilityFunction, /simple/)
35
+ end
36
+ it 'does not report a call to a constant' do
37
+ 'def simple(arga)
38
+ FIELDS[arga]
39
+ end'.should_not reek
40
+ end
35
41
  end
36
42
 
37
- def shelve(val)
38
- @shelf << val
39
- end
40
- end
41
- EOS
42
- src.should_not reek
43
- end
44
- end
43
+ context 'with two or more calls' do
44
+ it 'reports two calls' do
45
+ 'def simple(arga)
46
+ arga.to_s + arga.to_i
47
+ end'.should reek_of(:UtilityFunction, /simple/)
48
+ end
49
+ it 'should count usages of self'do
50
+ 'def <=>(other) Options[:sort_order].compare(self, other) end'.should_not reek
51
+ end
52
+ it 'should count self reference within a dstr' do
53
+ 'def as(alias_name); "#{self} as #{alias_name}".to_sym; end'.should_not reek
54
+ end
55
+ it 'should count calls to self within a dstr' do
56
+ 'def to_sql; "\'#{self.gsub(/\'/, "\'\'")}\'"; end'.should_not reek
57
+ end
58
+ it 'should report message chain' do
59
+ 'def simple(arga) arga.b.c end'.should reek_of(:UtilityFunction, /simple/)
60
+ end
45
61
 
46
- describe UtilityFunction, 'should only report a method containing a call' do
47
- it 'should not report empty method' do
48
- 'def simple(arga) end'.should_not reek
49
- end
50
- it 'should not report literal' do
51
- 'def simple(arga) 3; end'.should_not reek
52
- end
53
- it 'should not report instance variable reference' do
54
- 'def simple(arga) @yellow end'.should_not reek
55
- end
56
- it 'should not report vcall' do
57
- 'def simple(arga) y end'.should_not reek
58
- end
59
- it 'should not report references to self' do
60
- 'def into; self; end'.should_not reek
61
- end
62
+ it 'does not report a method that calls super' do
63
+ 'def child(arg) super; arg.to_s; end'.should_not reek
64
+ end
65
+
66
+ it 'should recognise a deep call' do
67
+ src = <<EOS
68
+ class Red
69
+ def deep(text)
70
+ text.each { |mod| atts = shelve(mod) }
71
+ end
62
72
 
63
- it 'should recognise an ivar reference within a block' do
64
- 'def clean(text) text.each { @fred = 3} end'.should_not reek
73
+ def shelve(val)
74
+ @shelf << val
75
+ end
76
+ end
77
+ EOS
78
+ src.should_not reek
79
+ end
65
80
  end
66
81
  end
67
82
 
data/spec/spec.opts CHANGED
@@ -1 +1 @@
1
- --colour
1
+ --color
data/tasks/test.rake CHANGED
@@ -10,12 +10,14 @@ namespace 'test' do
10
10
 
11
11
  Spec::Rake::SpecTask.new('spec') do |t|
12
12
  t.spec_files = UNIT_TESTS
13
+ t.spec_opts = ['--color']
13
14
  t.ruby_opts = ['-Ilib']
14
15
  t.rcov = false
15
16
  end
16
17
 
17
18
  Spec::Rake::SpecTask.new('quality') do |t|
18
19
  t.spec_files = QUALITY_TESTS
20
+ t.spec_opts = ['--color']
19
21
  t.ruby_opts = ['-Ilib']
20
22
  t.rcov = false
21
23
  end
@@ -33,7 +35,7 @@ namespace 'test' do
33
35
  end
34
36
 
35
37
  Cucumber::Rake::Task.new(:features) do |t|
36
- t.cucumber_opts = "features --format progress --no-color"
38
+ t.cucumber_opts = "features --format progress --color"
37
39
  end
38
40
 
39
41
  desc 'Runs all unit tests, acceptance tests and quality checks'
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.15
4
+ version: 1.1.3.16
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-09-03 00:00:00 -07:00
12
+ date: 2009-09-19 00:00:00 -07:00
13
13
  default_executable: reek
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -52,11 +52,11 @@ extensions: []
52
52
  extra_rdoc_files:
53
53
  - History.txt
54
54
  - License.txt
55
- - README.txt
55
+ - README.rdoc
56
56
  files:
57
57
  - History.txt
58
58
  - License.txt
59
- - README.txt
59
+ - README.rdoc
60
60
  - Rakefile
61
61
  - bin/reek
62
62
  - config/defaults.reek
@@ -181,6 +181,7 @@ files:
181
181
  - tasks/test.rake
182
182
  has_rdoc: false
183
183
  homepage: http://wiki.github.com/kevinrutherford/reek
184
+ licenses:
184
185
  post_install_message: |
185
186
 
186
187
  For more information on reek, see http://wiki.github.com/kevinrutherford/reek
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  requirements: []
206
207
 
207
208
  rubyforge_project: reek
208
- rubygems_version: 1.2.0
209
+ rubygems_version: 1.3.5
209
210
  signing_key:
210
211
  specification_version: 3
211
212
  summary: Code smell detector for Ruby
data/README.txt DELETED
@@ -1,6 +0,0 @@
1
- = Reek
2
-
3
- Code smell detection for Ruby.
4
-
5
- The documentation is at http://wiki.github.com/kevinrutherford/reek
6
- The code lives at http://github.com/kevinrutherford/reek/tree