reek 5.0.2 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -70
- data/.rubocop_todo.yml +63 -0
- data/.simplecov +4 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +12 -17
- data/README.md +21 -29
- data/Rakefile +2 -2
- data/docs/templates/default/docstring/setup.rb +3 -0
- data/features/command_line_interface/options.feature +5 -3
- data/features/configuration_files/schema_validation.feature +3 -3
- data/features/configuration_files/show_configuration_file.feature +44 -0
- data/features/rake_task/rake_task.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/rspec_matcher.feature +1 -0
- data/features/step_definitions/sample_file_steps.rb +6 -8
- data/features/todo_list.feature +39 -26
- data/lib/reek.rb +7 -0
- data/lib/reek/ast/node.rb +4 -0
- data/lib/reek/ast/sexp_extensions/if.rb +20 -0
- data/lib/reek/ast/sexp_extensions/methods.rb +1 -0
- data/lib/reek/cli/application.rb +25 -0
- data/lib/reek/cli/command/todo_list_command.rb +17 -7
- data/lib/reek/cli/options.rb +21 -14
- data/lib/reek/code_comment.rb +2 -0
- data/lib/reek/configuration/app_configuration.rb +0 -3
- data/lib/reek/configuration/configuration_converter.rb +4 -4
- data/lib/reek/configuration/directory_directives.rb +1 -0
- data/lib/reek/configuration/schema_validator.rb +1 -0
- data/lib/reek/context/method_context.rb +1 -0
- data/lib/reek/context/module_context.rb +5 -4
- data/lib/reek/context/visibility_tracker.rb +7 -4
- data/lib/reek/context_builder.rb +1 -0
- data/lib/reek/detector_repository.rb +1 -0
- data/lib/reek/errors/incomprehensible_source_error.rb +2 -2
- data/lib/reek/errors/syntax_error.rb +4 -0
- data/lib/reek/examiner.rb +1 -0
- data/lib/reek/report/text_report.rb +1 -0
- data/lib/reek/smell_detectors/control_parameter.rb +13 -107
- data/lib/reek/smell_detectors/control_parameter_helpers/call_in_condition_finder.rb +91 -0
- data/lib/reek/smell_detectors/control_parameter_helpers/candidate.rb +38 -0
- data/lib/reek/smell_detectors/control_parameter_helpers/control_parameter_finder.rb +94 -0
- data/lib/reek/smell_detectors/duplicate_method_call.rb +1 -0
- data/lib/reek/smell_detectors/feature_envy.rb +2 -0
- data/lib/reek/smell_detectors/irresponsible_module.rb +1 -0
- data/lib/reek/smell_detectors/long_parameter_list.rb +1 -0
- data/lib/reek/smell_detectors/manual_dispatch.rb +1 -0
- data/lib/reek/smell_detectors/missing_safe_method.rb +1 -0
- data/lib/reek/smell_detectors/nested_iterators.rb +1 -0
- data/lib/reek/smell_detectors/repeated_conditional.rb +1 -0
- data/lib/reek/smell_detectors/too_many_instance_variables.rb +1 -0
- data/lib/reek/smell_detectors/too_many_methods.rb +1 -0
- data/lib/reek/smell_detectors/too_many_statements.rb +1 -0
- data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +2 -0
- data/lib/reek/smell_detectors/unused_parameters.rb +1 -0
- data/lib/reek/source/source_locator.rb +1 -0
- data/lib/reek/spec/should_reek_of.rb +2 -2
- data/lib/reek/spec/should_reek_only_of.rb +1 -0
- data/lib/reek/spec/smell_matcher.rb +1 -0
- data/lib/reek/tree_dresser.rb +1 -0
- data/lib/reek/version.rb +1 -1
- data/samples/smelly_source/ruby.rb +368 -0
- data/spec/factories/factories.rb +10 -9
- data/spec/performance/reek/smell_detectors/runtime_speed_spec.rb +17 -0
- data/spec/quality/documentation_spec.rb +40 -0
- data/spec/reek/ast/sexp_extensions_spec.rb +20 -20
- data/spec/reek/cli/application_spec.rb +29 -0
- data/spec/reek/cli/command/todo_list_command_spec.rb +64 -46
- data/spec/reek/configuration/app_configuration_spec.rb +8 -8
- data/spec/reek/configuration/configuration_file_finder_spec.rb +3 -3
- data/spec/reek/configuration/schema_validator_spec.rb +10 -10
- data/spec/reek/detector_repository_spec.rb +2 -2
- data/spec/reek/smell_detectors/control_parameter_spec.rb +17 -0
- data/spec/reek/source/source_locator_spec.rb +0 -2
- data/spec/spec_helper.rb +2 -0
- data/tasks/configuration.rake +2 -1
- data/tasks/test.rake +4 -0
- metadata +11 -5
- data/ataru_setup.rb +0 -13
- data/tasks/ataru.rake +0 -5
@@ -9,7 +9,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
9
9
|
context 'when configuration is valid' do
|
10
10
|
let(:configuration) do
|
11
11
|
{
|
12
|
-
Reek::
|
12
|
+
Reek::DETECTORS_KEY => {
|
13
13
|
'UncommunicativeVariableName' => { 'enabled' => false },
|
14
14
|
'UncommunicativeMethodName' => { 'enabled' => false }
|
15
15
|
}
|
@@ -24,7 +24,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
24
24
|
context 'when detector is invalid' do
|
25
25
|
let(:configuration) do
|
26
26
|
{
|
27
|
-
Reek::
|
27
|
+
Reek::DETECTORS_KEY => {
|
28
28
|
'DoesNotExist' => { 'enabled' => false }
|
29
29
|
}
|
30
30
|
}
|
@@ -39,7 +39,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
39
39
|
context 'when `enabled` has a non-boolean value' do
|
40
40
|
let(:configuration) do
|
41
41
|
{
|
42
|
-
Reek::
|
42
|
+
Reek::DETECTORS_KEY => {
|
43
43
|
'FeatureEnvy' => { 'enabled' => 'foo' }
|
44
44
|
}
|
45
45
|
}
|
@@ -54,7 +54,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
54
54
|
context 'when detector has an unknown option' do
|
55
55
|
let(:configuration) do
|
56
56
|
{
|
57
|
-
Reek::
|
57
|
+
Reek::DETECTORS_KEY => {
|
58
58
|
'DataClump' => { 'does_not_exist' => 42 }
|
59
59
|
}
|
60
60
|
}
|
@@ -71,7 +71,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
71
71
|
context 'when a scalar' do
|
72
72
|
let(:configuration) do
|
73
73
|
{
|
74
|
-
Reek::
|
74
|
+
Reek::DETECTORS_KEY => {
|
75
75
|
'UncommunicativeMethodName' => { attribute => 42 }
|
76
76
|
}
|
77
77
|
}
|
@@ -86,7 +86,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
86
86
|
context 'when types are mixed' do
|
87
87
|
let(:configuration) do
|
88
88
|
{
|
89
|
-
Reek::
|
89
|
+
Reek::DETECTORS_KEY => {
|
90
90
|
'UncommunicativeMethodName' => { attribute => [42, 'foo'] }
|
91
91
|
}
|
92
92
|
}
|
@@ -103,7 +103,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
103
103
|
context 'when `exclude_paths` is a scalar' do
|
104
104
|
let(:configuration) do
|
105
105
|
{
|
106
|
-
Reek::
|
106
|
+
Reek::EXCLUDE_PATHS_KEY => 42
|
107
107
|
}
|
108
108
|
end
|
109
109
|
|
@@ -116,7 +116,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
116
116
|
context 'when `exclude_paths` mixes types' do
|
117
117
|
let(:configuration) do
|
118
118
|
{
|
119
|
-
Reek::
|
119
|
+
Reek::EXCLUDE_PATHS_KEY => [42, 'foo']
|
120
120
|
}
|
121
121
|
end
|
122
122
|
|
@@ -130,7 +130,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
130
130
|
context 'when bad detector' do
|
131
131
|
let(:configuration) do
|
132
132
|
{
|
133
|
-
Reek::
|
133
|
+
Reek::DIRECTORIES_KEY => {
|
134
134
|
'web_app/app/helpers' => {
|
135
135
|
'Bar' => { 'enabled' => false }
|
136
136
|
}
|
@@ -147,7 +147,7 @@ RSpec.describe Reek::Configuration::SchemaValidator do
|
|
147
147
|
context 'when unknown attribute' do
|
148
148
|
let(:configuration) do
|
149
149
|
{
|
150
|
-
Reek::
|
150
|
+
Reek::DIRECTORIES_KEY => {
|
151
151
|
'web_app/app/controllers' => {
|
152
152
|
'NestedIterators' => { 'foo' => false }
|
153
153
|
}
|
@@ -7,8 +7,8 @@ RSpec.describe Reek::DetectorRepository do
|
|
7
7
|
let(:smell_types) { described_class.smell_types }
|
8
8
|
|
9
9
|
it 'includes existing smell_types' do
|
10
|
-
expect(smell_types).to include(Reek::SmellDetectors::IrresponsibleModule
|
11
|
-
|
10
|
+
expect(smell_types).to include(Reek::SmellDetectors::IrresponsibleModule,
|
11
|
+
Reek::SmellDetectors::TooManyStatements)
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'excludes the smell detector base class' do
|
@@ -30,6 +30,23 @@ RSpec.describe Reek::SmellDetectors::ControlParameter do
|
|
30
30
|
and reek_of(:ControlParameter, lines: [3], argument: 'charlie')
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'does count multiple occurences of the same parameter' do
|
34
|
+
src = <<-EOS
|
35
|
+
def alfa(bravo, charlie)
|
36
|
+
if bravo
|
37
|
+
delta if charlie
|
38
|
+
end
|
39
|
+
if charlie
|
40
|
+
delta if bravo
|
41
|
+
end
|
42
|
+
end
|
43
|
+
EOS
|
44
|
+
|
45
|
+
expect(src).
|
46
|
+
to reek_of(:ControlParameter, lines: [2, 6], argument: 'bravo').
|
47
|
+
and reek_of(:ControlParameter, lines: [3, 5], argument: 'charlie')
|
48
|
+
end
|
49
|
+
|
33
50
|
context 'when a parameter is not used to determine code path' do
|
34
51
|
it 'does not report a ternary check on an ivar' do
|
35
52
|
src = 'def alfa(bravo) @charlie ? bravo : false end'
|
@@ -29,7 +29,6 @@ RSpec.describe Reek::Source::SourceLocator do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
# rubocop:disable RSpec/NestedGroups
|
33
32
|
context 'with excluded paths' do
|
34
33
|
let(:configuration) do
|
35
34
|
test_configuration_for(CONFIGURATION_DIR.join('with_excluded_paths.reek'))
|
@@ -118,7 +117,6 @@ RSpec.describe Reek::Source::SourceLocator do
|
|
118
117
|
end
|
119
118
|
end
|
120
119
|
end
|
121
|
-
# rubocop:enable RSpec/NestedGroups
|
122
120
|
|
123
121
|
context 'with non-Ruby paths' do
|
124
122
|
let(:path) { SAMPLES_DIR.join('source_with_non_ruby_files') }
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'timeout'
|
3
3
|
require 'active_support/core_ext/string/strip'
|
4
|
+
require 'rspec-benchmark'
|
4
5
|
require_relative '../lib/reek'
|
5
6
|
require_relative '../lib/reek/spec'
|
6
7
|
require_relative '../lib/reek/ast/ast_node_class_map'
|
@@ -76,6 +77,7 @@ RSpec.configure do |config|
|
|
76
77
|
config.run_all_when_everything_filtered = true
|
77
78
|
config.include FactoryBot::Syntax::Methods
|
78
79
|
config.include Helpers
|
80
|
+
config.include RSpec::Benchmark::Matchers
|
79
81
|
|
80
82
|
config.disable_monkey_patching!
|
81
83
|
|
data/tasks/configuration.rake
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative '../lib/reek'
|
1
2
|
require_relative '../lib/reek/detector_repository'
|
2
3
|
require_relative '../lib/reek/configuration/rake_task_converter'
|
3
4
|
require_relative '../lib/reek/configuration/app_configuration'
|
@@ -12,7 +13,7 @@ namespace :configuration do
|
|
12
13
|
hash[klass.smell_type] = Reek::Configuration::RakeTaskConverter.convert klass.default_config
|
13
14
|
end
|
14
15
|
File.open(DEFAULT_SMELL_CONFIGURATION, 'w') do |file|
|
15
|
-
YAML.dump({ Reek::
|
16
|
+
YAML.dump({ Reek::DETECTORS_KEY => content }, file)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
data/tasks/test.rake
CHANGED
@@ -7,6 +7,10 @@ namespace 'test' do
|
|
7
7
|
t.ruby_opts = ['-rbundler/setup -rsimplecov -Ilib -w']
|
8
8
|
end
|
9
9
|
|
10
|
+
RSpec::Core::RakeTask.new('performance') do |t|
|
11
|
+
t.pattern = 'spec/performance/**/*_spec.rb'
|
12
|
+
end
|
13
|
+
|
10
14
|
desc 'Tests code quality'
|
11
15
|
RSpec::Core::RakeTask.new('quality') do |t|
|
12
16
|
t.pattern = 'spec/quality/**/*_spec.rb'
|
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.0
|
4
|
+
version: 5.1.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-09-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: codeclimate-engine-rb
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- ".gitignore"
|
104
104
|
- ".reek.yml"
|
105
105
|
- ".rubocop.yml"
|
106
|
+
- ".rubocop_todo.yml"
|
106
107
|
- ".simplecov"
|
107
108
|
- ".travis.yml"
|
108
109
|
- ".yardopts"
|
@@ -113,7 +114,6 @@ files:
|
|
113
114
|
- License.txt
|
114
115
|
- README.md
|
115
116
|
- Rakefile
|
116
|
-
- ataru_setup.rb
|
117
117
|
- bin/code_climate_reek
|
118
118
|
- bin/reek
|
119
119
|
- docs/API.md
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- features/configuration_files/mix_accept_reject_setting.feature
|
184
184
|
- features/configuration_files/reject_setting.feature
|
185
185
|
- features/configuration_files/schema_validation.feature
|
186
|
+
- features/configuration_files/show_configuration_file.feature
|
186
187
|
- features/configuration_files/unused_private_method.feature
|
187
188
|
- features/configuration_loading.feature
|
188
189
|
- features/configuration_via_source_comments/erroneous_source_comments.feature
|
@@ -298,6 +299,9 @@ files:
|
|
298
299
|
- lib/reek/smell_detectors/boolean_parameter.rb
|
299
300
|
- lib/reek/smell_detectors/class_variable.rb
|
300
301
|
- lib/reek/smell_detectors/control_parameter.rb
|
302
|
+
- lib/reek/smell_detectors/control_parameter_helpers/call_in_condition_finder.rb
|
303
|
+
- lib/reek/smell_detectors/control_parameter_helpers/candidate.rb
|
304
|
+
- lib/reek/smell_detectors/control_parameter_helpers/control_parameter_finder.rb
|
301
305
|
- lib/reek/smell_detectors/data_clump.rb
|
302
306
|
- lib/reek/smell_detectors/duplicate_method_call.rb
|
303
307
|
- lib/reek/smell_detectors/feature_envy.rb
|
@@ -358,6 +362,7 @@ files:
|
|
358
362
|
- samples/smelly_source/inline.rb
|
359
363
|
- samples/smelly_source/optparse.rb
|
360
364
|
- samples/smelly_source/redcloth.rb
|
365
|
+
- samples/smelly_source/ruby.rb
|
361
366
|
- samples/smelly_source/smelly.rb
|
362
367
|
- samples/source_with_exclude_paths/ignore_me/uncommunicative_method_name.rb
|
363
368
|
- samples/source_with_exclude_paths/nested/ignore_me_as_well/irresponsible_module.rb
|
@@ -368,6 +373,8 @@ files:
|
|
368
373
|
- samples/source_with_non_ruby_files/python_source.py
|
369
374
|
- samples/source_with_non_ruby_files/ruby.rb
|
370
375
|
- spec/factories/factories.rb
|
376
|
+
- spec/performance/reek/smell_detectors/runtime_speed_spec.rb
|
377
|
+
- spec/quality/documentation_spec.rb
|
371
378
|
- spec/quality/reek_source_spec.rb
|
372
379
|
- spec/reek/ast/node_spec.rb
|
373
380
|
- spec/reek/ast/object_refs_spec.rb
|
@@ -451,7 +458,6 @@ files:
|
|
451
458
|
- spec/reek/spec/smell_matcher_spec.rb
|
452
459
|
- spec/reek/tree_dresser_spec.rb
|
453
460
|
- spec/spec_helper.rb
|
454
|
-
- tasks/ataru.rake
|
455
461
|
- tasks/configuration.rake
|
456
462
|
- tasks/console.rake
|
457
463
|
- tasks/reek.rake
|
@@ -481,7 +487,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
481
487
|
version: '0'
|
482
488
|
requirements: []
|
483
489
|
rubyforge_project:
|
484
|
-
rubygems_version: 2.5.2.
|
490
|
+
rubygems_version: 2.5.2.3
|
485
491
|
signing_key:
|
486
492
|
specification_version: 4
|
487
493
|
summary: Code smell detector for Ruby
|
data/ataru_setup.rb
DELETED