reek 5.2.0 → 5.3.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 +5 -5
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +6 -6
- data/.simplecov +4 -2
- data/.travis.yml +7 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -2
- data/README.md +3 -7
- 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/code_comment.rb +4 -4
- data/lib/reek/logging_error_handler.rb +1 -1
- data/lib/reek/report.rb +10 -10
- data/lib/reek/smell_detectors/base_detector.rb +1 -1
- data/lib/reek/smell_detectors/data_clump.rb +1 -1
- data/lib/reek/smell_detectors/subclassed_from_core_class.rb +2 -2
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -0
- data/spec/reek/cli/application_spec.rb +1 -1
- data/spec/reek/cli/command/todo_list_command_spec.rb +21 -21
- data/spec/reek/configuration/app_configuration_spec.rb +40 -35
- data/spec/reek/configuration/configuration_file_finder_spec.rb +19 -17
- data/spec/reek/configuration/directory_directives_spec.rb +3 -3
- data/spec/reek/configuration/rake_task_converter_spec.rb +2 -2
- data/spec/reek/examiner_spec.rb +7 -7
- data/spec/reek/report/code_climate/code_climate_report_spec.rb +20 -20
- data/spec/reek/report/yaml_report_spec.rb +2 -2
- data/spec/reek/smell_detectors/uncommunicative_parameter_name_spec.rb +1 -1
- data/spec/reek/spec/should_reek_of_spec.rb +2 -2
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b224c4eef70b2a99e48c212ba52e13a36ac530c2b96e3fd2b3924a38e0cbda42
|
4
|
+
data.tar.gz: 3667c059f76f95f5eeb25b9f6e576d41e4643c8118f93f31f54a41df50d7605a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbd6ef9ccbde8364187729ef0d496246db6da79e6e04f07f149b971fb567c3fa00d56641dcbd3b2e424d31132ba11bbdaac864e7f5077b432f60db518f8eeb68
|
7
|
+
data.tar.gz: c2ea5ccb2646ee26320fcbf791aee04229633862f98af22f186f2e0ed8d4ddd5115255a148f9b56523b61e244a78af0d31eefdebbd97e1437e2beccd9fc19d7a
|
data/.rubocop.yml
CHANGED
@@ -10,6 +10,12 @@ AllCops:
|
|
10
10
|
- 'vendor/**/*'
|
11
11
|
TargetRubyVersion: 2.3
|
12
12
|
|
13
|
+
# Tables are nice
|
14
|
+
Layout/AlignHash:
|
15
|
+
EnforcedColonStyle: table
|
16
|
+
EnforcedHashRocketStyle: table
|
17
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
18
|
+
|
13
19
|
# Place . on the previous line
|
14
20
|
Layout/DotPosition:
|
15
21
|
EnforcedStyle: trailing
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-
|
3
|
+
# on 2018-11-04 12:41:28 +0100 using RuboCop version 0.60.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -10,13 +10,13 @@
|
|
10
10
|
Metrics/AbcSize:
|
11
11
|
Max: 21
|
12
12
|
|
13
|
-
# Offense count:
|
13
|
+
# Offense count: 1
|
14
14
|
# Configuration parameters: CountComments.
|
15
15
|
Metrics/ClassLength:
|
16
|
-
Max:
|
16
|
+
Max: 161
|
17
17
|
|
18
|
-
# Offense count:
|
19
|
-
# Configuration parameters: CountComments.
|
18
|
+
# Offense count: 13
|
19
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
20
20
|
Metrics/MethodLength:
|
21
21
|
Max: 16
|
22
22
|
|
@@ -49,7 +49,7 @@ RSpec/MultipleDescribes:
|
|
49
49
|
RSpec/MultipleExpectations:
|
50
50
|
Max: 5
|
51
51
|
|
52
|
-
# Offense count:
|
52
|
+
# Offense count: 25
|
53
53
|
RSpec/NestedGroups:
|
54
54
|
Max: 5
|
55
55
|
|
data/.simplecov
CHANGED
@@ -9,6 +9,8 @@ end
|
|
9
9
|
|
10
10
|
SimpleCov.at_exit do
|
11
11
|
SimpleCov.result.format!
|
12
|
-
|
13
|
-
|
12
|
+
unless RUBY_ENGINE == 'jruby'
|
13
|
+
SimpleCov.minimum_coverage 98.88
|
14
|
+
SimpleCov.minimum_coverage_by_file 81.4
|
15
|
+
end
|
14
16
|
end
|
data/.travis.yml
CHANGED
@@ -3,18 +3,23 @@ dist: trusty
|
|
3
3
|
cache: bundler
|
4
4
|
language: ruby
|
5
5
|
bundler_args: --without debugging
|
6
|
+
before_script:
|
7
|
+
# Avoid Java announcing _JAVA_OPTIONS environment variable
|
8
|
+
# See https://github.com/travis-ci/travis-ci/issues/8408
|
9
|
+
- unset _JAVA_OPTIONS
|
6
10
|
script: bundle exec rake ci
|
7
11
|
rvm:
|
8
12
|
- 2.3
|
9
13
|
- 2.4
|
10
14
|
- 2.5
|
11
|
-
-
|
15
|
+
- 2.6
|
16
|
+
- jruby-9.1.17.0
|
17
|
+
- jruby-9.2.5.0
|
12
18
|
- jruby-head
|
13
19
|
- ruby-head
|
14
20
|
- rubinius-3
|
15
21
|
matrix:
|
16
22
|
allow_failures:
|
17
|
-
- rvm: jruby-9.1.15.0
|
18
23
|
- rvm: jruby-head
|
19
24
|
- rvm: ruby-head
|
20
25
|
- rvm: rubinius-3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -13,8 +13,8 @@ group :development do
|
|
13
13
|
gem 'rake', '~> 12.0'
|
14
14
|
gem 'rspec', '~> 3.0'
|
15
15
|
gem 'rspec-benchmark', '~> 0.4.0'
|
16
|
-
gem 'rubocop', '~> 0.
|
17
|
-
gem 'rubocop-rspec', '~> 1.
|
16
|
+
gem 'rubocop', '~> 0.61.1'
|
17
|
+
gem 'rubocop-rspec', '~> 1.30.1'
|
18
18
|
gem 'simplecov', '~> 0.16.1'
|
19
19
|
gem 'yard', '~> 0.9.5'
|
20
20
|
|
data/README.md
CHANGED
@@ -100,13 +100,9 @@ demo.rb -- 2 warnings:
|
|
100
100
|
|
101
101
|
## Supported Ruby versions
|
102
102
|
|
103
|
-
Reek is officially supported for
|
104
|
-
|
105
|
-
|
106
|
-
- 2.4
|
107
|
-
- 2.5
|
108
|
-
|
109
|
-
Other Ruby implementations (like Rubinius or JRuby) are not officially supported but should work as well.
|
103
|
+
Reek is officially supported for CRuby 2.3 to 2.6 and for JRuby 9.1 and 9.2.
|
104
|
+
Other Ruby implementations (like Rubinius) are not officially supported but
|
105
|
+
should work as well.
|
110
106
|
|
111
107
|
## Fixing Smell Warnings
|
112
108
|
|
@@ -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.3.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.3.0/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.
|
27
|
+
"documentation_link": "https://github.com/troessner/reek/blob/v5.3.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.3.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.3.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.3.0/docs/Uncommunicative-Method-Name.md]
|
186
|
+
[5]:UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.3.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.3.0/docs/Uncommunicative-Method-Name.md]
|
213
|
+
UncommunicativeVariableName: Smelly#x has the variable name 'y' [https://github.com/troessner/reek/blob/v5.3.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.3.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.3.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.3.0/docs/Irresponsible-Module.md
|
52
52
|
"""
|
data/lib/reek/code_comment.rb
CHANGED
@@ -20,8 +20,8 @@ module Reek
|
|
20
20
|
\s*
|
21
21
|
(\{.*?\}) # optional details in hash style e.g.: { max_methods: 30 }
|
22
22
|
)?
|
23
|
-
/x
|
24
|
-
SANITIZE_REGEX = /(#|\n|\s)
|
23
|
+
/x.freeze
|
24
|
+
SANITIZE_REGEX = /(#|\n|\s)+/.freeze # Matches '#', newlines and > 1 whitespaces.
|
25
25
|
DISABLE_DETECTOR_CONFIGURATION = '{ enabled: false }'
|
26
26
|
MINIMUM_CONTENT_LENGTH = 2
|
27
27
|
|
@@ -45,7 +45,7 @@ module Reek
|
|
45
45
|
source: source,
|
46
46
|
options: options).validate
|
47
47
|
@config.merge! detector_name => YAML.safe_load(options || DISABLE_DETECTOR_CONFIGURATION,
|
48
|
-
[Regexp])
|
48
|
+
permitted_classes: [Regexp])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -131,7 +131,7 @@ module Reek
|
|
131
131
|
|
132
132
|
def escalate_bad_detector_configuration
|
133
133
|
@parsed_options = YAML.safe_load(options || CodeComment::DISABLE_DETECTOR_CONFIGURATION,
|
134
|
-
[Regexp])
|
134
|
+
permitted_classes: [Regexp])
|
135
135
|
rescue Psych::SyntaxError
|
136
136
|
raise Errors::GarbageDetectorConfigurationInCommentError, detector_name: detector_name,
|
137
137
|
original_comment: original_comment,
|
data/lib/reek/report.rb
CHANGED
@@ -17,33 +17,33 @@ module Reek
|
|
17
17
|
# Reek reporting functionality.
|
18
18
|
module Report
|
19
19
|
REPORT_CLASSES = {
|
20
|
-
yaml:
|
21
|
-
json:
|
22
|
-
html:
|
23
|
-
xml:
|
24
|
-
text:
|
20
|
+
yaml: YAMLReport,
|
21
|
+
json: JSONReport,
|
22
|
+
html: HTMLReport,
|
23
|
+
xml: XMLReport,
|
24
|
+
text: TextReport,
|
25
25
|
code_climate: CodeClimateReport
|
26
26
|
}.freeze
|
27
27
|
|
28
28
|
LOCATION_FORMATTERS = {
|
29
29
|
single_line: SingleLineLocationFormatter,
|
30
|
-
plain:
|
31
|
-
numbers:
|
30
|
+
plain: BlankLocationFormatter,
|
31
|
+
numbers: DefaultLocationFormatter
|
32
32
|
}.freeze
|
33
33
|
|
34
34
|
HEADING_FORMATTERS = {
|
35
35
|
verbose: VerboseHeadingFormatter,
|
36
|
-
quiet:
|
36
|
+
quiet: QuietHeadingFormatter
|
37
37
|
}.freeze
|
38
38
|
|
39
39
|
PROGRESS_FORMATTERS = {
|
40
|
-
dots:
|
40
|
+
dots: ProgressFormatter::Dots,
|
41
41
|
quiet: ProgressFormatter::Quiet
|
42
42
|
}.freeze
|
43
43
|
|
44
44
|
WARNING_FORMATTER_CLASSES = {
|
45
45
|
documentation_links: DocumentationLinkWarningFormatter,
|
46
|
-
simple:
|
46
|
+
simple: SimpleWarningFormatter
|
47
47
|
}.freeze
|
48
48
|
|
49
49
|
# Map report format symbol to a report class.
|
@@ -44,8 +44,8 @@ module Reek
|
|
44
44
|
|
45
45
|
def build_smell_warning(ancestor_name)
|
46
46
|
smell_attributes = {
|
47
|
-
lines:
|
48
|
-
message:
|
47
|
+
lines: [source_line],
|
48
|
+
message: "inherits from core class '#{ancestor_name}'",
|
49
49
|
parameters: { ancestor: ancestor_name }
|
50
50
|
}
|
51
51
|
|
data/lib/reek/version.rb
CHANGED
data/reek.gemspec
CHANGED
@@ -22,5 +22,6 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_runtime_dependency 'codeclimate-engine-rb', '~> 0.4.0'
|
23
23
|
s.add_runtime_dependency 'kwalify', '~> 0.7.0'
|
24
24
|
s.add_runtime_dependency 'parser', '< 2.6', '>= 2.5.0.0', '!= 2.5.1.1'
|
25
|
+
s.add_runtime_dependency 'psych', '~> 3.1.0'
|
25
26
|
s.add_runtime_dependency 'rainbow', '>= 2.0', '< 4.0'
|
26
27
|
end
|
@@ -5,17 +5,17 @@ require_lib 'reek/configuration/app_configuration'
|
|
5
5
|
|
6
6
|
RSpec.describe Reek::CLI::Command::TodoListCommand do
|
7
7
|
let(:existing_configuration) do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
<<~YAML
|
9
|
+
---
|
10
|
+
detectors:
|
11
|
+
UncommunicativeMethodName:
|
12
|
+
exclude:
|
13
|
+
- Smelly#x
|
14
|
+
YAML
|
15
15
|
end
|
16
16
|
|
17
17
|
let(:smelly_file) do
|
18
|
-
|
18
|
+
<<~RUBY
|
19
19
|
# Smelly class
|
20
20
|
class Smelly
|
21
21
|
# This will reek of UncommunicativeMethodName
|
@@ -23,26 +23,26 @@ RSpec.describe Reek::CLI::Command::TodoListCommand do
|
|
23
23
|
y = 10 # This will reek of UncommunicativeVariableName
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
RUBY
|
27
27
|
end
|
28
28
|
|
29
29
|
let(:new_configuration_file) do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
<<~YAML
|
31
|
+
# Auto generated by Reeks --todo flag
|
32
|
+
---
|
33
|
+
detectors:
|
34
|
+
UncommunicativeMethodName:
|
35
|
+
exclude:
|
36
|
+
- Smelly#x
|
37
|
+
UncommunicativeVariableName:
|
38
|
+
exclude:
|
39
|
+
- Smelly#x
|
40
|
+
YAML
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#execute on smelly source' do
|
44
44
|
around do |example|
|
45
|
-
Dir.mktmpdir
|
45
|
+
Dir.mktmpdir do |tmp|
|
46
46
|
Dir.chdir(tmp) do
|
47
47
|
File.write SMELLY_FILE.basename, smelly_file
|
48
48
|
example.run
|
@@ -8,7 +8,7 @@ require_lib 'reek/configuration/excluded_paths'
|
|
8
8
|
RSpec.describe Reek::Configuration::AppConfiguration do
|
9
9
|
describe 'factory methods' do
|
10
10
|
around do |example|
|
11
|
-
Dir.mktmpdir
|
11
|
+
Dir.mktmpdir do |tmp|
|
12
12
|
Dir.chdir(tmp) do
|
13
13
|
example.run
|
14
14
|
end
|
@@ -32,30 +32,29 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
let(:expected_directory_directives) do
|
35
|
-
{ Pathname('directory_with_some_ruby_files') =>
|
36
|
-
|
35
|
+
{ Pathname('directory_with_some_ruby_files') => {
|
36
|
+
Reek::SmellDetectors::UtilityFunction => { 'enabled' => false }
|
37
|
+
} }
|
37
38
|
end
|
38
39
|
|
39
40
|
describe '#from_path' do
|
40
41
|
let(:configuration_path) { 'config.reek' }
|
41
42
|
let(:configuration) do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
enabled: false
|
47
|
-
|
48
|
-
directories:
|
49
|
-
"directory_with_some_ruby_files":
|
50
|
-
UtilityFunction:
|
43
|
+
<<~YAML
|
44
|
+
---
|
45
|
+
detectors:
|
46
|
+
IrresponsibleModule:
|
51
47
|
enabled: false
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
directories:
|
49
|
+
"directory_with_some_ruby_files":
|
50
|
+
UtilityFunction:
|
51
|
+
enabled: false
|
52
|
+
exclude_paths:
|
53
|
+
- "exclude_me.rb"
|
54
|
+
- "exclude_me_too.rb"
|
55
|
+
- "directory_with_trailing_slash/"
|
56
|
+
- "directory_without_trailing_slash"
|
57
|
+
YAML
|
59
58
|
end
|
60
59
|
|
61
60
|
before do
|
@@ -80,14 +79,17 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
80
79
|
end
|
81
80
|
|
82
81
|
let(:default_directive_value) do
|
83
|
-
{ Reek::DETECTORS_KEY =>
|
84
|
-
|
82
|
+
{ Reek::DETECTORS_KEY => {
|
83
|
+
'IrresponsibleModule' => { 'enabled' => false }
|
84
|
+
} }
|
85
85
|
end
|
86
86
|
|
87
87
|
let(:directory_directives_value) do
|
88
|
-
{ Reek::DIRECTORIES_KEY =>
|
89
|
-
|
90
|
-
|
88
|
+
{ Reek::DIRECTORIES_KEY => {
|
89
|
+
'directory_with_some_ruby_files' => {
|
90
|
+
'UtilityFunction' => { 'enabled' => false }
|
91
|
+
}
|
92
|
+
} }
|
91
93
|
end
|
92
94
|
|
93
95
|
let(:exclude_paths_value) do
|
@@ -128,11 +130,12 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
128
130
|
let(:expected_result) { { Reek::SmellDetectors::Attribute => { enabled: true } } }
|
129
131
|
|
130
132
|
let(:directory_directives) do
|
131
|
-
{
|
132
|
-
{
|
133
|
-
'samples/some_files'
|
133
|
+
{
|
134
|
+
Reek::DIRECTORIES_KEY => {
|
135
|
+
'samples/some_files' => bang_config,
|
134
136
|
'samples/other_files' => baz_config
|
135
|
-
}
|
137
|
+
}
|
138
|
+
}
|
136
139
|
end
|
137
140
|
|
138
141
|
it 'returns the corresponding directive' do
|
@@ -147,11 +150,12 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
147
150
|
|
148
151
|
let(:configuration_as_hash) do
|
149
152
|
{
|
150
|
-
Reek::DIRECTORIES_KEY =>
|
151
|
-
|
152
|
-
|
153
|
+
Reek::DIRECTORIES_KEY => {
|
154
|
+
directory => { TooManyStatements: { max_statements: 8 } }
|
155
|
+
},
|
156
|
+
Reek::DETECTORS_KEY => {
|
153
157
|
IrresponsibleModule: { enabled: false },
|
154
|
-
TooManyStatements:
|
158
|
+
TooManyStatements: { max_statements: 15 }
|
155
159
|
}
|
156
160
|
}
|
157
161
|
end
|
@@ -171,11 +175,12 @@ RSpec.describe Reek::Configuration::AppConfiguration do
|
|
171
175
|
|
172
176
|
let(:configuration_as_hash) do
|
173
177
|
{
|
174
|
-
Reek::DETECTORS_KEY
|
178
|
+
Reek::DETECTORS_KEY => {
|
175
179
|
IrresponsibleModule: { enabled: false }
|
176
180
|
},
|
177
|
-
Reek::DIRECTORIES_KEY =>
|
178
|
-
|
181
|
+
Reek::DIRECTORIES_KEY => {
|
182
|
+
'samples/other_files' => { Attribute: { enabled: false } }
|
183
|
+
}
|
179
184
|
}
|
180
185
|
end
|
181
186
|
|
@@ -33,12 +33,14 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'skips files ending in .reek.yml in current dir' do
|
36
|
-
|
36
|
+
skip_if_a_config_in_tempdir
|
37
|
+
|
38
|
+
Dir.mktmpdir do |tempdir|
|
37
39
|
current = Pathname.new(tempdir)
|
38
40
|
bad_config = current.join('ignoreme.reek.yml')
|
39
41
|
FileUtils.touch bad_config
|
40
|
-
found = described_class.find(current:
|
41
|
-
expect(found).to
|
42
|
+
found = described_class.find(current: current)
|
43
|
+
expect(found).to be_nil
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
@@ -128,15 +130,15 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
|
|
128
130
|
|
129
131
|
let(:expected) do
|
130
132
|
{
|
131
|
-
'UnusedPrivateMethod'
|
132
|
-
'UncommunicativeMethodName'
|
133
|
-
|
134
|
-
'UncommunicativeModuleName'
|
135
|
-
|
133
|
+
'UnusedPrivateMethod' => { 'exclude' => [/exclude regexp/] },
|
134
|
+
'UncommunicativeMethodName' => { 'reject' => ['reject name'],
|
135
|
+
'accept' => ['accept name'] },
|
136
|
+
'UncommunicativeModuleName' => { 'reject' => ['reject name 1', 'reject name 2'],
|
137
|
+
'accept' => ['accept name 1', 'accept name 2'] },
|
136
138
|
'UncommunicativeParameterName' => { 'reject' => ['reject name', /reject regexp/],
|
137
139
|
'accept' => ['accept name', /accept regexp/] },
|
138
|
-
'UncommunicativeVariableName'
|
139
|
-
|
140
|
+
'UncommunicativeVariableName' => { 'reject' => [/^reject regexp$/],
|
141
|
+
'accept' => [/accept(.*)regexp/] }
|
140
142
|
}
|
141
143
|
end
|
142
144
|
|
@@ -172,15 +174,15 @@ RSpec.describe Reek::Configuration::ConfigurationFileFinder do
|
|
172
174
|
let(:expected) do
|
173
175
|
{
|
174
176
|
directory_name => {
|
175
|
-
'UnusedPrivateMethod'
|
176
|
-
'UncommunicativeMethodName'
|
177
|
-
|
178
|
-
'UncommunicativeModuleName'
|
179
|
-
|
177
|
+
'UnusedPrivateMethod' => { 'exclude' => [/exclude regexp/] },
|
178
|
+
'UncommunicativeMethodName' => { 'reject' => ['reject name'],
|
179
|
+
'accept' => ['accept name'] },
|
180
|
+
'UncommunicativeModuleName' => { 'reject' => ['reject name 1', 'reject name 2'],
|
181
|
+
'accept' => ['accept name 1', 'accept name 2'] },
|
180
182
|
'UncommunicativeParameterName' => { 'reject' => ['reject name', /reject regexp/],
|
181
183
|
'accept' => ['accept name', /accept regexp/] },
|
182
|
-
'UncommunicativeVariableName'
|
183
|
-
|
184
|
+
'UncommunicativeVariableName' => { 'reject' => [/^reject regexp$/],
|
185
|
+
'accept' => [/accept(.*)regexp/] }
|
184
186
|
}
|
185
187
|
}
|
186
188
|
end
|
@@ -44,9 +44,9 @@ RSpec.describe Reek::Configuration::DirectoryDirectives do
|
|
44
44
|
describe '#best_match_for' do
|
45
45
|
let(:directives) do
|
46
46
|
{
|
47
|
-
Pathname.new('foo/bar/baz')
|
48
|
-
Pathname.new('foo/bar')
|
49
|
-
Pathname.new('bar/boo')
|
47
|
+
Pathname.new('foo/bar/baz') => {},
|
48
|
+
Pathname.new('foo/bar') => {},
|
49
|
+
Pathname.new('bar/boo') => {}
|
50
50
|
}.extend(described_class)
|
51
51
|
end
|
52
52
|
|
@@ -6,8 +6,8 @@ RSpec.describe Reek::Configuration::RakeTaskConverter do
|
|
6
6
|
let(:configuration_for_smell_detector) do
|
7
7
|
{
|
8
8
|
'exclude' => [/Klass#foobar$/, /^Klass#omg$/],
|
9
|
-
'reject'
|
10
|
-
'accept'
|
9
|
+
'reject' => [/^[a-z]$/, /[0-9]$/, /[A-Z]/],
|
10
|
+
'accept' => [/^_$/]
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
data/spec/reek/examiner_spec.rb
CHANGED
@@ -198,9 +198,9 @@ RSpec.describe Reek::Examiner do
|
|
198
198
|
context 'with a source that triggers a syntax error' do
|
199
199
|
let(:examiner) { described_class.new(source) }
|
200
200
|
let(:source) do
|
201
|
-
|
202
|
-
|
203
|
-
|
201
|
+
<<~RUBY
|
202
|
+
1 2 3
|
203
|
+
RUBY
|
204
204
|
end
|
205
205
|
|
206
206
|
it 'does not raise an error during initialization' do
|
@@ -225,10 +225,10 @@ RSpec.describe Reek::Examiner do
|
|
225
225
|
context 'with a source that triggers an encoding error' do
|
226
226
|
let(:examiner) { described_class.new(source) }
|
227
227
|
let(:source) do
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
228
|
+
<<~RUBY
|
229
|
+
# encoding: US-ASCII
|
230
|
+
puts 'こんにちは世界'
|
231
|
+
RUBY
|
232
232
|
end
|
233
233
|
|
234
234
|
it 'does not raise an error during initialization' do
|
@@ -26,29 +26,29 @@ RSpec.describe Reek::Report::CodeClimateReport do
|
|
26
26
|
let(:source) { 'def simple(a) a[3] end' }
|
27
27
|
|
28
28
|
it 'prints smells as json' do
|
29
|
-
expected =
|
30
|
-
{
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
expected = <<~HERE.delete("\n")
|
30
|
+
{"type":"issue",
|
31
|
+
"check_name":"UncommunicativeParameterName",
|
32
|
+
"description":"simple has the parameter name 'a'",
|
33
|
+
"categories":["Complexity"],
|
34
|
+
"location":{"path":"string","lines":{"begin":1,"end":1}},
|
35
|
+
"remediation_points":150000,
|
36
|
+
"content":{"body":"An `Uncommunicative Parameter Name` is a parameter name that
|
37
37
|
doesn't communicate its intent well enough.\\n\\nPoor names make it hard for the reader
|
38
38
|
to build a mental picture of what's going on in the code. They can also be
|
39
39
|
mis-interpreted; and they hurt the flow of reading, because the reader must slow down
|
40
|
-
to interpret the names.\\n
|
41
|
-
|
42
|
-
{
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
dependency on the state of the instance.\\n
|
50
|
-
|
51
|
-
|
40
|
+
to interpret the names.\\n"},
|
41
|
+
"fingerprint":"09970037d92b5a628bf682a3e2bb126d"}\u0000
|
42
|
+
{"type":"issue",
|
43
|
+
"check_name":"UtilityFunction",
|
44
|
+
"description":"simple doesn't depend on instance state (maybe move it to another class?)",
|
45
|
+
"categories":["Complexity"],
|
46
|
+
"location":{"path":"string","lines":{"begin":1,"end":1}},
|
47
|
+
"remediation_points":250000,
|
48
|
+
"content":{"body":"A _Utility Function_ is any instance method that has no
|
49
|
+
dependency on the state of the instance.\\n"},
|
50
|
+
"fingerprint":"db456db7cb344bb5a98b8fc54a2f382e"}\u0000
|
51
|
+
HERE
|
52
52
|
|
53
53
|
expect { instance.show }.to output(expected).to_stdout
|
54
54
|
end
|
@@ -30,7 +30,7 @@ RSpec.describe Reek::Report::YAMLReport do
|
|
30
30
|
instance.show(out)
|
31
31
|
out.rewind
|
32
32
|
result = YAML.safe_load(out.read)
|
33
|
-
expected = YAML.safe_load
|
33
|
+
expected = YAML.safe_load <<~YAML
|
34
34
|
---
|
35
35
|
- context: "simple"
|
36
36
|
lines:
|
@@ -47,7 +47,7 @@ RSpec.describe Reek::Report::YAMLReport do
|
|
47
47
|
smell_type: "UtilityFunction"
|
48
48
|
source: "string"
|
49
49
|
documentation_link: "https://github.com/troessner/reek/blob/v#{Reek::Version::STRING}/docs/Utility-Function.md"
|
50
|
-
|
50
|
+
YAML
|
51
51
|
|
52
52
|
expect(result).to eq expected
|
53
53
|
end
|
@@ -30,7 +30,7 @@ RSpec.describe Reek::SmellDetectors::UncommunicativeParameterName do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
{ 'alfa.' => 'with a receiver',
|
33
|
-
''
|
33
|
+
'' => 'without a receiver' }.each do |host, description|
|
34
34
|
context "in a method definition #{description}" do
|
35
35
|
it 'does not report two-letter parameter names' do
|
36
36
|
src = "def #{host}bravo(ab); charlie(ab); end"
|
@@ -103,14 +103,14 @@ RSpec.describe Reek::Spec::ShouldReekOf do
|
|
103
103
|
|
104
104
|
it 'sets the proper error message' do
|
105
105
|
matcher.matches?(smelly_code)
|
106
|
-
expected =
|
106
|
+
expected = <<~TEXT
|
107
107
|
Expected string to reek of DuplicateMethodCall (which it did) with smell details {:name=>"foo", :count=>15}, which it didn't.
|
108
108
|
The number of smell details I had to compare with the given one was 2 and here they are:
|
109
109
|
1.)
|
110
110
|
{"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls '@other.thing' 2 times", "source"=>"string", "name"=>"@other.thing", "count"=>2}
|
111
111
|
2.)
|
112
112
|
{"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls '@other.thing.foo' 2 times", "source"=>"string", "name"=>"@other.thing.foo", "count"=>2}
|
113
|
-
|
113
|
+
TEXT
|
114
114
|
|
115
115
|
expect(matcher.failure_message).to eq(expected)
|
116
116
|
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.3.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-12-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|
@@ -45,28 +45,42 @@ dependencies:
|
|
45
45
|
name: parser
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
|
-
- - "<"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '2.6'
|
51
48
|
- - ">="
|
52
49
|
- !ruby/object:Gem::Version
|
53
50
|
version: 2.5.0.0
|
54
51
|
- - "!="
|
55
52
|
- !ruby/object:Gem::Version
|
56
53
|
version: 2.5.1.1
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '2.6'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - "<"
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '2.6'
|
64
61
|
- - ">="
|
65
62
|
- !ruby/object:Gem::Version
|
66
63
|
version: 2.5.0.0
|
67
64
|
- - "!="
|
68
65
|
- !ruby/object:Gem::Version
|
69
66
|
version: 2.5.1.1
|
67
|
+
- - "<"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.6'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: psych
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.1.0
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 3.1.0
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: rainbow
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -487,8 +501,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
487
501
|
- !ruby/object:Gem::Version
|
488
502
|
version: '0'
|
489
503
|
requirements: []
|
490
|
-
|
491
|
-
rubygems_version: 2.5.2.3
|
504
|
+
rubygems_version: 3.0.1
|
492
505
|
signing_key:
|
493
506
|
specification_version: 4
|
494
507
|
summary: Code smell detector for Ruby
|