kevinrutherford-reek 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/reek/report.rb CHANGED
@@ -9,6 +9,9 @@ module Reek
9
9
  @report = SortedSet.new
10
10
  end
11
11
 
12
+ #
13
+ # Yields, in turn, each SmellWarning in this report.
14
+ #
12
15
  def each
13
16
  @report.each { |smell| yield smell }
14
17
  end
@@ -18,11 +21,11 @@ module Reek
18
21
  true
19
22
  end
20
23
 
21
- def empty? # :nodoc:
24
+ def empty?
22
25
  @report.empty?
23
26
  end
24
27
 
25
- def length # :nodoc:
28
+ def length
26
29
  @report.length
27
30
  end
28
31
 
@@ -39,4 +42,33 @@ module Reek
39
42
  end
40
43
  end
41
44
 
45
+ class ReportList
46
+ include Enumerable
47
+
48
+ def initialize(sources)
49
+ @sources = sources
50
+ end
51
+
52
+ #
53
+ # Yields, in turn, each SmellWarning in every report in this report.
54
+ #
55
+ def each(&blk)
56
+ @sources.each {|src| src.report.each(&blk) }
57
+ end
58
+
59
+ def empty?
60
+ length == 0
61
+ end
62
+
63
+ def length
64
+ @sources.inject(0) {|sum, src| sum + src.report.length }
65
+ end
66
+
67
+ def to_s
68
+ @sources.select {|src| src.smelly? }.map do |src|
69
+ warnings = src.report
70
+ "\"#{src}\" -- #{warnings.length} warnings:\n#{warnings.to_s}\n"
71
+ end.join("\n")
72
+ end
73
+ end
42
74
  end
data/lib/reek/source.rb CHANGED
@@ -107,10 +107,7 @@ module Reek
107
107
  end
108
108
 
109
109
  def report
110
- @sources.select {|src| src.smelly? }.map do |src|
111
- warnings = src.report
112
- "\"#{src}\" -- #{warnings.length} warnings:\n#{warnings.to_s}\n"
113
- end.join("\n")
110
+ ReportList.new(@sources)
114
111
  end
115
112
  end
116
113
  end
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.0.0'
4
+ VERSION = '1.0.1'
5
5
  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.0.0"
5
+ s.version = "1.0.1"
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-04-05}
9
+ s.date = %q{2009-04-06}
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
14
  s.extra_rdoc_files = ["History.txt", "README.txt"]
15
- s.files = ["History.txt", "README.txt", "Rakefile", "bin/reek", "config/defaults.reek", "lib/reek.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.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/options.rb", "lib/reek/rake_task.rb", "lib/reek/report.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/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/smell_detector.rb", "lib/reek/smells/smells.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/source.rb", "lib/reek/spec.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/integration/reek_source_spec.rb", "spec/integration/script_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/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/options_spec.rb", "spec/reek/report_spec.rb", "spec/reek/sexp_formatter_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smells/control_couple_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/smell_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/samples/inline.rb", "spec/samples/inline_spec.rb", "spec/samples/optparse.rb", "spec/samples/optparse_spec.rb", "spec/samples/redcloth.rb", "spec/samples/redcloth_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/rspec.rake"]
15
+ s.files = ["History.txt", "README.txt", "Rakefile", "bin/reek", "config/defaults.reek", "lib/reek.rb", "lib/reek/block_context.rb", "lib/reek/class_context.rb", "lib/reek/code_context.rb", "lib/reek/code_parser.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/options.rb", "lib/reek/rake_task.rb", "lib/reek/report.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/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/smell_detector.rb", "lib/reek/smells/smells.rb", "lib/reek/smells/uncommunicative_name.rb", "lib/reek/smells/utility_function.rb", "lib/reek/source.rb", "lib/reek/spec.rb", "lib/reek/stop_context.rb", "lib/reek/yield_call_context.rb", "reek.gemspec", "spec/integration/reek_source_spec.rb", "spec/integration/script_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/if_context_spec.rb", "spec/reek/method_context_spec.rb", "spec/reek/module_context_spec.rb", "spec/reek/object_refs_spec.rb", "spec/reek/options_spec.rb", "spec/reek/report_spec.rb", "spec/reek/sexp_formatter_spec.rb", "spec/reek/singleton_method_context_spec.rb", "spec/reek/smells/control_couple_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/smell_spec.rb", "spec/reek/smells/uncommunicative_name_spec.rb", "spec/reek/smells/utility_function_spec.rb", "spec/reek/source_spec.rb", "spec/samples/inline.rb", "spec/samples/inline_spec.rb", "spec/samples/optparse.rb", "spec/samples/optparse_spec.rb", "spec/samples/redcloth.rb", "spec/samples/redcloth_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/reek.rake", "tasks/rspec.rake"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://wiki.github.com/kevinrutherford/reek}
18
18
  s.post_install_message = %q{
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ require 'reek/source'
4
+
5
+ include Reek
6
+
7
+ describe SourceList do
8
+
9
+ describe 'with no smells in any source' do
10
+ before :each do
11
+ @src = Dir['lib/reek/*.rb'].to_source
12
+ end
13
+
14
+ it 'reports no smells' do
15
+ @src.report.length.should == 0
16
+ end
17
+
18
+ it 'is empty' do
19
+ @src.report.should be_empty
20
+ end
21
+ end
22
+
23
+ describe 'with smells in one source' do
24
+ before :each do
25
+ @src = Source.from_pathlist(['spec/samples/inline.rb', 'lib/reek.rb'])
26
+ end
27
+
28
+ it 'reports some smells in the samples' do
29
+ @src.report.length.should == 32
30
+ end
31
+
32
+ it 'is smelly' do
33
+ @src.should be_smelly
34
+ end
35
+
36
+ it 'reports an UncommunicativeName' do
37
+ @src.report.any? {|warning| warning.report =~ /Uncommunicative Name/}.should be_true
38
+ end
39
+ end
40
+ end
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.0.0
4
+ version: 1.0.1
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-04-05 00:00:00 -07:00
12
+ date: 2009-04-06 00:00:00 -07:00
13
13
  default_executable: reek
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,7 @@ files:
106
106
  - spec/reek/smells/smell_spec.rb
107
107
  - spec/reek/smells/uncommunicative_name_spec.rb
108
108
  - spec/reek/smells/utility_function_spec.rb
109
+ - spec/reek/source_spec.rb
109
110
  - spec/samples/inline.rb
110
111
  - spec/samples/inline_spec.rb
111
112
  - spec/samples/optparse.rb