reek 5.4.0 → 5.4.1
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/.rubocop.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/Dockerfile +1 -1
- data/Gemfile +7 -6
- data/README.md +1 -1
- data/features/command_line_interface/options.feature +2 -2
- data/features/reports/json.feature +3 -3
- data/features/reports/reports.feature +4 -4
- data/features/reports/yaml.feature +3 -3
- data/lib/reek/cli/command/todo_list_command.rb +7 -2
- data/lib/reek/smell_detectors/base_detector.rb +1 -1
- data/lib/reek/smell_detectors/too_many_constants.rb +1 -1
- data/lib/reek/smell_warning.rb +18 -14
- data/lib/reek/version.rb +1 -1
- data/spec/factories/factories.rb +3 -14
- data/spec/reek/cli/application_spec.rb +1 -1
- data/spec/reek/examiner_spec.rb +1 -0
- data/spec/reek/report/code_climate/code_climate_fingerprint_spec.rb +22 -22
- data/spec/reek/report/code_climate/code_climate_formatter_spec.rb +5 -5
- data/spec/reek/smell_configuration_spec.rb +2 -0
- data/spec/reek/smell_detectors/base_detector_spec.rb +3 -6
- data/spec/reek/smell_warning_spec.rb +17 -28
- data/spec/reek/spec/should_reek_only_of_spec.rb +6 -13
- data/spec/reek/spec/smell_matcher_spec.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc4e5c07f939e121b14b1b9250411d0e83fce7e936271328731500cf8a93a8e
|
4
|
+
data.tar.gz: 167f4022f6d3120e9dffb9eb3828f756755790c13c1e70c09f46a20dd1dc23c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 540da16a41f3939e187389759bfb9893e56f0cdf9f9dee01b09e924ba412c6f42210584b07613122dfbaed26f75991ac2b411a7db78227e175b2aae2dc289db0
|
7
|
+
data.tar.gz: a354ce529e870797c32b2608f1e05facfbdeb52f8e4fe9de5280b42b769dd2ddbe740a0c374f2cbdc1cc32d5254eb51037861c9149cc4ef427545ea626137ea1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 5.4.1 (2019-11-12)
|
6
|
+
|
7
|
+
* (Filipe Esperandio) Bump base image to a more recent ruby version
|
8
|
+
* (Fernando Contreras) Add quotes inside directory configuration
|
9
|
+
|
5
10
|
## 5.4.0 (2019-04-24)
|
6
11
|
|
7
12
|
* (Philippe Bernery) Enable regex for directory directives.
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
@@ -7,19 +7,20 @@ ruby RUBY_VERSION
|
|
7
7
|
group :development do
|
8
8
|
gem 'aruba', '~> 0.14.8'
|
9
9
|
gem 'cucumber', '~> 3.0'
|
10
|
-
gem 'factory_bot', '~> 5.0'
|
10
|
+
gem 'factory_bot', '~> 5.0', '!= 5.1.0'
|
11
11
|
gem 'kramdown', '~> 2.1'
|
12
12
|
gem 'kramdown-parser-gfm', '~> 1.0'
|
13
|
-
gem 'rake', '~>
|
13
|
+
gem 'rake', '~> 13.0'
|
14
14
|
gem 'rspec', '~> 3.0'
|
15
15
|
gem 'rspec-benchmark', '~> 0.5.0'
|
16
|
-
gem 'rubocop', '~> 0.
|
17
|
-
gem 'rubocop-
|
18
|
-
gem '
|
16
|
+
gem 'rubocop', '~> 0.75.0'
|
17
|
+
gem 'rubocop-performance', '~> 1.5.0'
|
18
|
+
gem 'rubocop-rspec', '~> 1.36.0'
|
19
|
+
gem 'simplecov', '~> 0.17.0'
|
19
20
|
gem 'yard', '~> 0.9.5'
|
20
21
|
|
21
22
|
platforms :mri do
|
22
|
-
gem 'redcarpet', '~> 3.4
|
23
|
+
gem 'redcarpet', '~> 3.4'
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
data/README.md
CHANGED
@@ -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.4.
|
46
|
+
Check out https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
123
|
+
Check out https://github.com/troessner/reek/blob/v5.4.1/docs/Code-Smells.md for a details on each detector
|
124
124
|
"""
|
@@ -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.4.
|
27
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
36
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
56
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
186
|
-
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.4.
|
185
|
+
[4]:UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.4.1/docs/Uncommunicative-Method-Name.md]
|
186
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
213
|
-
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.4.
|
212
|
+
UncommunicativeMethodName: Smelly#x has the name 'x' [https://github.com/troessner/reek/blob/v5.4.1/docs/Uncommunicative-Method-Name.md]
|
213
|
+
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
28
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
36
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.4.1/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.4.
|
51
|
+
documentation_link: https://github.com/troessner/reek/blob/v5.4.1/docs/Irresponsible-Module.md
|
52
52
|
"""
|
@@ -40,13 +40,18 @@ module Reek
|
|
40
40
|
def groups
|
41
41
|
@groups ||=
|
42
42
|
begin
|
43
|
-
todos =
|
43
|
+
todos = DetectorRepository.smell_types.map do |smell_class|
|
44
|
+
smells_for_class = grouped_smells[smell_class.smell_type] or next
|
44
45
|
smell_class.todo_configuration_for(smells_for_class)
|
45
46
|
end
|
46
|
-
todos.inject(&:merge)
|
47
|
+
todos.compact.inject(&:merge)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
def grouped_smells
|
52
|
+
@grouped_smells ||= smells.group_by(&:smell_type)
|
53
|
+
end
|
54
|
+
|
50
55
|
# :reek:FeatureEnvy
|
51
56
|
def write_to_file
|
52
57
|
File.open(DEFAULT_CONFIGURATION_FILE_NAME, 'w') do |configuration_file|
|
@@ -35,7 +35,7 @@ module Reek
|
|
35
35
|
# @return [Array<SmellWarning>]
|
36
36
|
#
|
37
37
|
def sniff
|
38
|
-
count = context.local_nodes(:casgn).
|
38
|
+
count = context.local_nodes(:casgn).count { |it| !it.defines_module? }
|
39
39
|
|
40
40
|
return [] if count <= max_allowed_constants
|
41
41
|
|
data/lib/reek/smell_warning.rb
CHANGED
@@ -15,22 +15,30 @@ module Reek
|
|
15
15
|
extend Forwardable
|
16
16
|
|
17
17
|
# @public
|
18
|
-
attr_reader :context, :lines, :message, :parameters, :
|
19
|
-
|
20
|
-
|
18
|
+
attr_reader :context, :lines, :message, :parameters, :smell_type, :source
|
19
|
+
|
20
|
+
# @param smell_type [String] type of detected smell; corresponds to
|
21
|
+
# detector#smell_type
|
22
|
+
# @param context [String] name of the context in which the smell occured
|
23
|
+
# @param lines [Array<Integer>] list of lines on which the smell occured
|
24
|
+
# @param message [String] text describing the smell in more detail
|
25
|
+
# @param source [String] name of the source (e.g., the file name) in which
|
26
|
+
# the smell occured
|
27
|
+
# @param parameters [Hash] smell-specific parameters
|
28
|
+
#
|
21
29
|
# @note When using Reek's public API, you should not create SmellWarning
|
22
30
|
# objects yourself. This is why the initializer is not part of the
|
23
31
|
# public API.
|
24
32
|
#
|
25
33
|
# @quality :reek:LongParameterList { max_params: 6 }
|
26
|
-
def initialize(
|
34
|
+
def initialize(smell_type, context: '', lines:, message:,
|
27
35
|
source:, parameters: {})
|
28
|
-
@
|
29
|
-
@source
|
30
|
-
@context
|
31
|
-
@lines
|
32
|
-
@message
|
33
|
-
@parameters
|
36
|
+
@smell_type = smell_type
|
37
|
+
@source = source
|
38
|
+
@context = context.to_s
|
39
|
+
@lines = lines
|
40
|
+
@message = message
|
41
|
+
@parameters = parameters
|
34
42
|
|
35
43
|
freeze
|
36
44
|
end
|
@@ -64,10 +72,6 @@ module Reek
|
|
64
72
|
"#{smell_type}: #{context} #{message}"
|
65
73
|
end
|
66
74
|
|
67
|
-
def smell_class
|
68
|
-
smell_detector.class
|
69
|
-
end
|
70
|
-
|
71
75
|
def explanatory_link
|
72
76
|
DocumentationLink.build(smell_type)
|
73
77
|
end
|
data/lib/reek/version.rb
CHANGED
data/spec/factories/factories.rb
CHANGED
@@ -4,29 +4,18 @@ require_relative '../../lib/reek/smell_warning'
|
|
4
4
|
require_relative '../../lib/reek/cli/options'
|
5
5
|
|
6
6
|
FactoryBot.define do
|
7
|
-
factory :smell_detector, class: Reek::SmellDetectors::BaseDetector do
|
8
|
-
skip_create
|
9
|
-
transient do
|
10
|
-
smell_type { 'FeatureEnvy' }
|
11
|
-
end
|
12
|
-
|
13
|
-
initialize_with do
|
14
|
-
::Reek::SmellDetectors.const_get(smell_type).new
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
7
|
factory :smell_warning, class: Reek::SmellWarning do
|
19
8
|
skip_create
|
20
|
-
smell_detector
|
21
|
-
context { 'self' }
|
22
9
|
|
10
|
+
smell_type { 'FeatureEnvy' }
|
23
11
|
source { 'dummy_file' }
|
24
12
|
lines { [42] }
|
25
13
|
message { 'smell warning message' }
|
26
14
|
parameters { {} }
|
15
|
+
context { 'self' }
|
27
16
|
|
28
17
|
initialize_with do
|
29
|
-
new(
|
18
|
+
new(smell_type,
|
30
19
|
source: source,
|
31
20
|
context: context,
|
32
21
|
lines: lines,
|
@@ -9,7 +9,7 @@ RSpec.describe Reek::CLI::Application do
|
|
9
9
|
described_class.new ['--foo']
|
10
10
|
end
|
11
11
|
end
|
12
|
-
expect(call).to raise_error(SystemExit) do |error|
|
12
|
+
expect(&call).to raise_error(SystemExit) do |error|
|
13
13
|
expect(error.status).to eq Reek::CLI::Status::DEFAULT_ERROR_EXIT_CODE
|
14
14
|
end
|
15
15
|
end
|
data/spec/reek/examiner_spec.rb
CHANGED
@@ -9,11 +9,11 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
|
|
9
9
|
let(:expected_fingerprint) { 'e68badd29db51c92363a7c6a2438d722' }
|
10
10
|
let(:warning) do
|
11
11
|
build(:smell_warning,
|
12
|
-
|
13
|
-
context:
|
14
|
-
message:
|
15
|
-
lines:
|
16
|
-
source:
|
12
|
+
smell_type: 'UtilityFunction',
|
13
|
+
context: 'alfa',
|
14
|
+
message: "doesn't depend on instance state (maybe move it to another class?)",
|
15
|
+
lines: lines,
|
16
|
+
source: 'a/ruby/source/file.rb')
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'with code at a specific location' do
|
@@ -36,11 +36,11 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
|
|
36
36
|
context 'when the fingerprint should not be computed' do
|
37
37
|
let(:warning) do
|
38
38
|
build(:smell_warning,
|
39
|
-
|
40
|
-
context:
|
41
|
-
message:
|
42
|
-
lines:
|
43
|
-
source:
|
39
|
+
smell_type: 'ManualDispatch',
|
40
|
+
context: 'Alfa#bravo',
|
41
|
+
message: 'manually dispatches method call',
|
42
|
+
lines: [4],
|
43
|
+
source: 'a/ruby/source/file.rb')
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns nil' do
|
@@ -51,12 +51,12 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
|
|
51
51
|
context 'when the smell warning has only identifying parameters' do
|
52
52
|
let(:warning) do
|
53
53
|
build(:smell_warning,
|
54
|
-
|
55
|
-
context:
|
56
|
-
message:
|
57
|
-
lines:
|
58
|
-
parameters:
|
59
|
-
source:
|
54
|
+
smell_type: 'ClassVariable',
|
55
|
+
context: 'Alfa',
|
56
|
+
message: "declares the class variable '@@#{name}'",
|
57
|
+
lines: [4],
|
58
|
+
parameters: { name: "@@#{name}" },
|
59
|
+
source: 'a/ruby/source/file.rb')
|
60
60
|
end
|
61
61
|
|
62
62
|
context 'when the name is one thing' do
|
@@ -81,12 +81,12 @@ RSpec.describe Reek::Report::CodeClimateFingerprint do
|
|
81
81
|
context 'when the smell warning has identifying and non-identifying parameters' do
|
82
82
|
let(:warning) do
|
83
83
|
build(:smell_warning,
|
84
|
-
|
85
|
-
context:
|
86
|
-
message:
|
87
|
-
lines:
|
88
|
-
parameters:
|
89
|
-
source:
|
84
|
+
smell_type: 'DuplicateMethodCall',
|
85
|
+
context: "Alfa##{name}",
|
86
|
+
message: "calls '#{name}' #{count} times",
|
87
|
+
lines: lines,
|
88
|
+
parameters: { name: "@@#{name}", count: count },
|
89
|
+
source: 'a/ruby/source/file.rb')
|
90
90
|
end
|
91
91
|
|
92
92
|
context 'when the parameters are provided' do
|
@@ -5,11 +5,11 @@ RSpec.describe Reek::Report::CodeClimateFormatter do
|
|
5
5
|
describe '#render' do
|
6
6
|
let(:warning) do
|
7
7
|
build(:smell_warning,
|
8
|
-
|
9
|
-
context:
|
10
|
-
message:
|
11
|
-
lines:
|
12
|
-
source:
|
8
|
+
smell_type: 'UtilityFunction',
|
9
|
+
context: 'context foo',
|
10
|
+
message: 'message bar',
|
11
|
+
lines: [1, 2],
|
12
|
+
source: 'a/ruby/source/file.rb')
|
13
13
|
end
|
14
14
|
let(:rendered) { described_class.new(warning).render }
|
15
15
|
let(:json) { JSON.parse rendered.chop }
|
@@ -18,10 +18,12 @@ RSpec.describe Reek::SmellConfiguration do
|
|
18
18
|
it { expect(smell_config.merge('enabled' => true)).to eq(base_config) }
|
19
19
|
it { expect(smell_config.merge('exclude' => [])).to eq(base_config) }
|
20
20
|
it { expect(smell_config.merge('accept' => ['_'])).to eq(base_config) }
|
21
|
+
|
21
22
|
it do
|
22
23
|
updated = smell_config.merge('reject' => [/^.$/, /[0-9]$/, /[A-Z]/])
|
23
24
|
expect(updated).to eq(base_config)
|
24
25
|
end
|
26
|
+
|
25
27
|
it do
|
26
28
|
updated = smell_config.merge('accept' => ['_'], 'enabled' => true)
|
27
29
|
expect(updated).to eq(base_config)
|
@@ -5,15 +5,13 @@ require_lib 'reek/smell_detectors/duplicate_method_call'
|
|
5
5
|
RSpec.describe Reek::SmellDetectors::BaseDetector do
|
6
6
|
describe '.todo_configuration_for' do
|
7
7
|
it 'returns exclusion configuration for the given smells' do
|
8
|
-
|
9
|
-
smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
|
8
|
+
smell = create(:smell_warning, smell_type: 'Foo', context: 'Foo#bar')
|
10
9
|
result = described_class.todo_configuration_for([smell])
|
11
10
|
expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
|
12
11
|
end
|
13
12
|
|
14
13
|
it 'merges identical contexts' do
|
15
|
-
|
16
|
-
smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
|
14
|
+
smell = create(:smell_warning, smell_type: 'Foo', context: 'Foo#bar')
|
17
15
|
result = described_class.todo_configuration_for([smell, smell])
|
18
16
|
expect(result).to eq('BaseDetector' => { 'exclude' => ['Foo#bar'] })
|
19
17
|
end
|
@@ -22,8 +20,7 @@ RSpec.describe Reek::SmellDetectors::BaseDetector do
|
|
22
20
|
let(:subclass) { Reek::SmellDetectors::TooManyStatements }
|
23
21
|
|
24
22
|
it 'includes default exclusions' do
|
25
|
-
|
26
|
-
smell = create(:smell_warning, smell_detector: detector, context: 'Foo#bar')
|
23
|
+
smell = create(:smell_warning, smell_type: 'TooManyStatements', context: 'Foo#bar')
|
27
24
|
result = subclass.todo_configuration_for([smell])
|
28
25
|
|
29
26
|
aggregate_failures do
|
@@ -2,9 +2,6 @@ require_relative '../spec_helper'
|
|
2
2
|
require_lib 'reek/smell_warning'
|
3
3
|
|
4
4
|
RSpec.describe Reek::SmellWarning do
|
5
|
-
let(:duplication_detector) { build(:smell_detector, smell_type: 'DuplicateMethodCall') }
|
6
|
-
let(:feature_envy_detector) { build(:smell_detector, smell_type: 'FeatureEnvy') }
|
7
|
-
let(:utility_function_detector) { build(:smell_detector, smell_type: 'UtilityFunction') }
|
8
5
|
let(:uncommunicative_name_detector) { build(:smell_detector, smell_type: 'UncommunicativeVariableName') }
|
9
6
|
|
10
7
|
describe 'sort order' do
|
@@ -27,23 +24,23 @@ RSpec.describe Reek::SmellWarning do
|
|
27
24
|
end
|
28
25
|
|
29
26
|
context 'when smells differ only by detector' do
|
30
|
-
let(:first) { build(:smell_warning,
|
31
|
-
let(:second) { build(:smell_warning,
|
27
|
+
let(:first) { build(:smell_warning, smell_type: 'DuplicateMethodCall') }
|
28
|
+
let(:second) { build(:smell_warning, smell_type: 'FeatureEnvy') }
|
32
29
|
|
33
30
|
it_behaves_like 'first sorts ahead of second'
|
34
31
|
end
|
35
32
|
|
36
33
|
context 'when smells differ only by lines' do
|
37
|
-
let(:first) { build(:smell_warning,
|
38
|
-
let(:second) { build(:smell_warning,
|
34
|
+
let(:first) { build(:smell_warning, smell_type: 'FeatureEnvy', lines: [2]) }
|
35
|
+
let(:second) { build(:smell_warning, smell_type: 'FeatureEnvy', lines: [3]) }
|
39
36
|
|
40
37
|
it_behaves_like 'first sorts ahead of second'
|
41
38
|
end
|
42
39
|
|
43
40
|
context 'when smells differ only by context' do
|
44
|
-
let(:first) { build(:smell_warning,
|
41
|
+
let(:first) { build(:smell_warning, smell_type: 'DuplicateMethodCall', context: 'first') }
|
45
42
|
let(:second) do
|
46
|
-
build(:smell_warning,
|
43
|
+
build(:smell_warning, smell_type: 'DuplicateMethodCall', context: 'second')
|
47
44
|
end
|
48
45
|
|
49
46
|
it_behaves_like 'first sorts ahead of second'
|
@@ -51,11 +48,11 @@ RSpec.describe Reek::SmellWarning do
|
|
51
48
|
|
52
49
|
context 'when smells differ only by message' do
|
53
50
|
let(:first) do
|
54
|
-
build(:smell_warning,
|
51
|
+
build(:smell_warning, smell_type: 'DuplicateMethodCall',
|
55
52
|
context: 'ctx', message: 'first message')
|
56
53
|
end
|
57
54
|
let(:second) do
|
58
|
-
build(:smell_warning,
|
55
|
+
build(:smell_warning, smell_type: 'DuplicateMethodCall',
|
59
56
|
context: 'ctx', message: 'second message')
|
60
57
|
end
|
61
58
|
|
@@ -64,10 +61,10 @@ RSpec.describe Reek::SmellWarning do
|
|
64
61
|
|
65
62
|
context 'when smells differ by name and message' do
|
66
63
|
let(:first) do
|
67
|
-
build(:smell_warning,
|
64
|
+
build(:smell_warning, smell_type: 'FeatureEnvy', message: 'second message')
|
68
65
|
end
|
69
66
|
let(:second) do
|
70
|
-
build(:smell_warning,
|
67
|
+
build(:smell_warning, smell_type: 'UtilityFunction', message: 'first message')
|
71
68
|
end
|
72
69
|
|
73
70
|
it_behaves_like 'first sorts ahead of second'
|
@@ -75,13 +72,13 @@ RSpec.describe Reek::SmellWarning do
|
|
75
72
|
|
76
73
|
context 'when smells differ everywhere' do
|
77
74
|
let(:first) do
|
78
|
-
build(:smell_warning,
|
75
|
+
build(:smell_warning, smell_type: 'DuplicateMethodCall',
|
79
76
|
context: 'Dirty#a',
|
80
77
|
message: 'calls @s.title twice')
|
81
78
|
end
|
82
79
|
|
83
80
|
let(:second) do
|
84
|
-
build(:smell_warning,
|
81
|
+
build(:smell_warning, smell_type: 'UncommunicativeVariableName',
|
85
82
|
context: 'Dirty',
|
86
83
|
message: "has the variable name '@s'")
|
87
84
|
end
|
@@ -90,28 +87,20 @@ RSpec.describe Reek::SmellWarning do
|
|
90
87
|
end
|
91
88
|
end
|
92
89
|
|
93
|
-
describe '#smell_class' do
|
94
|
-
it "returns the dectector's class" do
|
95
|
-
warning = build(:smell_warning, smell_detector: duplication_detector)
|
96
|
-
expect(warning.smell_class).to eq duplication_detector.class
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
90
|
describe '#yaml_hash' do
|
101
91
|
let(:context_name) { 'Module::Class#method/block' }
|
102
92
|
let(:lines) { [24, 513] }
|
103
93
|
let(:message) { 'test message' }
|
104
|
-
let(:detector) { Reek::SmellDetectors::FeatureEnvy.new }
|
105
94
|
let(:parameters) { { 'one' => 34, 'two' => 'second' } }
|
106
95
|
let(:smell_type) { 'FeatureEnvy' }
|
107
96
|
let(:source) { 'a/ruby/source/file.rb' }
|
108
97
|
|
109
98
|
let(:yaml) do
|
110
|
-
warning = described_class.new(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
99
|
+
warning = described_class.new(smell_type, source: source,
|
100
|
+
context: context_name,
|
101
|
+
lines: lines,
|
102
|
+
message: message,
|
103
|
+
parameters: parameters)
|
115
104
|
warning.yaml_hash
|
116
105
|
end
|
117
106
|
|
@@ -40,19 +40,16 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with 1 non-matching smell' do
|
43
|
-
let(:
|
44
|
-
let(:smells) { [build(:smell_warning, smell_detector: control_couple_detector)] }
|
43
|
+
let(:smells) { [build(:smell_warning, smell_type: 'ControlParameter')] }
|
45
44
|
|
46
45
|
it_behaves_like 'no match'
|
47
46
|
end
|
48
47
|
|
49
48
|
context 'with 2 non-matching smells' do
|
50
|
-
let(:control_couple_detector) { build(:smell_detector, smell_type: 'ControlParameter') }
|
51
|
-
let(:feature_envy_detector) { build(:smell_detector, smell_type: 'FeatureEnvy') }
|
52
49
|
let(:smells) do
|
53
50
|
[
|
54
|
-
build(:smell_warning,
|
55
|
-
build(:smell_warning,
|
51
|
+
build(:smell_warning, smell_type: 'ControlParameter'),
|
52
|
+
build(:smell_warning, smell_type: 'FeatureEnvy')
|
56
53
|
]
|
57
54
|
end
|
58
55
|
|
@@ -60,12 +57,10 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
|
|
60
57
|
end
|
61
58
|
|
62
59
|
context 'with 1 non-matching and 1 matching smell' do
|
63
|
-
let(:control_couple_detector) { build(:smell_detector, smell_type: 'ControlParameter') }
|
64
60
|
let(:smells) do
|
65
|
-
detector = build(:smell_detector, smell_type: expected_smell_type.to_s)
|
66
61
|
[
|
67
|
-
build(:smell_warning,
|
68
|
-
build(:smell_warning,
|
62
|
+
build(:smell_warning, smell_type: 'ControlParameter'),
|
63
|
+
build(:smell_warning, smell_type: expected_smell_type.to_s,
|
69
64
|
message: "message mentioning #{expected_context_name}")
|
70
65
|
]
|
71
66
|
end
|
@@ -75,9 +70,7 @@ RSpec.describe Reek::Spec::ShouldReekOnlyOf do
|
|
75
70
|
|
76
71
|
context 'with 1 matching smell' do
|
77
72
|
let(:smells) do
|
78
|
-
|
79
|
-
|
80
|
-
[build(:smell_warning, smell_detector: detector,
|
73
|
+
[build(:smell_warning, smell_type: expected_smell_type.to_s,
|
81
74
|
message: "message mentioning #{expected_context_name}")]
|
82
75
|
end
|
83
76
|
|
@@ -2,9 +2,8 @@ require_relative '../../spec_helper'
|
|
2
2
|
require_lib 'reek/spec/smell_matcher'
|
3
3
|
|
4
4
|
RSpec.describe Reek::Spec::SmellMatcher do
|
5
|
-
let(:detector) { build(:smell_detector, smell_type: 'UncommunicativeVariableName') }
|
6
5
|
let(:smell_warning) do
|
7
|
-
build(:smell_warning,
|
6
|
+
build(:smell_warning, smell_type: 'UncommunicativeVariableName',
|
8
7
|
message: "has the variable name '@s'",
|
9
8
|
parameters: { test: 'something' })
|
10
9
|
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.
|
4
|
+
version: 5.4.1
|
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: 2019-
|
14
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|