reek 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +44 -4
- data/License.txt +20 -0
- data/README.rdoc +83 -0
- data/Rakefile +0 -1
- data/bin/reek +3 -11
- data/config/defaults.reek +20 -1
- data/features/masking_smells.feature +111 -0
- data/features/options.feature +49 -0
- data/features/reports.feature +90 -0
- data/features/samples.feature +284 -0
- data/features/stdin.feature +43 -0
- data/features/step_definitions/reek_steps.rb +35 -0
- data/features/support/env.rb +38 -0
- data/lib/reek.rb +1 -1
- data/lib/reek/adapters/application.rb +47 -0
- data/lib/reek/adapters/config_file.rb +31 -0
- data/lib/reek/adapters/core_extras.rb +72 -0
- data/lib/reek/{object_source.rb → adapters/object_source.rb} +15 -19
- data/lib/reek/{rake_task.rb → adapters/rake_task.rb} +2 -2
- data/lib/reek/adapters/report.rb +91 -0
- data/lib/reek/adapters/source.rb +53 -0
- data/lib/reek/{spec.rb → adapters/spec.rb} +45 -60
- data/lib/reek/block_context.rb +1 -1
- data/lib/reek/class_context.rb +26 -6
- data/lib/reek/code_context.rb +8 -0
- data/lib/reek/code_parser.rb +82 -39
- data/lib/reek/command_line.rb +85 -0
- data/lib/reek/configuration.rb +51 -0
- data/lib/reek/detector_stack.rb +39 -0
- data/lib/reek/exceptions.reek +8 -1
- data/lib/reek/method_context.rb +53 -11
- data/lib/reek/module_context.rb +1 -2
- data/lib/reek/name.rb +8 -2
- data/lib/reek/sexp_formatter.rb +2 -0
- data/lib/reek/smell_warning.rb +26 -8
- data/lib/reek/smells/control_couple.rb +8 -4
- data/lib/reek/smells/data_clump.rb +88 -0
- data/lib/reek/smells/duplication.rb +11 -9
- data/lib/reek/smells/feature_envy.rb +3 -4
- data/lib/reek/smells/large_class.rb +17 -17
- data/lib/reek/smells/long_method.rb +10 -8
- data/lib/reek/smells/long_parameter_list.rb +16 -10
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +3 -3
- data/lib/reek/smells/simulated_polymorphism.rb +58 -0
- data/lib/reek/smells/smell_detector.rb +94 -27
- data/lib/reek/smells/uncommunicative_name.rb +23 -23
- data/lib/reek/smells/utility_function.rb +27 -11
- data/lib/reek/sniffer.rb +183 -0
- data/reek.gemspec +5 -5
- data/spec/quality/reek_source_spec.rb +15 -0
- data/spec/reek/adapters/report_spec.rb +49 -0
- data/spec/reek/adapters/should_reek_of_spec.rb +108 -0
- data/spec/reek/adapters/should_reek_only_of_spec.rb +87 -0
- data/spec/reek/adapters/should_reek_spec.rb +92 -0
- data/spec/reek/block_context_spec.rb +7 -1
- data/spec/reek/class_context_spec.rb +39 -16
- data/spec/reek/code_context_spec.rb +7 -7
- data/spec/reek/code_parser_spec.rb +6 -1
- data/spec/reek/config_spec.rb +3 -3
- data/spec/reek/configuration_spec.rb +12 -0
- data/spec/reek/method_context_spec.rb +2 -2
- data/spec/reek/name_spec.rb +24 -0
- data/spec/reek/object_source_spec.rb +23 -0
- data/spec/reek/singleton_method_context_spec.rb +2 -2
- data/spec/reek/smell_warning_spec.rb +53 -0
- data/spec/reek/smells/data_clump_spec.rb +87 -0
- data/spec/reek/smells/duplication_spec.rb +13 -17
- data/spec/reek/smells/feature_envy_spec.rb +23 -28
- data/spec/reek/smells/large_class_spec.rb +109 -34
- data/spec/reek/smells/long_method_spec.rb +140 -3
- data/spec/reek/smells/long_parameter_list_spec.rb +1 -2
- data/spec/reek/smells/simulated_polymorphism_spec.rb +50 -0
- data/spec/reek/smells/smell_detector_spec.rb +53 -0
- data/spec/reek/smells/uncommunicative_name_spec.rb +20 -7
- data/spec/reek/smells/utility_function_spec.rb +76 -67
- data/spec/reek/sniffer_spec.rb +10 -0
- data/spec/samples/all_but_one_masked/clean_one.rb +6 -0
- data/spec/samples/all_but_one_masked/dirty.rb +7 -0
- data/spec/samples/all_but_one_masked/masked.reek +5 -0
- data/spec/samples/clean_due_to_masking/clean_one.rb +6 -0
- data/spec/samples/clean_due_to_masking/clean_three.rb +6 -0
- data/spec/samples/clean_due_to_masking/clean_two.rb +6 -0
- data/spec/samples/clean_due_to_masking/dirty_one.rb +7 -0
- data/spec/samples/clean_due_to_masking/dirty_two.rb +7 -0
- data/spec/samples/clean_due_to_masking/masked.reek +7 -0
- data/spec/samples/corrupt_config_file/corrupt.reek +1 -0
- data/spec/samples/corrupt_config_file/dirty.rb +7 -0
- data/spec/samples/empty_config_file/dirty.rb +7 -0
- data/spec/samples/empty_config_file/empty.reek +0 -0
- data/spec/samples/exceptions.reek +4 -0
- data/spec/{slow/samples → samples}/inline.rb +0 -0
- data/spec/samples/masked/dirty.rb +7 -0
- data/spec/samples/masked/masked.reek +3 -0
- data/spec/samples/mixed_results/clean_one.rb +6 -0
- data/spec/samples/mixed_results/clean_three.rb +6 -0
- data/spec/samples/mixed_results/clean_two.rb +6 -0
- data/spec/samples/mixed_results/dirty_one.rb +7 -0
- data/spec/samples/mixed_results/dirty_two.rb +7 -0
- data/spec/samples/not_quite_masked/dirty.rb +8 -0
- data/spec/samples/not_quite_masked/masked.reek +5 -0
- data/spec/{slow/samples → samples}/optparse.rb +0 -0
- data/spec/samples/overrides/masked/dirty.rb +7 -0
- data/spec/samples/overrides/masked/lower.reek +5 -0
- data/spec/samples/overrides/upper.reek +5 -0
- data/spec/{slow/samples → samples}/redcloth.rb +0 -0
- data/spec/samples/three_clean_files/clean_one.rb +6 -0
- data/spec/samples/three_clean_files/clean_three.rb +6 -0
- data/spec/samples/three_clean_files/clean_two.rb +6 -0
- data/spec/samples/two_smelly_files/dirty_one.rb +7 -0
- data/spec/samples/two_smelly_files/dirty_two.rb +7 -0
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +4 -4
- data/tasks/reek.rake +8 -5
- data/tasks/test.rake +51 -0
- metadata +75 -25
- data/README.txt +0 -6
- data/lib/reek/options.rb +0 -92
- data/lib/reek/report.rb +0 -81
- data/lib/reek/smells/smells.rb +0 -81
- data/lib/reek/source.rb +0 -127
- data/spec/reek/options_spec.rb +0 -13
- data/spec/reek/report_spec.rb +0 -48
- data/spec/reek/smells/smell_spec.rb +0 -24
- data/spec/slow/inline_spec.rb +0 -43
- data/spec/slow/optparse_spec.rb +0 -108
- data/spec/slow/redcloth_spec.rb +0 -101
- data/spec/slow/reek_source_spec.rb +0 -20
- data/spec/slow/script_spec.rb +0 -55
- data/spec/slow/source_list_spec.rb +0 -40
- data/tasks/rspec.rake +0 -21
data/History.txt
CHANGED
@@ -1,10 +1,50 @@
|
|
1
|
+
== 1.2 2009-09-20
|
2
|
+
|
3
|
+
=== Major Changes
|
4
|
+
* Reek passes all its tests under ruby 1.8.6, 1.8.7 and 1.9.1 (fixed #16)
|
5
|
+
* New smell -- Data Clump:
|
6
|
+
** Looks within a class for 3 or more methods taking the same 2 or more parameters
|
7
|
+
* New smell -- Simulated Polymorphism:
|
8
|
+
** Currently only performs basic check for multiple tests of same value
|
9
|
+
* Reek's output reports are now formatted differently:
|
10
|
+
** Reek is no longer silent about smell-free source code
|
11
|
+
** Output now reports on all files examined, even if they have no smells
|
12
|
+
** Smell warnings are indented in the report; file summary headers are not
|
13
|
+
** Reports for multiple sources are run together; no more blank lines
|
14
|
+
** Reports in spec matcher failures are quiet (fixed #38)
|
15
|
+
* The smells masked by *.reek config files can now be seen:
|
16
|
+
** The header for each source file now counts masked smells
|
17
|
+
** The --show-all (-a) option shows masked warnings in the report
|
18
|
+
* The spec matchers are now accessed by requiring 'reek/adapters/spec'
|
19
|
+
|
20
|
+
=== Minor Changes
|
21
|
+
* Reek's RDoc is now hosted at http://rdoc.info/projects/kevinrutherford/reek
|
22
|
+
* If a dir is passed on the command-line all **/*.rb files below it are examined (fixed #41)
|
23
|
+
* Duplication warnings now report the number of identical calls
|
24
|
+
* FeatureEnvy no longer ignores :self when passed as a method parameter
|
25
|
+
* LargeClass is disabled when checking in-memory classes (fixed #28)
|
26
|
+
* LongParameterList accepts upto 5 parameters for #initialize methods
|
27
|
+
* Several changes to the LongMethod counting algorithm:
|
28
|
+
** LongMethod now counts statements deeper into each method (fixed #25)
|
29
|
+
** LongMethod no longer counts control structures, only their contained stmts
|
30
|
+
** See http://wiki.github.com/kevinrutherford/reek/long-method for details
|
31
|
+
* UncommunicativeName warns about any name ending in a number (fixed #18)
|
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
|
36
|
+
* Now reports an error for corrupt config files
|
37
|
+
* Empty config files are ignored
|
38
|
+
* Smells can be configured with scope-specific overrides for any config item
|
39
|
+
|
40
|
+
|
1
41
|
== 1.1.3 2009-05-19
|
2
42
|
|
3
43
|
=== Minor Changes
|
4
44
|
* No longer depends directly on the sexp_processor gem
|
5
45
|
|
6
46
|
=== Fixes
|
7
|
-
* LargeClass now relies only on the given source code (#26)
|
47
|
+
* LargeClass now relies only on the given source code (fixed #26)
|
8
48
|
|
9
49
|
== 1.1.2 2009-05-18
|
10
50
|
|
@@ -15,7 +55,7 @@
|
|
15
55
|
== 1.1.1 2009-05-08
|
16
56
|
|
17
57
|
=== Minor enhancements
|
18
|
-
* LargeClass now also warns about any class with > 9 instance variables (#6)
|
58
|
+
* LargeClass now also warns about any class with > 9 instance variables (fixed #6)
|
19
59
|
* Now depends on ruby2ruby, to display code better
|
20
60
|
* Duplication notices more repeated method calls
|
21
61
|
* Smells within blocks are now reported better
|
@@ -23,7 +63,7 @@
|
|
23
63
|
== 1.1.0 2009-04-10
|
24
64
|
|
25
65
|
=== Minor enhancements
|
26
|
-
* Now possible to write 'MyClass.should_not reek' (#33)
|
66
|
+
* Now possible to write 'MyClass.should_not reek' (fixed #33)
|
27
67
|
|
28
68
|
=== Fixes
|
29
69
|
* Now counts attr assignments ([]= etc) in feature envy calculations
|
@@ -32,7 +72,7 @@
|
|
32
72
|
== 1.0.1 2009-04-06
|
33
73
|
|
34
74
|
=== Fixes
|
35
|
-
* Dir[...].to_source now creates a Report that can be browsed (#36)
|
75
|
+
* Dir[...].to_source now creates a Report that can be browsed (fixed #36)
|
36
76
|
|
37
77
|
== 1.0.0 2009-04-05
|
38
78
|
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008,2009 Kevin Rutherford
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
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/Rakefile
CHANGED
data/bin/reek
CHANGED
@@ -1,19 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
3
|
# Reek examines Ruby source code for smells.
|
4
|
-
# Visit http://
|
4
|
+
# Visit http://wiki.github.com/kevinrutherford/reek for docs etc.
|
5
5
|
#
|
6
6
|
# Author: Kevin Rutherford
|
7
7
|
#
|
8
8
|
|
9
|
-
require 'reek'
|
10
|
-
require 'reek/source'
|
11
|
-
require 'reek/options'
|
9
|
+
require 'reek/adapters/application'
|
12
10
|
|
13
|
-
|
14
|
-
source = Reek::Options.parse(ARGV)
|
15
|
-
if source.smelly?
|
16
|
-
puts source.report
|
17
|
-
exitstatus = 2
|
18
|
-
end
|
19
|
-
exit(exitstatus)
|
11
|
+
exit Reek::Application.new(ARGV).execute
|
data/config/defaults.reek
CHANGED
@@ -10,6 +10,9 @@ LongParameterList:
|
|
10
10
|
exclude: []
|
11
11
|
|
12
12
|
enabled: true
|
13
|
+
overrides:
|
14
|
+
initialize:
|
15
|
+
max_params: 5
|
13
16
|
FeatureEnvy:
|
14
17
|
exclude:
|
15
18
|
- initialize
|
@@ -21,7 +24,8 @@ UncommunicativeName:
|
|
21
24
|
|
22
25
|
enabled: true
|
23
26
|
reject:
|
24
|
-
- !ruby/regexp
|
27
|
+
- !ruby/regexp /^.$/
|
28
|
+
- !ruby/regexp /[0-9]$/
|
25
29
|
NestedIterators:
|
26
30
|
exclude: []
|
27
31
|
|
@@ -37,9 +41,21 @@ Duplication:
|
|
37
41
|
enabled: true
|
38
42
|
max_calls: 1
|
39
43
|
UtilityFunction:
|
44
|
+
max_helper_calls: 1
|
40
45
|
exclude: []
|
41
46
|
|
42
47
|
enabled: true
|
48
|
+
SimulatedPolymorphism:
|
49
|
+
exclude: []
|
50
|
+
|
51
|
+
enabled: true
|
52
|
+
max_ifs: 2
|
53
|
+
DataClump:
|
54
|
+
exclude: []
|
55
|
+
|
56
|
+
enabled: true
|
57
|
+
max_copies: 2
|
58
|
+
min_clump_size: 2
|
43
59
|
ControlCouple:
|
44
60
|
exclude:
|
45
61
|
- initialize
|
@@ -49,3 +65,6 @@ LongYieldList:
|
|
49
65
|
exclude: []
|
50
66
|
|
51
67
|
enabled: true
|
68
|
+
overrides:
|
69
|
+
initialize:
|
70
|
+
max_params: 5
|
@@ -0,0 +1,111 @@
|
|
1
|
+
@masking
|
2
|
+
Feature: Masking smells using config files
|
3
|
+
In order to keep my reports meaningful
|
4
|
+
As a developer
|
5
|
+
I want to mask some smells using config files
|
6
|
+
|
7
|
+
Scenario: empty config file is ignored
|
8
|
+
When I run reek spec/samples/empty_config_file/dirty.rb
|
9
|
+
Then it fails with exit status 2
|
10
|
+
And it reports:
|
11
|
+
"""
|
12
|
+
spec/samples/empty_config_file/dirty.rb -- 6 warnings:
|
13
|
+
Dirty has the variable name '@s' (Uncommunicative Name)
|
14
|
+
Dirty#a calls @s.title twice (Duplication)
|
15
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
16
|
+
Dirty#a has the name 'a' (Uncommunicative Name)
|
17
|
+
Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
18
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
19
|
+
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: corrupt config file prevents normal output
|
23
|
+
When I run reek spec/samples/corrupt_config_file/dirty.rb
|
24
|
+
Then it fails with exit status 1
|
25
|
+
And it reports the error 'Error: Invalid configuration file "corrupt.reek" -- not a Hash'
|
26
|
+
|
27
|
+
Scenario: missing source file is an error
|
28
|
+
When I run reek no_such_file.rb
|
29
|
+
Then it fails with exit status 1
|
30
|
+
And it reports the error "Error: No such file or directory - no_such_file.rb"
|
31
|
+
|
32
|
+
Scenario: switch off one smell
|
33
|
+
When I run reek spec/samples/masked/dirty.rb
|
34
|
+
Then it fails with exit status 2
|
35
|
+
And it reports:
|
36
|
+
"""
|
37
|
+
spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
|
38
|
+
Dirty#a calls @s.title twice (Duplication)
|
39
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
40
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
41
|
+
|
42
|
+
"""
|
43
|
+
|
44
|
+
Scenario: switch off one smell but show all in the report
|
45
|
+
When I run reek --show-all spec/samples/masked/dirty.rb
|
46
|
+
Then it fails with exit status 2
|
47
|
+
And it reports:
|
48
|
+
"""
|
49
|
+
spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
|
50
|
+
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
51
|
+
Dirty#a calls @s.title twice (Duplication)
|
52
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
53
|
+
(masked) Dirty#a has the name 'a' (Uncommunicative Name)
|
54
|
+
(masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
55
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
56
|
+
|
57
|
+
"""
|
58
|
+
|
59
|
+
Scenario: switch off one smell and hide them in the report
|
60
|
+
When I run reek --no-show-all spec/samples/masked/dirty.rb
|
61
|
+
Then it fails with exit status 2
|
62
|
+
And it reports:
|
63
|
+
"""
|
64
|
+
spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
|
65
|
+
Dirty#a calls @s.title twice (Duplication)
|
66
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
67
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
68
|
+
|
69
|
+
"""
|
70
|
+
|
71
|
+
Scenario: non-masked smells are only counted once
|
72
|
+
When I run reek spec/samples/not_quite_masked/dirty.rb
|
73
|
+
Then it fails with exit status 2
|
74
|
+
And it reports:
|
75
|
+
"""
|
76
|
+
spec/samples/not_quite_masked/dirty.rb -- 5 warnings (+1 masked):
|
77
|
+
Dirty has the variable name '@s' (Uncommunicative Name)
|
78
|
+
Dirty#a calls @s.title twice (Duplication)
|
79
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
80
|
+
Dirty#a has the name 'a' (Uncommunicative Name)
|
81
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
82
|
+
|
83
|
+
"""
|
84
|
+
|
85
|
+
@overrides
|
86
|
+
Scenario: lower overrides upper
|
87
|
+
When I run reek spec/samples/overrides
|
88
|
+
Then it fails with exit status 2
|
89
|
+
And it reports:
|
90
|
+
"""
|
91
|
+
spec/samples/overrides/masked/dirty.rb -- 2 warnings (+4 masked):
|
92
|
+
Dirty#a calls @s.title twice (Duplication)
|
93
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
94
|
+
|
95
|
+
"""
|
96
|
+
|
97
|
+
@overrides
|
98
|
+
Scenario: all show up masked even when overridden
|
99
|
+
When I run reek --show-all spec/samples/overrides
|
100
|
+
Then it fails with exit status 2
|
101
|
+
And it reports:
|
102
|
+
"""
|
103
|
+
spec/samples/overrides/masked/dirty.rb -- 2 warnings (+4 masked):
|
104
|
+
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
105
|
+
Dirty#a calls @s.title twice (Duplication)
|
106
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
107
|
+
(masked) Dirty#a has the name 'a' (Uncommunicative Name)
|
108
|
+
(masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
109
|
+
(masked) Dirty#a/block/block is nested (Nested Iterators)
|
110
|
+
|
111
|
+
"""
|
@@ -0,0 +1,49 @@
|
|
1
|
+
@options
|
2
|
+
Feature: Reek can be controlled using command-line options
|
3
|
+
In order to change reek's default behaviour
|
4
|
+
As a developer
|
5
|
+
I want to supply options on the command line
|
6
|
+
|
7
|
+
Scenario: return non-zero status on bad option
|
8
|
+
When I run reek --no-such-option
|
9
|
+
Then it fails with exit status 1
|
10
|
+
And it reports the error "Error: invalid option: --no-such-option"
|
11
|
+
|
12
|
+
Scenario: return non-zero status on missing argument
|
13
|
+
When I run reek -f
|
14
|
+
Then it fails with exit status 1
|
15
|
+
And it reports the error "Error: missing argument: -f"
|
16
|
+
|
17
|
+
Scenario: display the current version number
|
18
|
+
When I run reek --version
|
19
|
+
Then it succeeds
|
20
|
+
And it reports the current version
|
21
|
+
|
22
|
+
Scenario: display the help information
|
23
|
+
When I run reek --help
|
24
|
+
Then it succeeds
|
25
|
+
And it reports:
|
26
|
+
"""
|
27
|
+
Usage: reek [options] [files]
|
28
|
+
|
29
|
+
Examples:
|
30
|
+
|
31
|
+
reek lib/*.rb
|
32
|
+
reek -q -a lib
|
33
|
+
cat my_class.rb | reek
|
34
|
+
|
35
|
+
See http://wiki.github.com/kevinrutherford/reek for detailed help.
|
36
|
+
|
37
|
+
Common options:
|
38
|
+
-h, --help Show this message
|
39
|
+
-v, --version Show version
|
40
|
+
|
41
|
+
|
42
|
+
Report formatting:
|
43
|
+
-a, --[no-]show-all Show all smells, including those masked by config settings
|
44
|
+
-q, --quiet Suppress headings for smell-free source files
|
45
|
+
-f, --format FORMAT Specify the format of smell warnings
|
46
|
+
-c, --context-first Sort by context; sets the format string to "%m%c %w (%s)"
|
47
|
+
-s, --smell-first Sort by smell; sets the format string to "%m[%s] %c %w"
|
48
|
+
|
49
|
+
"""
|
@@ -0,0 +1,90 @@
|
|
1
|
+
@reports
|
2
|
+
Feature: Correctly formatted reports
|
3
|
+
In order to get the most out of reek
|
4
|
+
As a developer
|
5
|
+
I want to be able to parse reek's output simply and consistently
|
6
|
+
|
7
|
+
Scenario Outline: two reports run together with indented smells
|
8
|
+
When I run reek <args>
|
9
|
+
Then it fails with exit status 2
|
10
|
+
And it reports:
|
11
|
+
"""
|
12
|
+
spec/samples/two_smelly_files/dirty_one.rb -- 6 warnings:
|
13
|
+
Dirty has the variable name '@s' (Uncommunicative Name)
|
14
|
+
Dirty#a calls @s.title twice (Duplication)
|
15
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
16
|
+
Dirty#a has the name 'a' (Uncommunicative Name)
|
17
|
+
Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
18
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
19
|
+
spec/samples/two_smelly_files/dirty_two.rb -- 6 warnings:
|
20
|
+
Dirty has the variable name '@s' (Uncommunicative Name)
|
21
|
+
Dirty#a calls @s.title twice (Duplication)
|
22
|
+
Dirty#a calls puts(@s.title) twice (Duplication)
|
23
|
+
Dirty#a has the name 'a' (Uncommunicative Name)
|
24
|
+
Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
25
|
+
Dirty#a/block/block is nested (Nested Iterators)
|
26
|
+
|
27
|
+
"""
|
28
|
+
|
29
|
+
Examples:
|
30
|
+
| args |
|
31
|
+
| spec/samples/two_smelly_files/*.rb |
|
32
|
+
| spec/samples/two_smelly_files |
|
33
|
+
|
34
|
+
Scenario Outline: good files show headers consecutively
|
35
|
+
When I run reek <args>
|
36
|
+
Then it succeeds
|
37
|
+
And it reports:
|
38
|
+
"""
|
39
|
+
spec/samples/three_clean_files/clean_one.rb -- 0 warnings
|
40
|
+
spec/samples/three_clean_files/clean_three.rb -- 0 warnings
|
41
|
+
spec/samples/three_clean_files/clean_two.rb -- 0 warnings
|
42
|
+
|
43
|
+
"""
|
44
|
+
|
45
|
+
Examples:
|
46
|
+
| args |
|
47
|
+
| spec/samples/three_clean_files/*.rb |
|
48
|
+
| spec/samples/three_clean_files |
|
49
|
+
|
50
|
+
Scenario Outline: --quiet turns off headers for fragrant files
|
51
|
+
When I run reek <option> spec/samples/three_clean_files/*.rb
|
52
|
+
Then it succeeds
|
53
|
+
And it reports:
|
54
|
+
"""
|
55
|
+
|
56
|
+
|
57
|
+
"""
|
58
|
+
|
59
|
+
Examples:
|
60
|
+
| option |
|
61
|
+
| -q |
|
62
|
+
| --quiet |
|
63
|
+
|
64
|
+
|
65
|
+
Scenario Outline: -a turns on details in presence of -q
|
66
|
+
When I run reek <options> spec/samples/clean_due_to_masking/*.rb
|
67
|
+
Then it succeeds
|
68
|
+
And it reports:
|
69
|
+
"""
|
70
|
+
spec/samples/clean_due_to_masking/dirty_one.rb -- 0 warnings (+6 masked):
|
71
|
+
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
72
|
+
(masked) Dirty#a calls @s.title twice (Duplication)
|
73
|
+
(masked) Dirty#a calls puts(@s.title) twice (Duplication)
|
74
|
+
(masked) Dirty#a has the name 'a' (Uncommunicative Name)
|
75
|
+
(masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
76
|
+
(masked) Dirty#a/block/block is nested (Nested Iterators)
|
77
|
+
spec/samples/clean_due_to_masking/dirty_two.rb -- 0 warnings (+6 masked):
|
78
|
+
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
79
|
+
(masked) Dirty#a calls @s.title twice (Duplication)
|
80
|
+
(masked) Dirty#a calls puts(@s.title) twice (Duplication)
|
81
|
+
(masked) Dirty#a has the name 'a' (Uncommunicative Name)
|
82
|
+
(masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
83
|
+
(masked) Dirty#a/block/block is nested (Nested Iterators)
|
84
|
+
|
85
|
+
"""
|
86
|
+
|
87
|
+
Examples:
|
88
|
+
| options |
|
89
|
+
| -q -a |
|
90
|
+
| -a -q |
|