reek 4.7.2 → 4.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +18 -4
  3. data/.travis.yml +0 -5
  4. data/CHANGELOG.md +8 -0
  5. data/CONTRIBUTING.md +1 -1
  6. data/Gemfile +4 -4
  7. data/docs/How-To-Write-New-Detectors.md +6 -5
  8. data/docs/Unused-Private-Method.md +1 -1
  9. data/features/configuration_via_source_comments/erroneous_source_comments.feature +1 -1
  10. data/features/locales.feature +32 -0
  11. data/features/rake_task/rake_task.feature +46 -6
  12. data/features/rspec_matcher.feature +32 -0
  13. data/features/step_definitions/reek_steps.rb +0 -4
  14. data/features/support/env.rb +0 -9
  15. data/lib/reek/ast/builder.rb +1 -1
  16. data/lib/reek/ast/sexp_extensions/send.rb +0 -4
  17. data/lib/reek/cli/options.rb +2 -2
  18. data/lib/reek/configuration/app_configuration.rb +3 -2
  19. data/lib/reek/configuration/configuration_file_finder.rb +3 -3
  20. data/lib/reek/context/ghost_context.rb +0 -2
  21. data/lib/reek/context/module_context.rb +0 -3
  22. data/lib/reek/context_builder.rb +2 -4
  23. data/lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb +2 -2
  24. data/lib/reek/errors/bad_detector_in_comment_error.rb +2 -2
  25. data/lib/reek/errors/encoding_error.rb +38 -0
  26. data/lib/reek/errors/garbage_detector_configuration_in_comment_error.rb +3 -3
  27. data/lib/reek/errors/incomprehensible_source_error.rb +4 -4
  28. data/lib/reek/examiner.rb +15 -11
  29. data/lib/reek/rake/task.rb +5 -1
  30. data/lib/reek/smell_detectors/attribute.rb +6 -11
  31. data/lib/reek/smell_detectors/base_detector.rb +9 -1
  32. data/lib/reek/smell_detectors/boolean_parameter.rb +4 -5
  33. data/lib/reek/smell_detectors/class_variable.rb +5 -6
  34. data/lib/reek/smell_detectors/control_parameter.rb +3 -3
  35. data/lib/reek/smell_detectors/data_clump.rb +13 -6
  36. data/lib/reek/smell_detectors/duplicate_method_call.rb +18 -11
  37. data/lib/reek/smell_detectors/feature_envy.rb +9 -7
  38. data/lib/reek/smell_detectors/instance_variable_assumption.rb +14 -14
  39. data/lib/reek/smell_detectors/irresponsible_module.rb +6 -12
  40. data/lib/reek/smell_detectors/long_parameter_list.rb +10 -6
  41. data/lib/reek/smell_detectors/long_yield_list.rb +9 -5
  42. data/lib/reek/smell_detectors/manual_dispatch.rb +3 -4
  43. data/lib/reek/smell_detectors/module_initialize.rb +4 -5
  44. data/lib/reek/smell_detectors/nested_iterators.rb +11 -19
  45. data/lib/reek/smell_detectors/nil_check.rb +9 -15
  46. data/lib/reek/smell_detectors/prima_donna_method.rb +17 -16
  47. data/lib/reek/smell_detectors/repeated_conditional.rb +11 -8
  48. data/lib/reek/smell_detectors/subclassed_from_core_class.rb +8 -8
  49. data/lib/reek/smell_detectors/too_many_constants.rb +10 -8
  50. data/lib/reek/smell_detectors/too_many_instance_variables.rb +10 -5
  51. data/lib/reek/smell_detectors/too_many_methods.rb +11 -6
  52. data/lib/reek/smell_detectors/too_many_statements.rb +10 -5
  53. data/lib/reek/smell_detectors/uncommunicative_method_name.rb +8 -8
  54. data/lib/reek/smell_detectors/uncommunicative_module_name.rb +12 -15
  55. data/lib/reek/smell_detectors/uncommunicative_parameter_name.rb +10 -13
  56. data/lib/reek/smell_detectors/uncommunicative_variable_name.rb +23 -23
  57. data/lib/reek/smell_detectors/unused_parameters.rb +5 -6
  58. data/lib/reek/smell_detectors/unused_private_method.rb +11 -18
  59. data/lib/reek/smell_detectors/utility_function.rb +12 -15
  60. data/lib/reek/source/source_code.rb +27 -6
  61. data/lib/reek/source/source_locator.rb +1 -1
  62. data/lib/reek/spec.rb +1 -1
  63. data/lib/reek/version.rb +1 -1
  64. data/reek.gemspec +0 -2
  65. data/spec/reek/ast/sexp_extensions_spec.rb +12 -32
  66. data/spec/reek/cli/application_spec.rb +4 -6
  67. data/spec/reek/configuration/configuration_file_finder_spec.rb +0 -2
  68. data/spec/reek/examiner_spec.rb +38 -1
  69. data/spec/reek/rake/task_spec.rb +25 -2
  70. data/spec/reek/smell_detectors/base_detector_spec.rb +4 -5
  71. data/spec/reek/smell_detectors/prima_donna_method_spec.rb +3 -3
  72. data/spec/reek/source/source_code_spec.rb +28 -1
  73. data/spec/reek/spec/should_reek_of_spec.rb +18 -18
  74. data/spec/reek/spec/should_reek_spec.rb +5 -5
  75. data/spec/reek/spec/smell_matcher_spec.rb +20 -20
  76. data/spec/spec_helper.rb +1 -1
  77. metadata +6 -3
@@ -8,11 +8,11 @@ RSpec.describe Reek::Spec::ShouldReek do
8
8
  let(:smelly_code) { 'def x() y = 4; end' }
9
9
 
10
10
  it 'matches a smelly String' do
11
- expect(matcher.matches?(smelly_code)).to be_truthy
11
+ expect(matcher).to be_matches(smelly_code)
12
12
  end
13
13
 
14
14
  it 'doesnt match a fragrant String' do
15
- expect(matcher.matches?(clean_code)).to be_falsey
15
+ expect(matcher).not_to be_matches(clean_code)
16
16
  end
17
17
 
18
18
  it 'reports the smells when should_not fails' do
@@ -26,11 +26,11 @@ RSpec.describe Reek::Spec::ShouldReek do
26
26
  let(:matcher) { described_class.new }
27
27
 
28
28
  it 'matches a smelly File' do
29
- expect(matcher.matches?(SMELLY_FILE)).to be_truthy
29
+ expect(matcher).to be_matches(SMELLY_FILE)
30
30
  end
31
31
 
32
32
  it 'doesnt match a fragrant File' do
33
- expect(matcher.matches?(CLEAN_FILE)).to be_falsey
33
+ expect(matcher).not_to be_matches(CLEAN_FILE)
34
34
  end
35
35
 
36
36
  it 'reports the smells when should_not fails' do
@@ -45,7 +45,7 @@ RSpec.describe Reek::Spec::ShouldReek do
45
45
  let(:matcher) { described_class.new(configuration: configuration) }
46
46
 
47
47
  it 'masks smells using the relevant configuration' do
48
- expect(matcher.matches?(SMELLY_FILE)).to be_falsey
48
+ expect(matcher).not_to be_matches(SMELLY_FILE)
49
49
  end
50
50
  end
51
51
  end
@@ -12,33 +12,33 @@ RSpec.describe Reek::Spec::SmellMatcher do
12
12
 
13
13
  context '#matches?' do
14
14
  it 'matches on class symbol' do
15
- expect(matcher.matches?(:UncommunicativeVariableName)).to be_truthy
15
+ expect(matcher).to be_matches(:UncommunicativeVariableName)
16
16
  end
17
17
 
18
18
  it 'matches on class symbol and params' do
19
- expect(matcher.matches?(:UncommunicativeVariableName,
20
- test: 'something')).to be_truthy
19
+ expect(matcher).to be_matches(:UncommunicativeVariableName,
20
+ test: 'something')
21
21
  end
22
22
 
23
23
  it 'matches on class symbol, params and attributes' do
24
- expect(matcher.matches?(:UncommunicativeVariableName,
25
- test: 'something',
26
- message: "has the variable name '@s'")).to be_truthy
24
+ expect(matcher).to be_matches(:UncommunicativeVariableName,
25
+ test: 'something',
26
+ message: "has the variable name '@s'")
27
27
  end
28
28
 
29
29
  it 'does not match on different class symbol' do
30
- expect(matcher.matches?(:FeatureEnvy)).to be_falsy
30
+ expect(matcher).not_to be_matches(:FeatureEnvy)
31
31
  end
32
32
 
33
33
  it 'does not match on different params' do
34
- expect(matcher.matches?(:UncommunicativeVariableName,
35
- test: 'something else')).to be_falsy
34
+ expect(matcher).not_to be_matches(:UncommunicativeVariableName,
35
+ test: 'something else')
36
36
  end
37
37
 
38
38
  it 'does not match on different attributes' do
39
- expect(matcher.matches?(:UncommunicativeVariableName,
40
- test: 'something',
41
- message: 'nothing')).to be_falsy
39
+ expect(matcher).not_to be_matches(:UncommunicativeVariableName,
40
+ test: 'something',
41
+ message: 'nothing')
42
42
  end
43
43
 
44
44
  it 'raises error on uncomparable attribute' do
@@ -52,31 +52,31 @@ RSpec.describe Reek::Spec::SmellMatcher do
52
52
 
53
53
  context '#matches_smell_type?' do
54
54
  it 'matches on class symbol' do
55
- expect(matcher.matches_smell_type?(:UncommunicativeVariableName)).to be_truthy
55
+ expect(matcher).to be_matches_smell_type(:UncommunicativeVariableName)
56
56
  end
57
57
 
58
58
  it 'does not match on different class symbol' do
59
- expect(matcher.matches_smell_type?(:FeatureEnvy)).to be_falsy
59
+ expect(matcher).not_to be_matches_smell_type(:FeatureEnvy)
60
60
  end
61
61
  end
62
62
 
63
63
  context '#matches_attributes?' do
64
64
  it 'matches on params' do
65
- expect(matcher.matches_attributes?(test: 'something')).to be_truthy
65
+ expect(matcher).to be_matches_attributes(test: 'something')
66
66
  end
67
67
 
68
68
  it 'matches on class symbol, params and attributes' do
69
- expect(matcher.matches_attributes?(test: 'something',
70
- message: "has the variable name '@s'")).to be_truthy
69
+ expect(matcher).to be_matches_attributes(test: 'something',
70
+ message: "has the variable name '@s'")
71
71
  end
72
72
 
73
73
  it 'does not match on different params' do
74
- expect(matcher.matches_attributes?(test: 'something else')).to be_falsy
74
+ expect(matcher).not_to be_matches_attributes(test: 'something else')
75
75
  end
76
76
 
77
77
  it 'does not match on different attributes' do
78
- expect(matcher.matches_attributes?(test: 'something',
79
- message: 'nothing')).to be_falsy
78
+ expect(matcher).not_to be_matches_attributes(test: 'something',
79
+ message: 'nothing')
80
80
  end
81
81
 
82
82
  it 'raises error on uncomparable attribute' do
@@ -90,7 +90,7 @@ RSpec.configure do |config|
90
90
  # mutation tester. Set the DEBUG environment variable to something truthy
91
91
  # like '1' to disable this and allow using pry without specs failing.
92
92
  unless ENV['DEBUG']
93
- config.around(:each) do |example|
93
+ config.around do |example|
94
94
  Timeout.timeout(5, &example)
95
95
  end
96
96
  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: 4.7.2
4
+ version: 4.7.3
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: 2017-07-24 00:00:00.000000000 Z
14
+ date: 2017-11-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -160,12 +160,14 @@ files:
160
160
  - features/configuration_loading.feature
161
161
  - features/configuration_via_source_comments/erroneous_source_comments.feature
162
162
  - features/configuration_via_source_comments/well_formed_source_comments.feature
163
+ - features/locales.feature
163
164
  - features/programmatic_access.feature
164
165
  - features/rake_task/rake_task.feature
165
166
  - features/reports/codeclimate.feature
166
167
  - features/reports/json.feature
167
168
  - features/reports/reports.feature
168
169
  - features/reports/yaml.feature
170
+ - features/rspec_matcher.feature
169
171
  - features/samples.feature
170
172
  - features/step_definitions/.rubocop.yml
171
173
  - features/step_definitions/reek_steps.rb
@@ -230,6 +232,7 @@ files:
230
232
  - lib/reek/errors/bad_detector_configuration_key_in_comment_error.rb
231
233
  - lib/reek/errors/bad_detector_in_comment_error.rb
232
234
  - lib/reek/errors/base_error.rb
235
+ - lib/reek/errors/encoding_error.rb
233
236
  - lib/reek/errors/garbage_detector_configuration_in_comment_error.rb
234
237
  - lib/reek/errors/incomprehensible_source_error.rb
235
238
  - lib/reek/examiner.rb
@@ -443,7 +446,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
443
446
  version: '0'
444
447
  requirements: []
445
448
  rubyforge_project:
446
- rubygems_version: 2.6.12
449
+ rubygems_version: 2.6.13
447
450
  signing_key:
448
451
  specification_version: 4
449
452
  summary: Code smell detector for Ruby