reek 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/README.md +70 -92
- data/config/defaults.reek +3 -0
- data/features/samples.feature +24 -20
- data/features/step_definitions/reek_steps.rb +1 -1
- data/features/support/env.rb +7 -7
- data/lib/reek/core/code_context.rb +1 -1
- data/lib/reek/core/code_parser.rb +19 -18
- data/lib/reek/core/method_context.rb +8 -7
- data/lib/reek/core/module_context.rb +1 -1
- data/lib/reek/core/smell_repository.rb +1 -0
- data/lib/reek/core/sniffer.rb +3 -1
- data/lib/reek/rake/task.rb +1 -5
- data/lib/reek/smell_description.rb +26 -0
- data/lib/reek/smell_warning.rb +35 -49
- data/lib/reek/smells.rb +1 -0
- data/lib/reek/smells/attribute.rb +1 -1
- data/lib/reek/smells/control_parameter.rb +14 -7
- data/lib/reek/smells/data_clump.rb +1 -1
- data/lib/reek/smells/duplicate_method_call.rb +2 -9
- data/lib/reek/smells/module_initialize.rb +38 -0
- data/lib/reek/smells/nested_iterators.rb +1 -1
- data/lib/reek/smells/nil_check.rb +3 -3
- data/lib/reek/smells/repeated_conditional.rb +3 -2
- data/lib/reek/smells/smell_detector.rb +1 -1
- data/lib/reek/smells/too_many_instance_variables.rb +1 -1
- data/lib/reek/smells/too_many_methods.rb +1 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +0 -4
- data/lib/reek/smells/uncommunicative_parameter_name.rb +0 -4
- data/lib/reek/smells/uncommunicative_variable_name.rb +11 -9
- data/lib/reek/smells/utility_function.rb +2 -2
- data/lib/reek/source/ast_node.rb +40 -0
- data/lib/reek/source/ast_node_class_map.rb +37 -0
- data/lib/reek/source/reference_collector.rb +3 -3
- data/lib/reek/source/sexp_extensions.rb +133 -59
- data/lib/reek/source/sexp_formatter.rb +10 -4
- data/lib/reek/source/sexp_node.rb +25 -17
- data/lib/reek/source/source_code.rb +21 -9
- data/lib/reek/source/tree_dresser.rb +10 -33
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +2 -4
- data/spec/matchers/smell_of_matcher.rb +9 -1
- data/spec/quality/reek_source_spec.rb +0 -35
- data/spec/reek/core/code_context_spec.rb +22 -8
- data/spec/reek/core/method_context_spec.rb +10 -10
- data/spec/reek/smell_description_spec.rb +43 -0
- data/spec/reek/smell_warning_spec.rb +0 -3
- data/spec/reek/smells/control_parameter_spec.rb +24 -0
- data/spec/reek/smells/feature_envy_spec.rb +50 -17
- data/spec/reek/smells/irresponsible_module_spec.rb +25 -17
- data/spec/reek/smells/module_initialize_spec.rb +20 -0
- data/spec/reek/smells/prima_donna_method_spec.rb +2 -2
- data/spec/reek/smells/repeated_conditional_spec.rb +10 -4
- data/spec/reek/smells/too_many_instance_variables_spec.rb +47 -21
- data/spec/reek/smells/too_many_statements_spec.rb +11 -1
- data/spec/reek/smells/uncommunicative_variable_name_spec.rb +1 -1
- data/spec/reek/smells/utility_function_spec.rb +26 -25
- data/spec/reek/source/sexp_extensions_spec.rb +164 -91
- data/spec/reek/source/sexp_formatter_spec.rb +13 -1
- data/spec/reek/source/sexp_node_spec.rb +5 -5
- data/spec/reek/source/source_code_spec.rb +18 -6
- data/spec/reek/source/tree_dresser_spec.rb +5 -5
- data/spec/spec_helper.rb +8 -4
- metadata +16 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd3b362caed94f8eec563376a0542677d215b9c
|
4
|
+
data.tar.gz: 85af0be0c7132c4718b145b114d2013a836a8880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e933370d907c7d45079a56e513c88363b3b6faeb8244651e6ac4a6f3e08242087e705490c8a5d86eee80fb585f5f74a3af7f5d2d49e42e672081b0e9d861f32c
|
7
|
+
data.tar.gz: c0bcc02e84cd9475db5f2c59c1d74c9fc42e983ff79e373f951092224df4df8784fd00b2ce8d43a306d4ebe42e742dba2507e42893aa88a4798a47dc7874d726
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Reek -- code smell detection for Ruby
|
2
2
|
|
3
|
-
|
4
|
-
### Overview
|
3
|
+
## Overview
|
5
4
|
|
6
5
|
|
7
6
|
[![Build Status](https://secure.travis-ci.org/troessner/reek.png?branch=master)](http://travis-ci.org/troessner/reek?branch=master)
|
@@ -9,59 +8,25 @@
|
|
9
8
|
[![Dependency Status](https://gemnasium.com/troessner/reek.png)](https://gemnasium.com/troessner/reek)
|
10
9
|
[![Inline docs](http://inch-ci.org/github/troessner/reek.png)](http://inch-ci.org/github/troessner/reek)
|
11
10
|
|
11
|
+
## Quickstart
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
`reek` is a tool that examines Ruby classes, modules and methods and reports any [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) it finds. Install it like this:
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
```bash
|
20
|
-
$ gem install reek
|
15
|
+
```Bash
|
16
|
+
gem install reek
|
21
17
|
```
|
22
18
|
|
23
19
|
and run it like this:
|
24
20
|
|
25
|
-
```
|
26
|
-
|
21
|
+
```Bash
|
22
|
+
reek [options] [dir_or_source_file]*
|
27
23
|
```
|
28
24
|
|
29
|
-
|
30
|
-
[Reek wiki](https://github.com/troessner/reek/wiki/command-line-options)
|
31
|
-
or run
|
32
|
-
|
33
|
-
```bash
|
34
|
-
$ reek --help
|
35
|
-
```
|
36
|
-
|
37
|
-
## Usage
|
38
|
-
|
39
|
-
For scanning the current directory you're in do a
|
40
|
-
|
41
|
-
```bash
|
42
|
-
$ reek .
|
43
|
-
```
|
25
|
+
## Example
|
44
26
|
|
45
|
-
|
27
|
+
Imagine a source file <tt>demo.rb</tt> containing:
|
46
28
|
|
47
|
-
|
48
|
-
Likewise you can scan specific directories like this
|
49
|
-
|
50
|
-
```bash
|
51
|
-
$ reek lib/your/files
|
52
|
-
```
|
53
|
-
|
54
|
-
Note that if you just call
|
55
|
-
|
56
|
-
```bash
|
57
|
-
$ reek
|
58
|
-
```
|
59
|
-
|
60
|
-
without any arguments reek will wait for input from STDIN.
|
61
|
-
|
62
|
-
Given a source file <tt>demo.rb</tt> containing:
|
63
|
-
|
64
|
-
```ruby
|
29
|
+
```Ruby
|
65
30
|
class Dirty
|
66
31
|
# This method smells of :reek:NestedIterators but ignores them
|
67
32
|
def awful(x, y, offset = 0, log = false)
|
@@ -74,7 +39,7 @@ end
|
|
74
39
|
|
75
40
|
Reek will report the following code smells in this file:
|
76
41
|
|
77
|
-
```
|
42
|
+
```
|
78
43
|
$ reek demo.rb
|
79
44
|
spec/samples/demo/demo.rb -- 6 warnings:
|
80
45
|
Dirty has no descriptive comment (IrresponsibleModule)
|
@@ -83,48 +48,55 @@ spec/samples/demo/demo.rb -- 6 warnings:
|
|
83
48
|
Dirty#awful has the parameter name 'x' (UncommunicativeName)
|
84
49
|
Dirty#awful has the parameter name 'y' (UncommunicativeName)
|
85
50
|
Dirty#awful has the variable name 'w' (UncommunicativeName)
|
51
|
+
Dirty#awful has unused parameter 'log' (UnusedParameters)
|
52
|
+
Dirty#awful has unused parameter 'offset' (UnusedParameters)
|
53
|
+
Dirty#awful has unused parameter 'x' (UnusedParameters)
|
54
|
+
Dirty#awful has unused parameter 'y' (UnusedParameters)
|
86
55
|
```
|
87
56
|
|
88
|
-
##
|
57
|
+
## Code smells
|
89
58
|
|
90
|
-
|
91
|
-
Data Clump, Feature Envy, Large Class, Long Method, Long Parameter List,
|
92
|
-
Simulated Polymorphism, Uncommunicative Name and more.
|
93
|
-
See the [Reek wiki](https://github.com/troessner/reek/wiki/code-smells)
|
94
|
-
for up to date details of exactly what Reek will check in your code.
|
59
|
+
`reek` currently includes checks for some aspects of [Control Couple](https://github.com/troessner/reek/wiki/Control-Couple), [Data Clump](https://github.com/troessner/reek/wiki/Data-Clump), [Feature Envy](https://github.com/troessner/reek/wiki/Feature-Envy), [Large Class](https://github.com/troessner/reek/wiki/Large-Class), [Long Parameter List](https://github.com/troessner/reek/wiki/Long-Parameter-List), [Simulated Polymorphism](https://github.com/troessner/reek/wiki/Simulated-Polymorphism), [Too Many Statements](https://github.com/troessner/reek/wiki/Too-Many-Statements), [Uncommunicative Name](https://github.com/troessner/reek/wiki/Uncommunicative-Name), [Unused Parameters](https://github.com/troessner/reek/wiki/Unused-Parameters) and more. See the [Code Smells](https://github.com/troessner/reek/wiki/Code-Smells) for up to date details of exactly what `reek` will check in your code.
|
95
60
|
|
96
|
-
|
61
|
+
## Configuration
|
97
62
|
|
98
|
-
|
99
|
-
static code analysis:
|
63
|
+
For a basic overview, run
|
100
64
|
|
101
|
-
|
102
|
-
|
65
|
+
```Ruby
|
66
|
+
reek --help
|
67
|
+
```
|
103
68
|
|
104
|
-
|
69
|
+
For a summary of those CLI options see [Command-Line Options](https://github.com/troessner/reek/wiki/Command-Line-Options).
|
105
70
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
71
|
+
Apart from that, `reek` offers quite a few ways for configuring it:
|
72
|
+
|
73
|
+
* The first thing you probably want to check out are the [Basic Smell Options](https://github.com/troessner/reek/wiki/Basic-Smell-Options)
|
74
|
+
* `reek` is not the police. In case you need to suppress a smell warning for whatever reasons have a look at [Smell Suppression](https://github.com/troessner/reek/wiki/Smell-Suppression)
|
75
|
+
* Lastly there are a couple of ways to configure `reek` via [Configuration Files](https://github.com/troessner/reek/wiki/Configuration-Files)
|
76
|
+
|
77
|
+
## Integration
|
111
78
|
|
112
|
-
|
79
|
+
Besides the obvious
|
113
80
|
|
114
|
-
|
115
|
-
|
81
|
+
```Bash
|
82
|
+
reek [options] [dir_or_source_file]*
|
116
83
|
```
|
117
84
|
|
118
|
-
|
85
|
+
there are quite a few other ways how to use reek in your projects:
|
119
86
|
|
120
|
-
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
* Submit a pull request
|
87
|
+
* Use `reek`'s [Rake Task](https://github.com/troessner/reek/wiki/Rake-Task) to automate detecting code smells
|
88
|
+
* Add `reek`'s custom matcher to your [RSpec examples](https://github.com/troessner/reek/wiki/RSpec-Integration)
|
89
|
+
* Include `reek` using the [Developer API](https://github.com/troessner/reek/wiki/Developer-Api)
|
124
90
|
|
125
|
-
|
91
|
+
## Developing reek / Contributing
|
126
92
|
|
127
|
-
|
93
|
+
The first thing you want to do after checking out the source code is to run bundler
|
94
|
+
|
95
|
+
```
|
96
|
+
bundle install
|
97
|
+
```
|
98
|
+
|
99
|
+
and then to run the tests:
|
128
100
|
|
129
101
|
```bash
|
130
102
|
bundle exec rspec spec/your/file_spec.rb # Runs all tests in spec/your/file_spec.rb
|
@@ -133,7 +105,28 @@ bundle exec cucumber features/your_file.feature # Runs all scenarios in your
|
|
133
105
|
bundle exec cucumber features/your_file.feature:23 # Runs scenario at line 23
|
134
106
|
```
|
135
107
|
|
136
|
-
|
108
|
+
Or just run the whole test suite by running
|
109
|
+
|
110
|
+
```
|
111
|
+
bundle exec rake
|
112
|
+
```
|
113
|
+
|
114
|
+
From then on continue by following the establish [pull request workflow](https://help.github.com/articles/using-pull-requests/).
|
115
|
+
|
116
|
+
If you don't feel like getting your hands dirty with code there a still other ways you can help us:
|
117
|
+
|
118
|
+
* Work on the [wiki](https://github.com/troessner/reek/wiki)
|
119
|
+
* Open up an [issue](https://github.com/troessner/reek/issues) and report bugs or suggest other improvements
|
120
|
+
|
121
|
+
## Output formats
|
122
|
+
|
123
|
+
`reek` supports 3 output formats:
|
124
|
+
|
125
|
+
* plain text (default)
|
126
|
+
* html (-H, --html)
|
127
|
+
* yaml (-y, --yaml)
|
128
|
+
|
129
|
+
## Additional resources
|
137
130
|
|
138
131
|
### Tools
|
139
132
|
|
@@ -146,22 +139,7 @@ TextMate Bundle for `reek`:
|
|
146
139
|
Colorful output for `reek`: [Preek](https://github.com/joenas/preek) (also with
|
147
140
|
[Guard::Preek](https://github.com/joenas/guard-preek))
|
148
141
|
|
149
|
-
###
|
150
|
-
|
151
|
-
Reek makes use of the following other gems:
|
152
|
-
|
153
|
-
* ruby_parser
|
154
|
-
* sexp_processor
|
155
|
-
* ruby2ruby
|
156
|
-
* rainbow
|
157
|
-
|
158
|
-
### Learn More
|
159
|
-
|
160
|
-
Find out more about Reek from any of the following sources:
|
142
|
+
### Find out more:
|
161
143
|
|
162
|
-
*
|
163
|
-
|
164
|
-
* Browse the code or install the latest development version from
|
165
|
-
[https://github.com/troessner/reek/tree](https://github.com/troessner/reek/tree)
|
166
|
-
* Read the code API at
|
167
|
-
[http://rdoc.info/projects/troessner/reek](http://rdoc.info/projects/troessner/reek)
|
144
|
+
* [Stack Overflow](http://stackoverflow.com/questions/tagged/reek)
|
145
|
+
* [RDoc](http://rdoc.info/projects/troessner/reek)
|
data/config/defaults.reek
CHANGED
data/features/samples.feature
CHANGED
@@ -10,7 +10,8 @@ Feature: Basic smell detection
|
|
10
10
|
Then the exit status indicates smells
|
11
11
|
And it reports:
|
12
12
|
"""
|
13
|
-
spec/samples/inline.rb --
|
13
|
+
spec/samples/inline.rb -- 43 warnings:
|
14
|
+
CompilationError has no descriptive comment (IrresponsibleModule)
|
14
15
|
File has no descriptive comment (IrresponsibleModule)
|
15
16
|
File#self.write_with_backup has approx 6 statements (TooManyStatements)
|
16
17
|
Inline declares the class variable @@directory (ClassVariable)
|
@@ -24,7 +25,7 @@ Feature: Basic smell detection
|
|
24
25
|
Inline::C tests $DEBUG at least 7 times (RepeatedConditional)
|
25
26
|
Inline::C tests $TESTING at least 4 times (RepeatedConditional)
|
26
27
|
Inline::C tests @@type_map.has_key?(type) at least 3 times (RepeatedConditional)
|
27
|
-
Inline::C#build calls
|
28
|
+
Inline::C#build calls $? != 0 twice (DuplicateMethodCall)
|
28
29
|
Inline::C#build calls Inline.directory 5 times (DuplicateMethodCall)
|
29
30
|
Inline::C#build calls io.puts 6 times (DuplicateMethodCall)
|
30
31
|
Inline::C#build calls io.puts("#endif") twice (DuplicateMethodCall)
|
@@ -51,6 +52,7 @@ Feature: Basic smell detection
|
|
51
52
|
Inline::C#strip_comments doesn't depend on instance state (UtilityFunction)
|
52
53
|
Inline::C#strip_comments refers to src more than self (FeatureEnvy)
|
53
54
|
Module#inline calls Inline.const_get(lang) twice (DuplicateMethodCall)
|
55
|
+
Module#inline calls options[:testing] twice (DuplicateMethodCall)
|
54
56
|
Module#inline has approx 12 statements (TooManyStatements)
|
55
57
|
"""
|
56
58
|
|
@@ -59,14 +61,14 @@ Feature: Basic smell detection
|
|
59
61
|
Then the exit status indicates smells
|
60
62
|
And it reports:
|
61
63
|
"""
|
62
|
-
spec/samples/optparse.rb --
|
64
|
+
spec/samples/optparse.rb -- 111 warnings:
|
63
65
|
OptionParser has at least 42 methods (TooManyMethods)
|
64
66
|
OptionParser has the variable name 'f' (UncommunicativeVariableName)
|
65
67
|
OptionParser has the variable name 'k' (UncommunicativeVariableName)
|
66
68
|
OptionParser has the variable name 'o' (UncommunicativeVariableName)
|
67
69
|
OptionParser has the variable name 's' (UncommunicativeVariableName)
|
68
70
|
OptionParser has the variable name 'v' (UncommunicativeVariableName)
|
69
|
-
OptionParser tests (argv.size == 1)
|
71
|
+
OptionParser tests (argv.size == 1) && (Array === argv[0]) at least 3 times (RepeatedConditional)
|
70
72
|
OptionParser tests a at least 7 times (RepeatedConditional)
|
71
73
|
OptionParser tests default_pattern at least 7 times (RepeatedConditional)
|
72
74
|
OptionParser tests not_style at least 3 times (RepeatedConditional)
|
@@ -79,15 +81,15 @@ Feature: Basic smell detection
|
|
79
81
|
OptionParser#getopts has approx 18 statements (TooManyStatements)
|
80
82
|
OptionParser#load has approx 6 statements (TooManyStatements)
|
81
83
|
OptionParser#load has the variable name 's' (UncommunicativeVariableName)
|
82
|
-
OptionParser#make_switch calls (
|
83
|
-
OptionParser#make_switch calls
|
84
|
-
OptionParser#make_switch calls default_style.guess((arg = a)) 4 times (DuplicateMethodCall)
|
85
|
-
OptionParser#make_switch calls notwice((a ? (Object) : (TrueClass)), klass, "type") twice (DuplicateMethodCall)
|
84
|
+
OptionParser#make_switch calls default_style.guess(arg = a) 4 times (DuplicateMethodCall)
|
85
|
+
OptionParser#make_switch calls long << (o = q.downcase) twice (DuplicateMethodCall)
|
86
86
|
OptionParser#make_switch calls notwice(NilClass, klass, "type") twice (DuplicateMethodCall)
|
87
|
+
OptionParser#make_switch calls notwice(if a ... end, klass, "type") twice (DuplicateMethodCall)
|
87
88
|
OptionParser#make_switch calls pattern.method(:convert) twice (DuplicateMethodCall)
|
88
89
|
OptionParser#make_switch calls pattern.method(:convert).to_proc twice (DuplicateMethodCall)
|
89
90
|
OptionParser#make_switch calls pattern.respond_to?(:convert) twice (DuplicateMethodCall)
|
90
91
|
OptionParser#make_switch calls q.downcase 3 times (DuplicateMethodCall)
|
92
|
+
OptionParser#make_switch calls sdesc << "-#{q}" twice (DuplicateMethodCall)
|
91
93
|
OptionParser#make_switch calls search(:atype, FalseClass) twice (DuplicateMethodCall)
|
92
94
|
OptionParser#make_switch calls search(:atype, o) 6 times (DuplicateMethodCall)
|
93
95
|
OptionParser#make_switch contains iterators nested 3 deep (NestedIterators)
|
@@ -120,7 +122,9 @@ Feature: Basic smell detection
|
|
120
122
|
OptionParser#self.inc performs a nil-check. (NilCheck)
|
121
123
|
OptionParser#summarize has 4 parameters (LongParameterList)
|
122
124
|
OptionParser#summarize has the variable name 'l' (UncommunicativeVariableName)
|
125
|
+
OptionParser#summarize is controlled by argument blk (ControlParameter)
|
123
126
|
OptionParser#ver has the variable name 'v' (UncommunicativeVariableName)
|
127
|
+
OptionParser::Arguable has initialize method (ModuleInitialize)
|
124
128
|
OptionParser::Arguable#options has approx 6 statements (TooManyStatements)
|
125
129
|
OptionParser::Arguable#options= is controlled by argument opt (ControlParameter)
|
126
130
|
OptionParser::CompletingHash#match contains iterators nested 2 deep (NestedIterators)
|
@@ -152,13 +156,13 @@ Feature: Basic smell detection
|
|
152
156
|
OptionParser::Switch#self.guess has approx 6 statements (TooManyStatements)
|
153
157
|
OptionParser::Switch#self.guess has the variable name 't' (UncommunicativeVariableName)
|
154
158
|
OptionParser::Switch#self.incompatible_argument_styles has the parameter name 't' (UncommunicativeParameterName)
|
155
|
-
OptionParser::Switch#summarize calls
|
159
|
+
OptionParser::Switch#summarize calls indent + l twice (DuplicateMethodCall)
|
160
|
+
OptionParser::Switch#summarize calls left.collect do |s| ... end twice (DuplicateMethodCall)
|
161
|
+
OptionParser::Switch#summarize calls left.collect do |s| ... end.max twice (DuplicateMethodCall)
|
162
|
+
OptionParser::Switch#summarize calls left.collect do |s| ... end.max.to_i twice (DuplicateMethodCall)
|
156
163
|
OptionParser::Switch#summarize calls left.collect twice (DuplicateMethodCall)
|
157
|
-
OptionParser::Switch#summarize calls left.collect { |s| s.length } twice (DuplicateMethodCall)
|
158
|
-
OptionParser::Switch#summarize calls left.collect { |s| s.length }.max twice (DuplicateMethodCall)
|
159
|
-
OptionParser::Switch#summarize calls left.collect { |s| s.length }.max.to_i twice (DuplicateMethodCall)
|
160
164
|
OptionParser::Switch#summarize calls left.shift twice (DuplicateMethodCall)
|
161
|
-
OptionParser::Switch#summarize calls left[-1] 3 times (DuplicateMethodCall)
|
165
|
+
OptionParser::Switch#summarize calls left[(-1)] 3 times (DuplicateMethodCall)
|
162
166
|
OptionParser::Switch#summarize calls s.length 3 times (DuplicateMethodCall)
|
163
167
|
OptionParser::Switch#summarize contains iterators nested 2 deep (NestedIterators)
|
164
168
|
OptionParser::Switch#summarize has 5 parameters (LongParameterList)
|
@@ -190,11 +194,11 @@ Feature: Basic smell detection
|
|
190
194
|
RedCloth#block_markdown_lists has unused parameter 'text' (UnusedParameters)
|
191
195
|
RedCloth#block_markdown_rule refers to text more than self (FeatureEnvy)
|
192
196
|
RedCloth#block_markdown_setext refers to text more than self (FeatureEnvy)
|
193
|
-
RedCloth#block_textile_lists calls (line_id - 1) twice (DuplicateMethodCall)
|
194
197
|
RedCloth#block_textile_lists calls depth.last 5 times (DuplicateMethodCall)
|
195
198
|
RedCloth#block_textile_lists calls depth.last.length twice (DuplicateMethodCall)
|
196
199
|
RedCloth#block_textile_lists calls depth[i] twice (DuplicateMethodCall)
|
197
|
-
RedCloth#block_textile_lists calls
|
200
|
+
RedCloth#block_textile_lists calls line_id - 1 twice (DuplicateMethodCall)
|
201
|
+
RedCloth#block_textile_lists calls lines[line_id - 1] twice (DuplicateMethodCall)
|
198
202
|
RedCloth#block_textile_lists calls tl.length 3 times (DuplicateMethodCall)
|
199
203
|
RedCloth#block_textile_lists contains iterators nested 3 deep (NestedIterators)
|
200
204
|
RedCloth#block_textile_lists has approx 21 statements (TooManyStatements)
|
@@ -208,6 +212,7 @@ Feature: Basic smell detection
|
|
208
212
|
RedCloth#blocks has approx 19 statements (TooManyStatements)
|
209
213
|
RedCloth#blocks has boolean parameter 'deep_code' (BooleanParameter)
|
210
214
|
RedCloth#blocks is controlled by argument deep_code (ControlParameter)
|
215
|
+
RedCloth#blocks refers to blk more than self (FeatureEnvy)
|
211
216
|
RedCloth#clean_html calls tags[tag] twice (DuplicateMethodCall)
|
212
217
|
RedCloth#clean_html contains iterators nested 3 deep (NestedIterators)
|
213
218
|
RedCloth#clean_html doesn't depend on instance state (UtilityFunction)
|
@@ -219,7 +224,6 @@ Feature: Basic smell detection
|
|
219
224
|
RedCloth#clean_white_space has approx 7 statements (TooManyStatements)
|
220
225
|
RedCloth#clean_white_space refers to text more than self (FeatureEnvy)
|
221
226
|
RedCloth#flush_left doesn't depend on instance state (UtilityFunction)
|
222
|
-
RedCloth#flush_left refers to indt more than self (FeatureEnvy)
|
223
227
|
RedCloth#flush_left refers to text more than self (FeatureEnvy)
|
224
228
|
RedCloth#footnote_ref refers to text more than self (FeatureEnvy)
|
225
229
|
RedCloth#glyphs_textile has approx 10 statements (TooManyStatements)
|
@@ -245,21 +249,21 @@ Feature: Basic smell detection
|
|
245
249
|
RedCloth#inline_textile_span has the variable name 'm' (UncommunicativeVariableName)
|
246
250
|
RedCloth#lT has the name 'lT' (UncommunicativeMethodName)
|
247
251
|
RedCloth#lT is controlled by argument text (ControlParameter)
|
252
|
+
RedCloth#lT refers to text more than self (FeatureEnvy)
|
248
253
|
RedCloth#no_textile doesn't depend on instance state (UtilityFunction)
|
249
254
|
RedCloth#no_textile refers to text more than self (FeatureEnvy)
|
250
255
|
RedCloth#pba calls $1.length twice (DuplicateMethodCall)
|
251
256
|
RedCloth#pba has approx 21 statements (TooManyStatements)
|
252
257
|
RedCloth#pba is controlled by argument element (ControlParameter)
|
253
|
-
RedCloth#pba refers to style more than self (FeatureEnvy)
|
254
258
|
RedCloth#pba refers to text more than self (FeatureEnvy)
|
255
259
|
RedCloth#refs_markdown has the variable name 'm' (UncommunicativeVariableName)
|
256
260
|
RedCloth#refs_textile has the variable name 'm' (UncommunicativeVariableName)
|
257
261
|
RedCloth#retrieve has the variable name 'i' (UncommunicativeVariableName)
|
258
262
|
RedCloth#retrieve has the variable name 'r' (UncommunicativeVariableName)
|
259
|
-
RedCloth#rip_offtags calls (
|
260
|
-
RedCloth#rip_offtags calls
|
261
|
-
RedCloth#rip_offtags calls (codepre - used_offtags.length) twice (DuplicateMethodCall)
|
263
|
+
RedCloth#rip_offtags calls (codepre - used_offtags.length) > 0 twice (DuplicateMethodCall)
|
264
|
+
RedCloth#rip_offtags calls @pre_list.last << line twice (DuplicateMethodCall)
|
262
265
|
RedCloth#rip_offtags calls @pre_list.last twice (DuplicateMethodCall)
|
266
|
+
RedCloth#rip_offtags calls codepre - used_offtags.length twice (DuplicateMethodCall)
|
263
267
|
RedCloth#rip_offtags calls codepre.zero? twice (DuplicateMethodCall)
|
264
268
|
RedCloth#rip_offtags calls htmlesc(line, :NoQuotes) twice (DuplicateMethodCall)
|
265
269
|
RedCloth#rip_offtags calls used_offtags.length twice (DuplicateMethodCall)
|
@@ -57,7 +57,7 @@ Then /^it reports the error ['"](.*)['"]$/ do |string|
|
|
57
57
|
end
|
58
58
|
|
59
59
|
Then /^it reports a parsing error$/ do
|
60
|
-
expect(@last_stderr.chomp).to match(/
|
60
|
+
expect(@last_stderr.chomp).to match(/Parser::SyntaxError/)
|
61
61
|
end
|
62
62
|
|
63
63
|
Then /^it should indicate the line numbers of those smells$/ do
|
data/features/support/env.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'tempfile'
|
3
2
|
require 'fileutils'
|
4
3
|
require 'open3'
|
@@ -6,18 +5,19 @@ require 'reek/cli/application'
|
|
6
5
|
|
7
6
|
class ReekWorld
|
8
7
|
def run(cmd)
|
9
|
-
|
10
|
-
|
11
|
-
@
|
12
|
-
@last_exit_status =
|
8
|
+
stderr_file = Tempfile.new('reek-world')
|
9
|
+
stderr_file.close
|
10
|
+
@last_stdout = `#{cmd} 2> #{stderr_file.path}`
|
11
|
+
@last_exit_status = $?.exitstatus
|
12
|
+
@last_stderr = IO.read(stderr_file.path)
|
13
13
|
end
|
14
14
|
|
15
15
|
def reek(args)
|
16
|
-
run("ruby -Ilib
|
16
|
+
run("ruby -Ilib bin/reek --no-color #{args}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def reek_with_pipe(stdin, args)
|
20
|
-
run("echo \"#{stdin}\" | ruby -Ilib
|
20
|
+
run("echo \"#{stdin}\" | ruby -Ilib bin/reek --no-color #{args}")
|
21
21
|
end
|
22
22
|
|
23
23
|
def rake(name, task_def)
|