reek 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/CONTRIBUTING.md +41 -4
  4. data/README.md +15 -3
  5. data/defaults.reek +1 -1
  6. data/docs/Basic-Smell-Options.md +2 -2
  7. data/docs/Code-Smells.md +4 -0
  8. data/docs/How-To-Write-New-Detectors.md +116 -0
  9. data/docs/How-reek-works-internally.md +3 -4
  10. data/docs/Instance-Variable-Assumption.md +134 -0
  11. data/docs/Simulated-Polymorphism.md +1 -1
  12. data/docs/Smell-Suppression.md +6 -6
  13. data/docs/{style-guide.md → Style-Guide.md} +0 -0
  14. data/docs/Unused-Private-Method.md +1 -1
  15. data/docs/YAML-Reports.md +0 -18
  16. data/features/configuration_files/directory_specific_directives.feature +4 -4
  17. data/features/configuration_files/unused_private_method.feature +2 -2
  18. data/features/samples.feature +122 -117
  19. data/features/smells/subclassed_from_core_class.feature +1 -1
  20. data/lib/reek/code_comment.rb +13 -4
  21. data/lib/reek/context/code_context.rb +1 -0
  22. data/lib/reek/examiner.rb +24 -27
  23. data/lib/reek/smells/class_variable.rb +1 -1
  24. data/lib/reek/smells/control_parameter.rb +1 -1
  25. data/lib/reek/smells/data_clump.rb +1 -1
  26. data/lib/reek/smells/duplicate_method_call.rb +1 -1
  27. data/lib/reek/smells/feature_envy.rb +1 -1
  28. data/lib/reek/smells/instance_variable_assumption.rb +1 -1
  29. data/lib/reek/smells/prima_donna_method.rb +1 -1
  30. data/lib/reek/smells/repeated_conditional.rb +1 -1
  31. data/lib/reek/smells/smell_detector.rb +5 -14
  32. data/lib/reek/smells/smell_repository.rb +1 -5
  33. data/lib/reek/smells/smell_warning.rb +6 -8
  34. data/lib/reek/smells/subclassed_from_core_class.rb +1 -1
  35. data/lib/reek/smells/uncommunicative_variable_name.rb +22 -12
  36. data/lib/reek/smells/unused_private_method.rb +1 -1
  37. data/lib/reek/spec.rb +2 -2
  38. data/lib/reek/spec/should_reek_of.rb +12 -8
  39. data/lib/reek/version.rb +1 -1
  40. data/spec/reek/code_comment_spec.rb +13 -5
  41. data/spec/reek/examiner_spec.rb +2 -2
  42. data/spec/reek/smells/attribute_spec.rb +91 -78
  43. data/spec/reek/smells/boolean_parameter_spec.rb +72 -64
  44. data/spec/reek/smells/class_variable_spec.rb +81 -68
  45. data/spec/reek/smells/control_parameter_spec.rb +101 -141
  46. data/spec/reek/smells/data_clump_spec.rb +94 -149
  47. data/spec/reek/smells/duplicate_method_call_spec.rb +98 -85
  48. data/spec/reek/smells/feature_envy_spec.rb +164 -183
  49. data/spec/reek/smells/instance_variable_assumption_spec.rb +51 -147
  50. data/spec/reek/smells/irresponsible_module_spec.rb +153 -170
  51. data/spec/reek/smells/long_parameter_list_spec.rb +44 -88
  52. data/spec/reek/smells/long_yield_list_spec.rb +41 -41
  53. data/spec/reek/smells/manual_dispatch_spec.rb +36 -18
  54. data/spec/reek/smells/module_initialize_spec.rb +31 -33
  55. data/spec/reek/smells/nested_iterators_spec.rb +189 -183
  56. data/spec/reek/smells/nil_check_spec.rb +48 -37
  57. data/spec/reek/smells/prima_donna_method_spec.rb +41 -26
  58. data/spec/reek/smells/repeated_conditional_spec.rb +75 -87
  59. data/spec/reek/smells/smell_warning_spec.rb +7 -0
  60. data/spec/reek/smells/subclassed_from_core_class_spec.rb +37 -112
  61. data/spec/reek/smells/too_many_constants_spec.rb +109 -199
  62. data/spec/reek/smells/too_many_instance_variables_spec.rb +105 -128
  63. data/spec/reek/smells/too_many_methods_spec.rb +38 -62
  64. data/spec/reek/smells/too_many_statements_spec.rb +69 -45
  65. data/spec/reek/smells/uncommunicative_method_name_spec.rb +16 -29
  66. data/spec/reek/smells/uncommunicative_module_name_spec.rb +24 -37
  67. data/spec/reek/smells/uncommunicative_parameter_name_spec.rb +55 -60
  68. data/spec/reek/smells/uncommunicative_variable_name_spec.rb +108 -95
  69. data/spec/reek/smells/unused_parameters_spec.rb +73 -49
  70. data/spec/reek/smells/unused_private_method_spec.rb +97 -50
  71. data/spec/reek/smells/utility_function_spec.rb +130 -188
  72. data/spec/reek/spec/should_reek_of_spec.rb +2 -2
  73. metadata +6 -7
  74. data/lib/reek/cli/warning_collector.rb +0 -27
  75. data/spec/reek/cli/warning_collector_spec.rb +0 -25
  76. data/spec/reek/smells/smell_detector_shared.rb +0 -29
@@ -112,9 +112,9 @@ RSpec.describe Reek::Spec::ShouldReekOf do
112
112
  Expected string to reek of DuplicateMethodCall (which it did) with smell details {:name=>"foo", :count=>15}, which it didn't.
113
113
  The number of smell details I had to compare with the given one was 2 and here they are:
114
114
  1.)
115
- {"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls @other.thing 2 times", "source"=>"string", "name"=>"@other.thing", "count"=>2}
115
+ {"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls '@other.thing' 2 times", "source"=>"string", "name"=>"@other.thing", "count"=>2}
116
116
  2.)
117
- {"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls @other.thing.foo 2 times", "source"=>"string", "name"=>"@other.thing.foo", "count"=>2}
117
+ {"context"=>"double_thing", "lines"=>[1, 1], "message"=>"calls '@other.thing.foo' 2 times", "source"=>"string", "name"=>"@other.thing.foo", "count"=>2}
118
118
  EOS
119
119
 
120
120
  expect(matcher.failure_message).to eq(expected)
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.4.0
4
+ version: 4.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: 2016-08-24 00:00:00.000000000 Z
14
+ date: 2016-09-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -103,7 +103,9 @@ files:
103
103
  - docs/Data-Clump.md
104
104
  - docs/Duplicate-Method-Call.md
105
105
  - docs/Feature-Envy.md
106
+ - docs/How-To-Write-New-Detectors.md
106
107
  - docs/How-reek-works-internally.md
108
+ - docs/Instance-Variable-Assumption.md
107
109
  - docs/Irresponsible-Module.md
108
110
  - docs/Large-Class.md
109
111
  - docs/Long-Parameter-List.md
@@ -119,6 +121,7 @@ files:
119
121
  - docs/Repeated-Conditional.md
120
122
  - docs/Simulated-Polymorphism.md
121
123
  - docs/Smell-Suppression.md
124
+ - docs/Style-Guide.md
122
125
  - docs/Subclassed-From-Core-Class.md
123
126
  - docs/Too-Many-Constants.md
124
127
  - docs/Too-Many-Instance-Variables.md
@@ -134,7 +137,6 @@ files:
134
137
  - docs/Utility-Function.md
135
138
  - docs/Versioning-Policy.md
136
139
  - docs/YAML-Reports.md
137
- - docs/style-guide.md
138
140
  - docs/templates/default/docstring/html/public_api_marker.erb
139
141
  - docs/templates/default/docstring/setup.rb
140
142
  - docs/templates/default/fulldoc/html/css/common.css
@@ -197,7 +199,6 @@ files:
197
199
  - lib/reek/cli/command/todo_list_command.rb
198
200
  - lib/reek/cli/options.rb
199
201
  - lib/reek/cli/silencer.rb
200
- - lib/reek/cli/warning_collector.rb
201
202
  - lib/reek/code_comment.rb
202
203
  - lib/reek/configuration/app_configuration.rb
203
204
  - lib/reek/configuration/configuration_file_finder.rb
@@ -314,7 +315,6 @@ files:
314
315
  - spec/reek/cli/command/report_command_spec.rb
315
316
  - spec/reek/cli/command/todo_list_command_spec.rb
316
317
  - spec/reek/cli/options_spec.rb
317
- - spec/reek/cli/warning_collector_spec.rb
318
318
  - spec/reek/code_comment_spec.rb
319
319
  - spec/reek/configuration/app_configuration_spec.rb
320
320
  - spec/reek/configuration/configuration_file_finder_spec.rb
@@ -357,7 +357,6 @@ files:
357
357
  - spec/reek/smells/prima_donna_method_spec.rb
358
358
  - spec/reek/smells/repeated_conditional_spec.rb
359
359
  - spec/reek/smells/smell_configuration_spec.rb
360
- - spec/reek/smells/smell_detector_shared.rb
361
360
  - spec/reek/smells/smell_detector_spec.rb
362
361
  - spec/reek/smells/smell_repository_spec.rb
363
362
  - spec/reek/smells/smell_warning_spec.rb
@@ -412,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
412
411
  version: '0'
413
412
  requirements: []
414
413
  rubyforge_project:
415
- rubygems_version: 2.6.4
414
+ rubygems_version: 2.5.1
416
415
  signing_key:
417
416
  specification_version: 4
418
417
  summary: Code smell detector for Ruby
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'set'
3
-
4
- module Reek
5
- module CLI
6
- #
7
- # Collects and sorts smells warnings.
8
- #
9
- class WarningCollector
10
- def initialize
11
- @warnings_set = Set.new
12
- end
13
-
14
- def found_smell(warning)
15
- warnings_set.add(warning)
16
- end
17
-
18
- def warnings
19
- warnings_set.sort
20
- end
21
-
22
- private
23
-
24
- attr_reader :warnings_set
25
- end
26
- end
27
- end
@@ -1,25 +0,0 @@
1
- require_relative '../../spec_helper'
2
- require_lib 'reek/cli/warning_collector'
3
- require_lib 'reek/smells/smell_warning'
4
-
5
- RSpec.describe Reek::CLI::WarningCollector do
6
- let(:collector) { described_class.new }
7
-
8
- context 'when empty' do
9
- it 'reports no warnings' do
10
- expect(collector.warnings).to eq([])
11
- end
12
- end
13
-
14
- context 'with one warning' do
15
- it 'reports that warning' do
16
- warning = Reek::Smells::SmellWarning.new(Reek::Smells::FeatureEnvy.new,
17
- source: 'string',
18
- context: 'foo',
19
- lines: [1, 2, 3],
20
- message: 'hello')
21
- collector.found_smell(warning)
22
- expect(collector.warnings).to eq([warning])
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- RSpec.shared_examples_for 'SmellDetector' do
4
- context 'exception matching follows the context' do
5
- let(:ctx) { double('context') }
6
-
7
- before { allow(ctx).to receive(:config_for).and_return({}) }
8
-
9
- it 'when false' do
10
- expect(ctx).to receive(:matches?).at_least(:once).and_return(false)
11
- expect(detector.exception?(ctx)).to eq(false)
12
- end
13
-
14
- it 'when true' do
15
- expect(ctx).to receive(:matches?).at_least(:once).and_return(true)
16
- expect(detector.exception?(ctx)).to eq(true)
17
- end
18
- end
19
- end
20
-
21
- RSpec.shared_examples_for 'common fields set correctly' do
22
- it 'reports the source' do
23
- expect(warning.source).to eq('string')
24
- end
25
-
26
- it 'reports the smell type' do
27
- expect(warning.smell_type).to eq(detector.smell_type)
28
- end
29
- end