reek 1.2.6 → 1.2.8
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/.yardopts +10 -0
- data/History.txt +62 -0
- data/README.md +74 -0
- data/bin/reek +2 -2
- data/config/defaults.reek +44 -5
- data/features/api.feature +20 -0
- data/features/masking_smells.feature +60 -42
- data/features/options.feature +7 -2
- data/features/rake_task.feature +29 -22
- data/features/reports.feature +9 -41
- data/features/samples.feature +184 -196
- data/features/stdin.feature +5 -8
- data/features/step_definitions/reek_steps.rb +8 -4
- data/features/support/env.rb +2 -3
- data/features/yaml.feature +85 -0
- data/lib/reek/cli/application.rb +46 -0
- data/lib/reek/cli/command_line.rb +108 -0
- data/lib/reek/cli/help_command.rb +18 -0
- data/lib/reek/cli/reek_command.rb +37 -0
- data/lib/reek/cli/report.rb +58 -0
- data/lib/reek/cli/version_command.rb +19 -0
- data/lib/reek/cli/yaml_command.rb +32 -0
- data/lib/reek/core/code_context.rb +64 -0
- data/lib/reek/core/code_parser.rb +166 -0
- data/lib/reek/core/method_context.rb +84 -0
- data/lib/reek/core/module_context.rb +20 -0
- data/lib/reek/core/object_refs.rb +51 -0
- data/lib/reek/core/singleton_method_context.rb +20 -0
- data/lib/reek/core/smell_configuration.rb +62 -0
- data/lib/reek/core/sniffer.rb +105 -0
- data/lib/reek/core/stop_context.rb +30 -0
- data/lib/reek/core/warning_collector.rb +27 -0
- data/lib/reek/examiner.rb +104 -0
- data/lib/reek/rake/task.rb +142 -0
- data/lib/reek/smell_warning.rb +73 -23
- data/lib/reek/smells/attribute.rb +26 -21
- data/lib/reek/smells/boolean_parameter.rb +38 -0
- data/lib/reek/smells/class_variable.rb +22 -9
- data/lib/reek/smells/control_couple.rb +40 -16
- data/lib/reek/smells/data_clump.rb +114 -23
- data/lib/reek/smells/duplication.rb +55 -15
- data/lib/reek/smells/feature_envy.rb +16 -7
- data/lib/reek/smells/irresponsible_module.rb +37 -0
- data/lib/reek/smells/large_class.rb +37 -19
- data/lib/reek/smells/long_method.rb +20 -9
- data/lib/reek/smells/long_parameter_list.rb +22 -10
- data/lib/reek/smells/long_yield_list.rb +43 -7
- data/lib/reek/smells/nested_iterators.rb +68 -8
- data/lib/reek/smells/simulated_polymorphism.rb +26 -15
- data/lib/reek/smells/smell_detector.rb +29 -51
- data/lib/reek/smells/uncommunicative_method_name.rb +74 -0
- data/lib/reek/smells/uncommunicative_module_name.rb +74 -0
- data/lib/reek/smells/uncommunicative_parameter_name.rb +79 -0
- data/lib/reek/smells/uncommunicative_variable_name.rb +89 -0
- data/lib/reek/smells/utility_function.rb +51 -12
- data/lib/reek/smells.rb +29 -0
- data/lib/reek/source/code_comment.rb +37 -0
- data/lib/reek/source/config_file.rb +72 -0
- data/lib/reek/source/core_extras.rb +46 -0
- data/lib/reek/source/reference_collector.rb +28 -0
- data/lib/reek/source/sexp_formatter.rb +17 -0
- data/lib/reek/source/source_code.rb +44 -0
- data/lib/reek/source/source_file.rb +32 -0
- data/lib/reek/source/source_locator.rb +42 -0
- data/lib/reek/source/tree_dresser.rb +204 -0
- data/lib/reek/source.rb +18 -0
- data/lib/reek/spec/should_reek.rb +31 -0
- data/lib/reek/spec/should_reek_of.rb +37 -0
- data/lib/reek/spec/should_reek_only_of.rb +37 -0
- data/lib/reek/spec.rb +51 -0
- data/lib/reek.rb +8 -4
- data/reek.gemspec +9 -7
- data/spec/matchers/smell_of_matcher.rb +58 -0
- data/spec/reek/{help_command_spec.rb → cli/help_command_spec.rb} +3 -4
- data/spec/reek/cli/reek_command_spec.rb +46 -0
- data/spec/reek/cli/report_spec.rb +30 -0
- data/spec/reek/{version_command_spec.rb → cli/version_command_spec.rb} +3 -3
- data/spec/reek/cli/yaml_command_spec.rb +47 -0
- data/spec/reek/core/code_context_spec.rb +145 -0
- data/spec/reek/{code_parser_spec.rb → core/code_parser_spec.rb} +7 -6
- data/spec/reek/{config_spec.rb → core/config_spec.rb} +2 -6
- data/spec/reek/{method_context_spec.rb → core/method_context_spec.rb} +16 -36
- data/spec/reek/core/module_context_spec.rb +27 -0
- data/spec/reek/{object_refs_spec.rb → core/object_refs_spec.rb} +5 -6
- data/spec/reek/core/singleton_method_context_spec.rb +9 -0
- data/spec/reek/core/smell_configuration_spec.rb +11 -0
- data/spec/reek/core/stop_context_spec.rb +17 -0
- data/spec/reek/core/warning_collector_spec.rb +27 -0
- data/spec/reek/examiner_spec.rb +103 -0
- data/spec/reek/smell_warning_spec.rb +74 -82
- data/spec/reek/smells/attribute_spec.rb +42 -23
- data/spec/reek/smells/behaves_like_variable_detector.rb +2 -2
- data/spec/reek/smells/boolean_parameter_spec.rb +66 -0
- data/spec/reek/smells/class_variable_spec.rb +60 -75
- data/spec/reek/smells/control_couple_spec.rb +37 -32
- data/spec/reek/smells/data_clump_spec.rb +63 -24
- data/spec/reek/smells/duplication_spec.rb +106 -57
- data/spec/reek/smells/feature_envy_spec.rb +113 -92
- data/spec/reek/smells/irresponsible_module_spec.rb +58 -0
- data/spec/reek/smells/large_class_spec.rb +67 -57
- data/spec/reek/smells/long_method_spec.rb +40 -10
- data/spec/reek/smells/long_parameter_list_spec.rb +50 -28
- data/spec/reek/smells/long_yield_list_spec.rb +57 -0
- data/spec/reek/smells/nested_iterators_spec.rb +115 -7
- data/spec/reek/smells/simulated_polymorphism_spec.rb +56 -20
- data/spec/reek/smells/smell_detector_shared.rb +42 -0
- data/spec/reek/smells/uncommunicative_method_name_spec.rb +42 -0
- data/spec/reek/smells/uncommunicative_module_name_spec.rb +66 -0
- data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +71 -0
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +120 -0
- data/spec/reek/smells/utility_function_spec.rb +50 -4
- data/spec/reek/source/code_comment_spec.rb +82 -0
- data/spec/reek/source/object_source_spec.rb +20 -0
- data/spec/reek/source/reference_collector_spec.rb +53 -0
- data/spec/reek/{adapters/source_spec.rb → source/source_code_spec.rb} +7 -8
- data/spec/reek/source/tree_dresser_spec.rb +270 -0
- data/spec/reek/spec/should_reek_of_spec.rb +76 -0
- data/spec/reek/spec/should_reek_only_of_spec.rb +89 -0
- data/spec/reek/{adapters → spec}/should_reek_spec.rb +8 -32
- data/spec/samples/all_but_one_masked/clean_one.rb +1 -0
- data/spec/samples/all_but_one_masked/dirty.rb +1 -0
- data/spec/samples/all_but_one_masked/masked.reek +5 -1
- data/spec/samples/clean_due_to_masking/clean_one.rb +1 -0
- data/spec/samples/clean_due_to_masking/clean_three.rb +1 -0
- data/spec/samples/clean_due_to_masking/clean_two.rb +1 -0
- data/spec/samples/clean_due_to_masking/dirty_one.rb +1 -1
- data/spec/samples/clean_due_to_masking/dirty_two.rb +1 -1
- data/spec/samples/clean_due_to_masking/masked.reek +5 -1
- data/spec/samples/config/allow_duplication.reek +3 -0
- data/spec/samples/config/deeper_nested_iterators.reek +3 -0
- data/spec/samples/corrupt_config_file/dirty.rb +1 -1
- data/spec/samples/demo/demo.rb +8 -0
- data/spec/samples/empty_config_file/dirty.rb +2 -1
- data/spec/samples/exceptions.reek +1 -1
- data/spec/samples/inline_config/dirty.rb +16 -0
- data/spec/samples/inline_config/masked.reek +7 -0
- data/spec/samples/mask_some/dirty.rb +8 -0
- data/spec/samples/mask_some/some.reek +8 -0
- data/spec/samples/masked/dirty.rb +2 -1
- data/spec/samples/masked/masked.reek +3 -1
- data/spec/samples/mixed_results/clean_one.rb +1 -0
- data/spec/samples/mixed_results/clean_three.rb +1 -0
- data/spec/samples/mixed_results/clean_two.rb +1 -0
- data/spec/samples/mixed_results/dirty_one.rb +1 -0
- data/spec/samples/mixed_results/dirty_two.rb +1 -0
- data/spec/samples/not_quite_masked/dirty.rb +2 -1
- data/spec/samples/not_quite_masked/masked.reek +1 -1
- data/spec/samples/overrides/masked/dirty.rb +2 -1
- data/spec/samples/overrides/masked/lower.reek +3 -1
- data/spec/samples/three_clean_files/clean_one.rb +1 -0
- data/spec/samples/three_clean_files/clean_three.rb +1 -0
- data/spec/samples/three_clean_files/clean_two.rb +1 -0
- data/spec/samples/two_smelly_files/dirty_one.rb +2 -1
- data/spec/samples/two_smelly_files/dirty_two.rb +2 -1
- data/spec/spec_helper.rb +10 -2
- data/tasks/reek.rake +2 -2
- data/tasks/test.rake +12 -3
- metadata +121 -79
- data/README.rdoc +0 -84
- data/features/profile.feature +0 -34
- data/lib/reek/adapters/application.rb +0 -46
- data/lib/reek/adapters/command_line.rb +0 -77
- data/lib/reek/adapters/config_file.rb +0 -31
- data/lib/reek/adapters/core_extras.rb +0 -64
- data/lib/reek/adapters/rake_task.rb +0 -121
- data/lib/reek/adapters/report.rb +0 -86
- data/lib/reek/adapters/source.rb +0 -72
- data/lib/reek/adapters/spec.rb +0 -133
- data/lib/reek/block_context.rb +0 -62
- data/lib/reek/class_context.rb +0 -41
- data/lib/reek/code_context.rb +0 -68
- data/lib/reek/code_parser.rb +0 -203
- data/lib/reek/configuration.rb +0 -57
- data/lib/reek/detector_stack.rb +0 -37
- data/lib/reek/help_command.rb +0 -14
- data/lib/reek/if_context.rb +0 -18
- data/lib/reek/masking_collection.rb +0 -33
- data/lib/reek/method_context.rb +0 -138
- data/lib/reek/module_context.rb +0 -49
- data/lib/reek/name.rb +0 -57
- data/lib/reek/object_refs.rb +0 -49
- data/lib/reek/reek_command.rb +0 -28
- data/lib/reek/sexp_formatter.rb +0 -10
- data/lib/reek/singleton_method_context.rb +0 -26
- data/lib/reek/smells/uncommunicative_name.rb +0 -84
- data/lib/reek/sniffer.rb +0 -177
- data/lib/reek/stop_context.rb +0 -35
- data/lib/reek/tree_dresser.rb +0 -82
- data/lib/reek/version_command.rb +0 -14
- data/lib/reek/yield_call_context.rb +0 -12
- data/spec/reek/adapters/report_spec.rb +0 -31
- data/spec/reek/adapters/should_reek_of_spec.rb +0 -138
- data/spec/reek/adapters/should_reek_only_of_spec.rb +0 -87
- data/spec/reek/block_context_spec.rb +0 -65
- data/spec/reek/class_context_spec.rb +0 -161
- data/spec/reek/code_context_spec.rb +0 -182
- data/spec/reek/configuration_spec.rb +0 -12
- data/spec/reek/if_context_spec.rb +0 -17
- data/spec/reek/masking_collection_spec.rb +0 -236
- data/spec/reek/module_context_spec.rb +0 -46
- data/spec/reek/name_spec.rb +0 -37
- data/spec/reek/object_source_spec.rb +0 -23
- data/spec/reek/reek_command_spec.rb +0 -45
- data/spec/reek/singleton_method_context_spec.rb +0 -16
- data/spec/reek/smells/smell_detector_spec.rb +0 -36
- data/spec/reek/smells/uncommunicative_name_spec.rb +0 -146
- data/spec/reek/sniffer_spec.rb +0 -11
- data/spec/reek/stop_context_spec.rb +0 -33
- data/spec/reek/tree_dresser_spec.rb +0 -20
data/.yardopts
ADDED
data/History.txt
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
+
== 1.2.8 (2010-04-26)
|
|
2
|
+
|
|
3
|
+
=== Major Changes
|
|
4
|
+
* Smell detectors can be configured or disabled in code comments
|
|
5
|
+
** Comment with :reek:smell_name disables the named smell for a class, module or method
|
|
6
|
+
** Comment with :reek:smell_name:{...} for more detailed configuration
|
|
7
|
+
* Additional config file(s) can be specified:
|
|
8
|
+
** on the command-line using -c
|
|
9
|
+
** via Reek::Rake::Task in the rakefile
|
|
10
|
+
|
|
11
|
+
=== Minor Changes
|
|
12
|
+
* Duplication can be configured to ignore specific calls
|
|
13
|
+
* IrresponsibleModule now reports scoped module names correctly (#66)
|
|
14
|
+
* NestedIterators is now more configurable:
|
|
15
|
+
** Option to specify permitted nesting depth (#14)
|
|
16
|
+
** Option to ignore certain iterator methods
|
|
17
|
+
|
|
18
|
+
== 1.2.7.3 (2010-03-29)
|
|
19
|
+
|
|
20
|
+
=== Minor Changes
|
|
21
|
+
* UtilityFunction no longer reported when local method called in param initializer (#60)
|
|
22
|
+
* Spaces removed from smell class names in report output
|
|
23
|
+
* Masked smells are no longer reported
|
|
24
|
+
** the -a command-line option has been removed
|
|
25
|
+
** some methods on Examiner are now deprecated
|
|
26
|
+
* DataClump no longer needs infinite memory for large classes (#57 again)
|
|
27
|
+
|
|
28
|
+
== 1.2.7.2 (2010-03-05)
|
|
29
|
+
|
|
30
|
+
=== Minor Changes
|
|
31
|
+
* Number of masked smells is no longer shown in report headers
|
|
32
|
+
* Masked smells are no longer listed in --yaml reports
|
|
33
|
+
* DataClump no longer needs infinite memory for large classes (#57)
|
|
34
|
+
* DataClump reports the names of the offending methods in the YAML report
|
|
35
|
+
* UncommunicativeMethodName now accepts operator names (+, -, ...)
|
|
36
|
+
* Uncommunicative Name now warns about uppercase letters in method & var names
|
|
37
|
+
|
|
38
|
+
== 1.2.7.1 (2010-02-03)
|
|
39
|
+
|
|
40
|
+
=== Minor Changes
|
|
41
|
+
* Fixed crash on a case statement with no condition (#58)
|
|
42
|
+
|
|
43
|
+
== 1.2.7 (2010-02-01)
|
|
44
|
+
|
|
45
|
+
=== Major Changes
|
|
46
|
+
* New option --yaml reports smells in YAML format
|
|
47
|
+
* Now require 'reek/rake/task' to use the rake task
|
|
48
|
+
* Now require 'reek/spec' to use the Rspec matchers
|
|
49
|
+
* Developer API completely revised and documented
|
|
50
|
+
|
|
51
|
+
=== Minor Changes
|
|
52
|
+
* New smell: Irresponsible Module (has no meaningful comment)
|
|
53
|
+
* ControlCouple no longer checks arguments yielded to blocks
|
|
54
|
+
* FeatureEnvy and UtilityFunction are now subclasses of a new smell: LowCohesion
|
|
55
|
+
* NestedIterators now reports the nesting depth
|
|
56
|
+
* Fixed problem checking for UtilityFunctions in Object
|
|
57
|
+
* Improved detection of invalid config files
|
|
58
|
+
* Invalid config files are now ignored
|
|
59
|
+
* Non-existent files are now ignored
|
|
60
|
+
|
|
61
|
+
See http://wiki.github.com/kevinrutherford/reek for further details.
|
|
62
|
+
|
|
1
63
|
== 1.2.6 (2009-11-28)
|
|
2
64
|
|
|
3
65
|
=== Minor Changes
|
data/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
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>demo.rb</tt> containing:
|
|
21
|
+
|
|
22
|
+
class Dirty
|
|
23
|
+
# This method smells of :reek:NestedIterators but ignores them
|
|
24
|
+
def awful(x, y, offset = 0, log = false)
|
|
25
|
+
puts @screen.title
|
|
26
|
+
@screen = widgets.map {|w| w.each {|key| key += 3}}
|
|
27
|
+
puts @screen.contents
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Reek will report the following code smells in this file:
|
|
32
|
+
|
|
33
|
+
$ reek demo.rb
|
|
34
|
+
spec/samples/demo/demo.rb -- 6 warnings:
|
|
35
|
+
Dirty has no descriptive comment (IrresponsibleModule)
|
|
36
|
+
Dirty#awful has 4 parameters (LongParameterList)
|
|
37
|
+
Dirty#awful has boolean parameter 'log' (ControlCouple)
|
|
38
|
+
Dirty#awful has the parameter name 'x' (UncommunicativeName)
|
|
39
|
+
Dirty#awful has the parameter name 'y' (UncommunicativeName)
|
|
40
|
+
Dirty#awful has the variable name 'w' (UncommunicativeName)
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
Reek currently includes checks for some aspects of Control Couple,
|
|
45
|
+
Data Clump, Feature Envy, Large Class, Long Method, Long Parameter List,
|
|
46
|
+
Simulated Polymorphism, Uncommunicative Name and more.
|
|
47
|
+
See the [Reek wiki](http://wiki.github.com/kevinrutherford/reek/code-smells)
|
|
48
|
+
for up to date details of exactly what Reek will check in your code.
|
|
49
|
+
|
|
50
|
+
### Tool Integration
|
|
51
|
+
|
|
52
|
+
Reek integrates with many of your favourite tools:
|
|
53
|
+
|
|
54
|
+
* `require 'reek/rake/task'` to easily add Reek to your Rakefile
|
|
55
|
+
* `require 'reek/spec'` to add the `should_not reek` custom matcher to your Rspec examples
|
|
56
|
+
* Reek is fully compliant with Ruby 1.8.6, 1.8.7 and 1.9.1
|
|
57
|
+
|
|
58
|
+
### Dependencies
|
|
59
|
+
|
|
60
|
+
Reek makes use of the following other gems:
|
|
61
|
+
|
|
62
|
+
* ruby_parser
|
|
63
|
+
* sexp_processor
|
|
64
|
+
* ruby2ruby
|
|
65
|
+
|
|
66
|
+
Learn More
|
|
67
|
+
----------
|
|
68
|
+
|
|
69
|
+
Find out more about Reek from any of the following sources:
|
|
70
|
+
|
|
71
|
+
* Browse the Reek documentation at [http://wiki.github.com/kevinrutherford/reek](http://wiki.github.com/kevinrutherford/reek)
|
|
72
|
+
* Browse the code or install the latest development version from [http://github.com/kevinrutherford/reek/tree](http://github.com/kevinrutherford/reek/tree)
|
|
73
|
+
* Read the code API at [http://rdoc.info/projects/kevinrutherford/reek](http://rdoc.info/projects/kevinrutherford/reek)
|
|
74
|
+
* Follow [@rubyreek](http://twitter.com/rubyreek) on twitter!
|
data/bin/reek
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
# Author: Kevin Rutherford
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
require 'reek
|
|
9
|
+
require File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib', 'reek', 'cli', 'application')
|
|
10
10
|
|
|
11
|
-
exit Reek::Application.new(ARGV).execute
|
|
11
|
+
exit Reek::Cli::Application.new(ARGV).execute
|
data/config/defaults.reek
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
---
|
|
2
|
+
UncommunicativeParameterName:
|
|
3
|
+
accept: []
|
|
4
|
+
|
|
5
|
+
exclude: []
|
|
6
|
+
|
|
7
|
+
enabled: true
|
|
8
|
+
reject:
|
|
9
|
+
- !ruby/regexp /^.$/
|
|
10
|
+
- !ruby/regexp /[0-9]$/
|
|
11
|
+
- !ruby/regexp /[A-Z]/
|
|
2
12
|
LargeClass:
|
|
3
13
|
max_methods: 25
|
|
4
14
|
exclude: []
|
|
5
15
|
|
|
6
16
|
enabled: true
|
|
7
17
|
max_instance_variables: 9
|
|
18
|
+
UncommunicativeMethodName:
|
|
19
|
+
accept: []
|
|
20
|
+
|
|
21
|
+
exclude: []
|
|
22
|
+
|
|
23
|
+
enabled: true
|
|
24
|
+
reject:
|
|
25
|
+
- !ruby/regexp /^[a-z]$/
|
|
26
|
+
- !ruby/regexp /[0-9]$/
|
|
27
|
+
- !ruby/regexp /[A-Z]/
|
|
8
28
|
LongParameterList:
|
|
9
29
|
max_params: 3
|
|
10
30
|
exclude: []
|
|
@@ -20,7 +40,13 @@ FeatureEnvy:
|
|
|
20
40
|
ClassVariable:
|
|
21
41
|
exclude: *id001
|
|
22
42
|
enabled: true
|
|
23
|
-
|
|
43
|
+
BooleanParameter:
|
|
44
|
+
exclude: *id001
|
|
45
|
+
enabled: true
|
|
46
|
+
IrresponsibleModule:
|
|
47
|
+
exclude: *id001
|
|
48
|
+
enabled: true
|
|
49
|
+
UncommunicativeModuleName:
|
|
24
50
|
accept:
|
|
25
51
|
- Inline::C
|
|
26
52
|
exclude: []
|
|
@@ -30,14 +56,20 @@ UncommunicativeName:
|
|
|
30
56
|
- !ruby/regexp /^.$/
|
|
31
57
|
- !ruby/regexp /[0-9]$/
|
|
32
58
|
NestedIterators:
|
|
33
|
-
|
|
59
|
+
ignore_iterators: []
|
|
60
|
+
|
|
61
|
+
exclude: []
|
|
62
|
+
|
|
34
63
|
enabled: true
|
|
64
|
+
max_allowed_nesting: 1
|
|
35
65
|
LongMethod:
|
|
36
66
|
max_statements: 5
|
|
37
67
|
exclude:
|
|
38
68
|
- initialize
|
|
39
69
|
enabled: true
|
|
40
70
|
Duplication:
|
|
71
|
+
allow_calls: []
|
|
72
|
+
|
|
41
73
|
exclude: []
|
|
42
74
|
|
|
43
75
|
enabled: true
|
|
@@ -51,6 +83,16 @@ Attribute:
|
|
|
51
83
|
exclude: []
|
|
52
84
|
|
|
53
85
|
enabled: false
|
|
86
|
+
UncommunicativeVariableName:
|
|
87
|
+
accept: []
|
|
88
|
+
|
|
89
|
+
exclude: []
|
|
90
|
+
|
|
91
|
+
enabled: true
|
|
92
|
+
reject:
|
|
93
|
+
- !ruby/regexp /^.$/
|
|
94
|
+
- !ruby/regexp /[0-9]$/
|
|
95
|
+
- !ruby/regexp /[A-Z]/
|
|
54
96
|
SimulatedPolymorphism:
|
|
55
97
|
exclude: []
|
|
56
98
|
|
|
@@ -70,6 +112,3 @@ LongYieldList:
|
|
|
70
112
|
exclude: []
|
|
71
113
|
|
|
72
114
|
enabled: true
|
|
73
|
-
overrides:
|
|
74
|
-
initialize:
|
|
75
|
-
max_params: 5
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@masking
|
|
2
|
+
Feature: The Reek API maintains backwards compatibility
|
|
3
|
+
In order to use Reek witthout fuss
|
|
4
|
+
As a developer
|
|
5
|
+
I want to mave a stable API
|
|
6
|
+
|
|
7
|
+
Scenario: the demo example reports as expected
|
|
8
|
+
When I run reek spec/samples/demo
|
|
9
|
+
Then the exit status indicates smells
|
|
10
|
+
And it reports:
|
|
11
|
+
"""
|
|
12
|
+
spec/samples/demo/demo.rb -- 6 warnings:
|
|
13
|
+
Dirty has no descriptive comment (IrresponsibleModule)
|
|
14
|
+
Dirty#awful has 4 parameters (LongParameterList)
|
|
15
|
+
Dirty#awful has boolean parameter 'log' (ControlCouple)
|
|
16
|
+
Dirty#awful has the parameter name 'x' (UncommunicativeName)
|
|
17
|
+
Dirty#awful has the parameter name 'y' (UncommunicativeName)
|
|
18
|
+
Dirty#awful has the variable name 'w' (UncommunicativeName)
|
|
19
|
+
|
|
20
|
+
"""
|
|
@@ -10,61 +10,54 @@ Feature: Masking smells using config files
|
|
|
10
10
|
And it reports:
|
|
11
11
|
"""
|
|
12
12
|
spec/samples/empty_config_file/dirty.rb -- 6 warnings:
|
|
13
|
-
Dirty has the variable name '@s' (
|
|
13
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
14
14
|
Dirty#a calls @s.title twice (Duplication)
|
|
15
15
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
16
|
-
Dirty#a
|
|
17
|
-
Dirty#a
|
|
18
|
-
Dirty#a
|
|
16
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
17
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
18
|
+
Dirty#a has the variable name 'x' (UncommunicativeName)
|
|
19
19
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
Scenario: corrupt config file prevents normal output
|
|
23
|
-
When I run reek spec/samples/corrupt_config_file
|
|
24
|
-
Then the exit status indicates an error
|
|
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 the exit status indicates an error
|
|
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
|
|
23
|
+
When I run reek spec/samples/corrupt_config_file
|
|
34
24
|
Then the exit status indicates smells
|
|
35
25
|
And it reports:
|
|
36
26
|
"""
|
|
37
|
-
spec/samples/
|
|
27
|
+
spec/samples/corrupt_config_file/dirty.rb -- 7 warnings:
|
|
28
|
+
Dirty has no descriptive comment (IrresponsibleModule)
|
|
29
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
38
30
|
Dirty#a calls @s.title twice (Duplication)
|
|
39
31
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
40
|
-
Dirty#a
|
|
32
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
33
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
34
|
+
Dirty#a has the variable name 'x' (UncommunicativeName)
|
|
41
35
|
|
|
42
36
|
"""
|
|
37
|
+
And it reports the error 'Error: Invalid configuration file "corrupt.reek" -- "This is not a config file" is not a code smell'
|
|
43
38
|
|
|
44
|
-
Scenario:
|
|
45
|
-
When I run reek
|
|
39
|
+
Scenario: missing source file is an error
|
|
40
|
+
When I run reek no_such_file.rb spec/samples/masked/dirty.rb
|
|
46
41
|
Then the exit status indicates smells
|
|
47
42
|
And it reports:
|
|
48
43
|
"""
|
|
49
|
-
spec/samples/masked/dirty.rb -- 3 warnings
|
|
50
|
-
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
|
44
|
+
spec/samples/masked/dirty.rb -- 3 warnings:
|
|
51
45
|
Dirty#a calls @s.title twice (Duplication)
|
|
52
46
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
53
|
-
|
|
54
|
-
(masked) Dirty#a/block has the variable name 'x' (Uncommunicative Name)
|
|
55
|
-
Dirty#a/block/block is nested (Nested Iterators)
|
|
47
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
56
48
|
|
|
57
49
|
"""
|
|
50
|
+
And it reports the error "Error: No such file - no_such_file.rb"
|
|
58
51
|
|
|
59
|
-
Scenario: switch off one smell
|
|
60
|
-
When I run reek
|
|
52
|
+
Scenario: switch off one smell
|
|
53
|
+
When I run reek spec/samples/masked/dirty.rb
|
|
61
54
|
Then the exit status indicates smells
|
|
62
55
|
And it reports:
|
|
63
56
|
"""
|
|
64
|
-
spec/samples/masked/dirty.rb -- 3 warnings
|
|
57
|
+
spec/samples/masked/dirty.rb -- 3 warnings:
|
|
65
58
|
Dirty#a calls @s.title twice (Duplication)
|
|
66
59
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
67
|
-
Dirty#a
|
|
60
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
68
61
|
|
|
69
62
|
"""
|
|
70
63
|
|
|
@@ -73,12 +66,12 @@ Feature: Masking smells using config files
|
|
|
73
66
|
Then the exit status indicates smells
|
|
74
67
|
And it reports:
|
|
75
68
|
"""
|
|
76
|
-
spec/samples/not_quite_masked/dirty.rb -- 5 warnings
|
|
77
|
-
Dirty has the variable name '@s' (
|
|
69
|
+
spec/samples/not_quite_masked/dirty.rb -- 5 warnings:
|
|
70
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
78
71
|
Dirty#a calls @s.title twice (Duplication)
|
|
79
72
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
80
|
-
Dirty#a
|
|
81
|
-
Dirty#a
|
|
73
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
74
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
82
75
|
|
|
83
76
|
"""
|
|
84
77
|
|
|
@@ -88,24 +81,49 @@ Feature: Masking smells using config files
|
|
|
88
81
|
Then the exit status indicates smells
|
|
89
82
|
And it reports:
|
|
90
83
|
"""
|
|
91
|
-
spec/samples/overrides/masked/dirty.rb -- 2 warnings
|
|
84
|
+
spec/samples/overrides/masked/dirty.rb -- 2 warnings:
|
|
92
85
|
Dirty#a calls @s.title twice (Duplication)
|
|
93
86
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
94
87
|
|
|
95
88
|
"""
|
|
96
89
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
When I run reek --show-all spec/samples/overrides
|
|
90
|
+
Scenario: allow masking some calls for duplication smell
|
|
91
|
+
When I run reek spec/samples/mask_some/dirty.rb
|
|
100
92
|
Then the exit status indicates smells
|
|
101
93
|
And it reports:
|
|
102
94
|
"""
|
|
103
|
-
spec/samples/
|
|
104
|
-
(masked) Dirty has the variable name '@s' (Uncommunicative Name)
|
|
95
|
+
spec/samples/mask_some/dirty.rb -- 2 warnings:
|
|
105
96
|
Dirty#a calls @s.title twice (Duplication)
|
|
106
|
-
Dirty#a
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
97
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
@comments
|
|
102
|
+
Scenario: provide extra masking inline in comments
|
|
103
|
+
When I run reek spec/samples/inline_config
|
|
104
|
+
Then the exit status indicates smells
|
|
105
|
+
And it reports:
|
|
106
|
+
"""
|
|
107
|
+
spec/samples/inline_config/dirty.rb -- 1 warning:
|
|
108
|
+
Dirty#a calls @s.title twice (Duplication)
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
Scenario: supports a config file
|
|
113
|
+
When I run reek -c spec/samples/config/allow_duplication.reek spec/samples/masked/dirty.rb
|
|
114
|
+
Then the exit status indicates smells
|
|
115
|
+
And it reports:
|
|
116
|
+
"""
|
|
117
|
+
spec/samples/masked/dirty.rb -- 1 warning:
|
|
118
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
Scenario: supports multiple config files
|
|
123
|
+
When I run reek -c spec/samples/config/allow_duplication.reek -c spec/samples/config/deeper_nested_iterators.reek spec/samples/masked/dirty.rb
|
|
124
|
+
Then it succeeds
|
|
125
|
+
And it reports:
|
|
126
|
+
"""
|
|
127
|
+
spec/samples/masked/dirty.rb -- 0 warnings
|
|
110
128
|
|
|
111
129
|
"""
|
data/features/options.feature
CHANGED
|
@@ -8,6 +8,7 @@ Feature: Reek can be controlled using command-line options
|
|
|
8
8
|
When I run reek --no-such-option
|
|
9
9
|
Then the exit status indicates an error
|
|
10
10
|
And it reports the error "Error: invalid option: --no-such-option"
|
|
11
|
+
And stdout equals ""
|
|
11
12
|
|
|
12
13
|
Scenario: display the current version number
|
|
13
14
|
When I run reek --version
|
|
@@ -24,7 +25,7 @@ Feature: Reek can be controlled using command-line options
|
|
|
24
25
|
Examples:
|
|
25
26
|
|
|
26
27
|
reek lib/*.rb
|
|
27
|
-
reek -q
|
|
28
|
+
reek -q lib
|
|
28
29
|
cat my_class.rb | reek
|
|
29
30
|
|
|
30
31
|
See http://wiki.github.com/kevinrutherford/reek for detailed help.
|
|
@@ -34,8 +35,12 @@ Feature: Reek can be controlled using command-line options
|
|
|
34
35
|
-v, --version Show version
|
|
35
36
|
|
|
36
37
|
|
|
38
|
+
Configuration:
|
|
39
|
+
-c, --config FILE Read configuration options from FILE
|
|
40
|
+
|
|
41
|
+
|
|
37
42
|
Report formatting:
|
|
38
|
-
-a, --[no-]show-all Show all smells, including those masked by config settings
|
|
39
43
|
-q, --[no-]quiet Suppress headings for smell-free source files
|
|
44
|
+
-y, --yaml Report smells in YAML format
|
|
40
45
|
|
|
41
46
|
"""
|
data/features/rake_task.feature
CHANGED
|
@@ -1,62 +1,55 @@
|
|
|
1
1
|
@rake
|
|
2
|
-
Feature: Reek can be driven through its
|
|
2
|
+
Feature: Reek can be driven through its Task
|
|
3
3
|
Reek provides an easy way to integrate its use into Rakefiles,
|
|
4
|
-
via the
|
|
4
|
+
via the Task class. These scenarios test its various options.
|
|
5
5
|
|
|
6
6
|
Scenario: source_files points at the desired files
|
|
7
7
|
When I run rake reek with:
|
|
8
8
|
"""
|
|
9
|
-
Reek::
|
|
9
|
+
Reek::Rake::Task.new do |t|
|
|
10
10
|
t.source_files = 'spec/samples/masked/dirty.rb'
|
|
11
11
|
end
|
|
12
12
|
"""
|
|
13
13
|
Then the exit status indicates an error
|
|
14
14
|
And it reports:
|
|
15
15
|
"""
|
|
16
|
-
spec/samples/masked/dirty.rb -- 3 warnings
|
|
16
|
+
spec/samples/masked/dirty.rb -- 3 warnings:
|
|
17
17
|
Dirty#a calls @s.title twice (Duplication)
|
|
18
18
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
19
|
-
Dirty#a
|
|
19
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
Scenario: name changes the task name
|
|
23
23
|
When I run rake silky with:
|
|
24
24
|
"""
|
|
25
|
-
Reek::
|
|
25
|
+
Reek::Rake::Task.new('silky') do |t|
|
|
26
26
|
t.source_files = 'spec/samples/masked/dirty.rb'
|
|
27
27
|
end
|
|
28
28
|
"""
|
|
29
29
|
Then the exit status indicates an error
|
|
30
30
|
And it reports:
|
|
31
31
|
"""
|
|
32
|
-
spec/samples/masked/dirty.rb -- 3 warnings
|
|
32
|
+
spec/samples/masked/dirty.rb -- 3 warnings:
|
|
33
33
|
Dirty#a calls @s.title twice (Duplication)
|
|
34
34
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
35
|
-
Dirty#a
|
|
35
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
Scenario: verbose prints the reek command
|
|
39
39
|
When I run rake reek with:
|
|
40
40
|
"""
|
|
41
|
-
Reek::
|
|
41
|
+
Reek::Rake::Task.new do |t|
|
|
42
42
|
t.source_files = 'spec/samples/masked/dirty.rb'
|
|
43
43
|
t.verbose = true
|
|
44
44
|
end
|
|
45
45
|
"""
|
|
46
46
|
Then the exit status indicates an error
|
|
47
|
-
And
|
|
48
|
-
"""
|
|
49
|
-
/usr/bin/ruby1.8 -I"/home/kevin/Working/git/reek/lib" "/home/kevin/Working/git/reek/bin/reek" "spec/samples/masked/dirty.rb"
|
|
50
|
-
spec/samples/masked/dirty.rb -- 3 warnings (+3 masked):
|
|
51
|
-
Dirty#a calls @s.title twice (Duplication)
|
|
52
|
-
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
53
|
-
Dirty#a/block/block is nested (Nested Iterators)
|
|
54
|
-
"""
|
|
47
|
+
And stdout includes /spec\/samples\/masked\/dirty\.rb/
|
|
55
48
|
|
|
56
49
|
Scenario: fail_on_error can hide the error status
|
|
57
50
|
When I run rake reek with:
|
|
58
51
|
"""
|
|
59
|
-
Reek::
|
|
52
|
+
Reek::Rake::Task.new do |t|
|
|
60
53
|
t.fail_on_error = false
|
|
61
54
|
t.source_files = 'spec/samples/empty_config_file/dirty.rb'
|
|
62
55
|
end
|
|
@@ -65,10 +58,24 @@ Feature: Reek can be driven through its RakeTask
|
|
|
65
58
|
And it reports:
|
|
66
59
|
"""
|
|
67
60
|
spec/samples/empty_config_file/dirty.rb -- 6 warnings:
|
|
68
|
-
Dirty has the variable name '@s' (
|
|
61
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
69
62
|
Dirty#a calls @s.title twice (Duplication)
|
|
70
63
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
71
|
-
Dirty#a
|
|
72
|
-
Dirty#a
|
|
73
|
-
Dirty#a
|
|
64
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
65
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
66
|
+
Dirty#a has the variable name 'x' (UncommunicativeName)
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
Scenario: can be configured with config_files
|
|
70
|
+
When I run rake reek with:
|
|
71
|
+
"""
|
|
72
|
+
Reek::Rake::Task.new do |t|
|
|
73
|
+
t.config_files = 'spec/samples/config/**/*.reek'
|
|
74
|
+
t.source_files = 'spec/samples/masked/dirty.rb'
|
|
75
|
+
end
|
|
76
|
+
"""
|
|
77
|
+
Then it succeeds
|
|
78
|
+
And it reports:
|
|
79
|
+
"""
|
|
80
|
+
spec/samples/masked/dirty.rb -- 0 warnings
|
|
74
81
|
"""
|
data/features/reports.feature
CHANGED
|
@@ -10,19 +10,19 @@ Feature: Correctly formatted reports
|
|
|
10
10
|
And it reports:
|
|
11
11
|
"""
|
|
12
12
|
spec/samples/two_smelly_files/dirty_one.rb -- 6 warnings:
|
|
13
|
-
Dirty has the variable name '@s' (
|
|
13
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
14
14
|
Dirty#a calls @s.title twice (Duplication)
|
|
15
15
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
16
|
-
Dirty#a
|
|
17
|
-
Dirty#a
|
|
18
|
-
Dirty#a
|
|
16
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
17
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
18
|
+
Dirty#a has the variable name 'x' (UncommunicativeName)
|
|
19
19
|
spec/samples/two_smelly_files/dirty_two.rb -- 6 warnings:
|
|
20
|
-
Dirty has the variable name '@s' (
|
|
20
|
+
Dirty has the variable name '@s' (UncommunicativeName)
|
|
21
21
|
Dirty#a calls @s.title twice (Duplication)
|
|
22
22
|
Dirty#a calls puts(@s.title) twice (Duplication)
|
|
23
|
-
Dirty#a
|
|
24
|
-
Dirty#a
|
|
25
|
-
Dirty#a
|
|
23
|
+
Dirty#a contains iterators nested 2 deep (NestedIterators)
|
|
24
|
+
Dirty#a has the name 'a' (UncommunicativeName)
|
|
25
|
+
Dirty#a has the variable name 'x' (UncommunicativeName)
|
|
26
26
|
|
|
27
27
|
"""
|
|
28
28
|
|
|
@@ -50,41 +50,9 @@ Feature: Correctly formatted reports
|
|
|
50
50
|
Scenario Outline: --quiet turns off headers for fragrant files
|
|
51
51
|
When I run reek <option> spec/samples/three_clean_files/*.rb
|
|
52
52
|
Then it succeeds
|
|
53
|
-
And
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"""
|
|
53
|
+
And stdout equals ""
|
|
58
54
|
|
|
59
55
|
Examples:
|
|
60
56
|
| option |
|
|
61
57
|
| -q |
|
|
62
58
|
| --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 |
|