reek 5.1.0 → 5.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +8 -0
- data/Gemfile +1 -1
- data/README.md +5 -1
- data/docs/Instance-Variable-Assumption.md +29 -0
- data/features/command_line_interface/options.feature +2 -2
- data/features/configuration_files/exclude_paths_directives.feature +8 -9
- data/features/configuration_files/schema_validation.feature +1 -1
- data/features/reports/json.feature +3 -3
- data/features/reports/reports.feature +4 -4
- data/features/reports/yaml.feature +3 -3
- data/features/step_definitions/sample_file_steps.rb +6 -0
- data/lib/reek/configuration/excluded_paths.rb +4 -4
- data/lib/reek/source/source_locator.rb +2 -0
- data/lib/reek/version.rb +1 -1
- data/samples/configuration/with_excluded_paths.reek +1 -0
- data/samples/source_with_exclude_paths/nested/uncommunicative_variable_name.rb +6 -0
- data/spec/reek/configuration/app_configuration_spec.rb +75 -32
- data/spec/reek/configuration/excluded_paths_spec.rb +5 -8
- data/spec/reek/source/source_locator_spec.rb +5 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6edbc24f9dc5d13f418d60c9fbcadd30e8ac433c
|
4
|
+
data.tar.gz: f0fdcaa7d1a6dc702f24763f62a44367a7004365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7cad97b7d6108cf2c8f813adf0dc72258f64aab8645eacbb5854146614a6afa6d35951e950187d967007abeefe38eebd5af468f005d551929a73115e7cbe00
|
7
|
+
data.tar.gz: 4a04b1a57046145c006322cb6d34db5bcd970cceef1834a539209dfe2c2469c1b4d05359e5e3393dd8084f3f605af25dd2aaafaecb6212cf680587a267326e2d
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -89,6 +89,14 @@ class Alfa
|
|
89
89
|
end
|
90
90
|
```
|
91
91
|
|
92
|
+
We also aim to make our specs as self-reliant as possible. They should not rely on external sample
|
93
|
+
or configuration files since that makes it very hard to reason about them and introduces a tight coupling
|
94
|
+
which makes refactoring more difficult.
|
95
|
+
Unfortunately our current specs are a bit misleading in this regard since they are often doing the
|
96
|
+
opposite, relying on external sample and configuration files (indicated by using
|
97
|
+
some of the constants defined in `samples/paths.rb`).
|
98
|
+
Our goal is to reverse this development.
|
99
|
+
|
92
100
|
### Cucumber Features
|
93
101
|
|
94
102
|
Reek uses [Cucumber](https://cucumber.io/) with
|
data/Gemfile
CHANGED
@@ -12,7 +12,7 @@ group :development do
|
|
12
12
|
gem 'kramdown', '~> 1.17'
|
13
13
|
gem 'rake', '~> 12.0'
|
14
14
|
gem 'rspec', '~> 3.0'
|
15
|
-
gem 'rspec-benchmark', '~> 0.
|
15
|
+
gem 'rspec-benchmark', '~> 0.4.0'
|
16
16
|
gem 'rubocop', '~> 0.59.1'
|
17
17
|
gem 'rubocop-rspec', '~> 1.29.0'
|
18
18
|
gem 'simplecov', '~> 0.16.1'
|
data/README.md
CHANGED
@@ -324,10 +324,11 @@ directories:
|
|
324
324
|
|
325
325
|
### Excluding directories
|
326
326
|
|
327
|
-
# Directories below will not be scanned at all
|
327
|
+
# Directories and files below will not be scanned at all
|
328
328
|
exclude_paths:
|
329
329
|
- lib/legacy
|
330
330
|
- lib/rake/legacy_tasks
|
331
|
+
- lib/smelly.rb
|
331
332
|
```
|
332
333
|
|
333
334
|
As you see above, Reek's configuration consists of 3 different sections denoted by 3 different keys:
|
@@ -582,6 +583,9 @@ directories:
|
|
582
583
|
"app/mailers":
|
583
584
|
InstanceVariableAssumption:
|
584
585
|
enabled: false
|
586
|
+
"app/models":
|
587
|
+
InstanceVariableAssumption:
|
588
|
+
enabled: false
|
585
589
|
```
|
586
590
|
|
587
591
|
Be careful though, Reek does not merge your configuration entries, so if you already have a directory directive for "app/controllers" or "app/helpers" you need to update those directives instead of copying the above YAML sample into your configuration file.
|
@@ -129,6 +129,35 @@ An instance variable must:
|
|
129
129
|
|
130
130
|
If not, _Instance Variable Assumption_ will be reported.
|
131
131
|
|
132
|
+
## Using Instance Variable Assumption in a Rails context
|
133
|
+
|
134
|
+
In ActiveRecord it seems common to use callbacks like `after_initialize` to initialize instance variables as
|
135
|
+
outlined [here](https://stackoverflow.com/questions/41165520/overriding-applicationrecord-initialize-bad-idea)
|
136
|
+
or [here](http://blog.dalethatcher.com/2008/03/rails-dont-override-initialize-on.html)
|
137
|
+
instead of overriding the `initialize` method.
|
138
|
+
If an instance variable is initialized in such a callback Reek will report it correspondingly.
|
139
|
+
|
140
|
+
This would smell for instance:
|
141
|
+
|
142
|
+
```Ruby
|
143
|
+
class Sample < ApplicationRecord
|
144
|
+
after_initialize do
|
145
|
+
@my_var = false
|
146
|
+
end
|
147
|
+
end
|
148
|
+
```
|
149
|
+
|
150
|
+
Since Reek cannot reliably detect that is used in a Rails context we recommend to disable this detector
|
151
|
+
for "app/models" like this:
|
152
|
+
|
153
|
+
```Yaml
|
154
|
+
directories:
|
155
|
+
# Your other configuration....
|
156
|
+
"app/models":
|
157
|
+
InstanceVariableAssumption:
|
158
|
+
enabled: false
|
159
|
+
```
|
160
|
+
|
132
161
|
## Configuration
|
133
162
|
|
134
163
|
_Instance Variable Assumption_ supports the [Basic Smell Options](Basic-Smell-Options.md).
|
@@ -43,7 +43,7 @@ Feature: Reek can be controlled using command-line options
|
|
43
43
|
-c, --config FILE Read configuration options from FILE
|
44
44
|
--smell SMELL Only look for a specific smell.
|
45
45
|
Call it like this: reek --smell MissingSafeMethod source.rb
|
46
|
-
Check out https://github.com/troessner/reek/blob/v5.
|
46
|
+
Check out https://github.com/troessner/reek/blob/v5.2.0/docs/Code-Smells.md for a list of smells
|
47
47
|
--stdin-filename FILE When passing code in via pipe, assume this filename when checking file or directory rules in the config.
|
48
48
|
|
49
49
|
Generate a todo list:
|
@@ -120,5 +120,5 @@ Feature: Reek can be controlled using command-line options
|
|
120
120
|
UnusedPrivateMethod
|
121
121
|
UtilityFunction
|
122
122
|
|
123
|
-
Check out https://github.com/troessner/reek/blob/v5.
|
123
|
+
Check out https://github.com/troessner/reek/blob/v5.2.0/docs/Code-Smells.md for a details on each detector
|
124
124
|
"""
|
@@ -3,25 +3,24 @@ Feature: Exclude paths directives
|
|
3
3
|
As a user
|
4
4
|
I want to be able to exclude specific paths from being checked
|
5
5
|
|
6
|
-
Scenario: Exclude
|
7
|
-
Given
|
8
|
-
|
9
|
-
|
10
|
-
class Smelly
|
11
|
-
def alfa(bravo); end
|
12
|
-
end
|
13
|
-
"""
|
6
|
+
Scenario: Exclude paths
|
7
|
+
Given the smelly file "smelly.rb" in the directory "smelly_sources"
|
8
|
+
And the smelly file "smelly.rb" in the directory "smelly_as_well"
|
9
|
+
And the smelly file "smelly.rb" in the directory "smelly_as_well_2"
|
14
10
|
When I run reek .
|
15
11
|
Then the exit status indicates smells
|
16
12
|
Given a file named "config.reek" with:
|
17
13
|
"""
|
18
14
|
---
|
19
15
|
exclude_paths:
|
20
|
-
-
|
16
|
+
- smelly_sources/smelly.rb
|
17
|
+
- smelly_as_well/
|
18
|
+
- smelly_as_well_2
|
21
19
|
"""
|
22
20
|
When I run reek -c config.reek .
|
23
21
|
Then it succeeds
|
24
22
|
And it reports nothing
|
23
|
+
|
25
24
|
Scenario: Using a file name within an excluded directory
|
26
25
|
Given a file named "bad_files_live_here/smelly.rb" with:
|
27
26
|
"""
|
@@ -24,7 +24,7 @@ Feature: Report smells using simple JSON layout
|
|
24
24
|
"context": "Smelly#x",
|
25
25
|
"lines": [ 4 ],
|
26
26
|
"message": "has the name 'x'",
|
27
|
-
"documentation_link": "https://github.com/troessner/reek/blob/v5.
|
27
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Method-Name.md",
|
28
28
|
"name": "x"
|
29
29
|
},
|
30
30
|
{
|
@@ -33,7 +33,7 @@ Feature: Report smells using simple JSON layout
|
|
33
33
|
"context": "Smelly#x",
|
34
34
|
"lines": [ 5 ],
|
35
35
|
"message": "has the variable name 'y'",
|
36
|
-
"documentation_link": "https://github.com/troessner/reek/blob/v5.
|
36
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Variable-Name.md",
|
37
37
|
"name": "y"
|
38
38
|
}
|
39
39
|
]
|
@@ -53,7 +53,7 @@ Feature: Report smells using simple JSON layout
|
|
53
53
|
1
|
54
54
|
],
|
55
55
|
"message": "has no descriptive comment",
|
56
|
-
"documentation_link": "https://github.com/troessner/reek/blob/v5.
|
56
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.2.0/docs/Irresponsible-Module.md"
|
57
57
|
}
|
58
58
|
]
|
59
59
|
"""
|
@@ -182,8 +182,8 @@ Feature: Correctly formatted reports
|
|
182
182
|
And it reports:
|
183
183
|
"""
|
184
184
|
smelly.rb -- 2 warnings:
|
185
|
-
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.
|
186
|
-
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.
|
185
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Method-Name.md]
|
186
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Variable-Name.md]
|
187
187
|
"""
|
188
188
|
|
189
189
|
Examples:
|
@@ -209,8 +209,8 @@ Feature: Correctly formatted reports
|
|
209
209
|
And it reports:
|
210
210
|
"""
|
211
211
|
smelly.rb -- 2 warnings:
|
212
|
-
UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.
|
213
|
-
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.
|
212
|
+
UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Method-Name.md]
|
213
|
+
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Variable-Name.md]
|
214
214
|
"""
|
215
215
|
|
216
216
|
Examples:
|
@@ -25,7 +25,7 @@ Feature: Report smells using simple YAML layout
|
|
25
25
|
smell_type: UncommunicativeMethodName
|
26
26
|
source: smelly.rb
|
27
27
|
name: x
|
28
|
-
documentation_link: https://github.com/troessner/reek/blob/v5.
|
28
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Method-Name.md
|
29
29
|
- context: Smelly#x
|
30
30
|
lines:
|
31
31
|
- 5
|
@@ -33,7 +33,7 @@ Feature: Report smells using simple YAML layout
|
|
33
33
|
smell_type: UncommunicativeVariableName
|
34
34
|
source: smelly.rb
|
35
35
|
name: y
|
36
|
-
documentation_link: https://github.com/troessner/reek/blob/v5.
|
36
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.2.0/docs/Uncommunicative-Variable-Name.md
|
37
37
|
"""
|
38
38
|
|
39
39
|
Scenario: Indicate smells and print them as yaml when using STDIN
|
@@ -48,5 +48,5 @@ Feature: Report smells using simple YAML layout
|
|
48
48
|
lines:
|
49
49
|
- 1
|
50
50
|
message: has no descriptive comment
|
51
|
-
documentation_link: https://github.com/troessner/reek/blob/v5.
|
51
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.2.0/docs/Irresponsible-Module.md
|
52
52
|
"""
|
@@ -4,6 +4,12 @@ Given(/^the smelly file '(.+)'$/) do |filename|
|
|
4
4
|
write_file(filename, SAMPLES_DIR.join('smelly_source').join(filename).read)
|
5
5
|
end
|
6
6
|
|
7
|
+
Given(/^the smelly file "(.+)" in the directory "(.+)"$/) do |filename, directory|
|
8
|
+
FileUtils.mkdir_p directory
|
9
|
+
write_file Pathname(directory).join(filename).to_s,
|
10
|
+
SAMPLES_DIR.join('smelly_source').join(filename).read
|
11
|
+
end
|
12
|
+
|
7
13
|
Given(/^the clean file "(.*)"$/) do |filename|
|
8
14
|
write_file(filename, CLEAN_FILE.read)
|
9
15
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative './configuration_validator'
|
4
|
+
require_relative '../errors/config_file_error'
|
4
5
|
|
5
6
|
module Reek
|
6
7
|
module Configuration
|
@@ -10,11 +11,10 @@ module Reek
|
|
10
11
|
module ExcludedPaths
|
11
12
|
include ConfigurationValidator
|
12
13
|
|
13
|
-
# @
|
14
|
+
# @param paths [String]
|
15
|
+
# @return [undefined]
|
14
16
|
def add(paths)
|
15
|
-
paths.each
|
16
|
-
with_valid_directory(path) { |directory| self << directory }
|
17
|
-
end
|
17
|
+
paths.each { |path| self << Pathname(path) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/reek/version.rb
CHANGED
@@ -7,48 +7,65 @@ require_lib 'reek/configuration/excluded_paths'
|
|
7
7
|
|
8
8
|
RSpec.describe Reek::Configuration::AppConfiguration do
|
9
9
|
describe 'factory methods' do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
{ Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } }
|
10
|
+
around do |example|
|
11
|
+
Dir.mktmpdir('/tmp') do |tmp|
|
12
|
+
Dir.chdir(tmp) do
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
end
|
17
16
|
end
|
18
17
|
|
19
|
-
let(:
|
20
|
-
|
21
|
-
{ Reek::SmellDetectors::UtilityFunction => { 'enabled' => false } } }
|
18
|
+
let(:expected_exclude_file_names) do
|
19
|
+
%w(exclude_me.rb exclude_me_too.rb)
|
22
20
|
end
|
23
21
|
|
24
|
-
let(:
|
25
|
-
|
26
|
-
{ 'IrresponsibleModule' => { 'enabled' => false } } }
|
22
|
+
let(:expected_exclude_directories) do
|
23
|
+
%w(directory_with_trailing_slash/ directory_without_trailing_slash)
|
27
24
|
end
|
28
25
|
|
29
|
-
let(:
|
30
|
-
{
|
31
|
-
{ 'samples/three_clean_files' =>
|
32
|
-
{ 'UtilityFunction' => { 'enabled' => false } } } }
|
26
|
+
let(:expected_excluded_paths) do
|
27
|
+
(expected_exclude_file_names + expected_exclude_directories).map { |path| Pathname(path) }
|
33
28
|
end
|
34
29
|
|
35
|
-
let(:
|
36
|
-
{ Reek::
|
37
|
-
['samples/two_smelly_files',
|
38
|
-
'samples/source_with_non_ruby_files'] }
|
30
|
+
let(:expected_default_directive) do
|
31
|
+
{ Reek::SmellDetectors::IrresponsibleModule => { 'enabled' => false } }
|
39
32
|
end
|
40
33
|
|
41
|
-
let(:
|
42
|
-
|
43
|
-
|
44
|
-
merge(exclude_paths_value)
|
34
|
+
let(:expected_directory_directives) do
|
35
|
+
{ Pathname('directory_with_some_ruby_files') =>
|
36
|
+
{ Reek::SmellDetectors::UtilityFunction => { 'enabled' => false } } }
|
45
37
|
end
|
46
38
|
|
47
39
|
describe '#from_path' do
|
48
|
-
let(:
|
40
|
+
let(:configuration_path) { 'config.reek' }
|
41
|
+
let(:configuration) do
|
42
|
+
<<-EOF.strip_heredoc
|
43
|
+
---
|
44
|
+
detectors:
|
45
|
+
IrresponsibleModule:
|
46
|
+
enabled: false
|
47
|
+
|
48
|
+
directories:
|
49
|
+
"directory_with_some_ruby_files":
|
50
|
+
UtilityFunction:
|
51
|
+
enabled: false
|
52
|
+
|
53
|
+
exclude_paths:
|
54
|
+
- "exclude_me.rb"
|
55
|
+
- "exclude_me_too.rb"
|
56
|
+
- "directory_with_trailing_slash/"
|
57
|
+
- "directory_without_trailing_slash"
|
58
|
+
EOF
|
59
|
+
end
|
60
|
+
|
61
|
+
before do
|
62
|
+
File.write configuration_path, configuration
|
63
|
+
FileUtils.touch expected_exclude_file_names
|
64
|
+
FileUtils.mkdir expected_exclude_directories
|
65
|
+
end
|
49
66
|
|
50
67
|
it 'properly loads configuration and processes it' do
|
51
|
-
config = described_class.from_path
|
68
|
+
config = described_class.from_path configuration_path
|
52
69
|
|
53
70
|
expect(config.send(:excluded_paths)).to eq(expected_excluded_paths)
|
54
71
|
expect(config.send(:default_directive)).to eq(expected_default_directive)
|
@@ -57,6 +74,32 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
57
74
|
end
|
58
75
|
|
59
76
|
describe '#from_hash' do
|
77
|
+
before do
|
78
|
+
FileUtils.touch expected_exclude_file_names
|
79
|
+
FileUtils.mkdir expected_exclude_directories
|
80
|
+
end
|
81
|
+
|
82
|
+
let(:default_directive_value) do
|
83
|
+
{ Reek::DETECTORS_KEY =>
|
84
|
+
{ 'IrresponsibleModule' => { 'enabled' => false } } }
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:directory_directives_value) do
|
88
|
+
{ Reek::DIRECTORIES_KEY =>
|
89
|
+
{ 'directory_with_some_ruby_files' =>
|
90
|
+
{ 'UtilityFunction' => { 'enabled' => false } } } }
|
91
|
+
end
|
92
|
+
|
93
|
+
let(:exclude_paths_value) do
|
94
|
+
{ Reek::EXCLUDE_PATHS_KEY => (expected_exclude_file_names + expected_exclude_directories) }
|
95
|
+
end
|
96
|
+
|
97
|
+
let(:combined_value) do
|
98
|
+
directory_directives_value.
|
99
|
+
merge(default_directive_value).
|
100
|
+
merge(exclude_paths_value)
|
101
|
+
end
|
102
|
+
|
60
103
|
it 'sets the configuration a unified simple data structure' do
|
61
104
|
config = described_class.from_hash(combined_value)
|
62
105
|
|
@@ -79,7 +122,7 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
79
122
|
|
80
123
|
describe '#directive_for' do
|
81
124
|
context 'with multiple directory directives and no default directive present' do
|
82
|
-
let(:source_via) { 'samples/
|
125
|
+
let(:source_via) { 'samples/some_files/dummy1.rb' }
|
83
126
|
let(:baz_config) { { IrresponsibleModule: { enabled: false } } }
|
84
127
|
let(:bang_config) { { Attribute: { enabled: true } } }
|
85
128
|
let(:expected_result) { { Reek::SmellDetectors::Attribute => { enabled: true } } }
|
@@ -87,8 +130,8 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
87
130
|
let(:directory_directives) do
|
88
131
|
{ Reek::DIRECTORIES_KEY =>
|
89
132
|
{
|
90
|
-
'samples/
|
91
|
-
'samples/
|
133
|
+
'samples/some_files' => bang_config,
|
134
|
+
'samples/other_files' => baz_config
|
92
135
|
} }
|
93
136
|
end
|
94
137
|
|
@@ -124,7 +167,7 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
124
167
|
end
|
125
168
|
|
126
169
|
context 'with a path not covered by a directory directive but a default directive present' do
|
127
|
-
let(:source_via) { '
|
170
|
+
let(:source_via) { 'samples/some_files/dummy.rb' }
|
128
171
|
|
129
172
|
let(:configuration_as_hash) do
|
130
173
|
{
|
@@ -132,7 +175,7 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
132
175
|
IrresponsibleModule: { enabled: false }
|
133
176
|
},
|
134
177
|
Reek::DIRECTORIES_KEY =>
|
135
|
-
{ '
|
178
|
+
{ 'samples/other_files' => { Attribute: { enabled: false } } }
|
136
179
|
}
|
137
180
|
end
|
138
181
|
|
@@ -5,15 +5,12 @@ require_lib 'reek/configuration/excluded_paths'
|
|
5
5
|
RSpec.describe Reek::Configuration::ExcludedPaths do
|
6
6
|
describe '#add' do
|
7
7
|
let(:exclusions) { [].extend(described_class) }
|
8
|
+
let(:paths) { ['smelly/sources'] }
|
9
|
+
let(:expected_exclude_paths) { [Pathname('smelly/sources')] }
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
let(:paths) { [smelly_source_dir, file_as_path] }
|
13
|
-
|
14
|
-
it 'raises an error if one of the given paths is a file' do
|
15
|
-
expect { exclusions.add(paths) }.to raise_error(Reek::Errors::ConfigFileError)
|
16
|
-
end
|
11
|
+
it 'adds the given paths as Pathname' do
|
12
|
+
exclusions.add(paths)
|
13
|
+
expect(exclusions).to eq expected_exclude_paths
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -92,17 +92,18 @@ RSpec.describe Reek::Source::SourceLocator do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
context 'when path is a directory' do
|
95
|
+
context 'when path is a directory or a file' do
|
96
96
|
let(:path) { SAMPLES_DIR.join('source_with_exclude_paths') }
|
97
97
|
|
98
98
|
let(:expected_paths) do
|
99
|
-
[path.join('nested/
|
99
|
+
[path.join('nested/uncommunicative_variable_name.rb')]
|
100
100
|
end
|
101
101
|
|
102
102
|
let(:paths_that_are_expected_to_be_ignored) do
|
103
103
|
[
|
104
104
|
path.join('ignore_me/uncommunicative_method_name.rb'),
|
105
|
-
path.join('nested/ignore_me_as_well/irresponsible_module.rb')
|
105
|
+
path.join('nested/ignore_me_as_well/irresponsible_module.rb'),
|
106
|
+
path.join('nested/uncommunicative_parameter_name.rb')
|
106
107
|
]
|
107
108
|
end
|
108
109
|
|
@@ -111,7 +112,7 @@ RSpec.describe Reek::Source::SourceLocator do
|
|
111
112
|
expect(sources).not_to include(*paths_that_are_expected_to_be_ignored)
|
112
113
|
end
|
113
114
|
|
114
|
-
it 'scans directories that are not excluded' do
|
115
|
+
it 'scans directories and files that are not excluded' do
|
115
116
|
sources = described_class.new([path], configuration: configuration).sources
|
116
117
|
expect(sources).to eq expected_paths
|
117
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rutherford
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-10-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb
|
368
368
|
- samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb
|
369
369
|
- samples/source_with_exclude_paths/nested/uncommunicative_parameter_name.rb
|
370
|
+
- samples/source_with_exclude_paths/nested/uncommunicative_variable_name.rb
|
370
371
|
- samples/source_with_hidden_directories/.hidden/hidden.rb
|
371
372
|
- samples/source_with_hidden_directories/not_hidden.rb
|
372
373
|
- samples/source_with_non_ruby_files/gibberish
|