reek 3.7.0 → 3.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abd5004377700bed9881c5ed437ec2a9d19caa23
4
- data.tar.gz: 8a4c3835fb589450122e13b4b449413aa93c9bcc
3
+ metadata.gz: 0360a27f0d7285b66c630aa23ff08c48273f0ff7
4
+ data.tar.gz: cf166a5b8541a65c60738afa51aa903c0c673998
5
5
  SHA512:
6
- metadata.gz: fe96cf2b530e92d25370691e3b8584825b9243016639073575817893dd7645a97bee491b8b73d0e04166a86e0602271186744d1b1eeec9285a4abc533fe9e813
7
- data.tar.gz: 1b98379f0590f06b76dcc6e8031a4c7fedeca3af08ba3189c516b3e12bf754addc1e2155747807ef48c65569bedaa389ab0d0a4aa8e34fba03b1e0f8cb939a6f
6
+ metadata.gz: d52ffb53c36fc67b58993411a6bdeb1f319cadd044736f5cb13e690789dc77c2e0022b7f25261e1ebe4838fe4c11036f47d005472d5af30d6f33f4885651ae37
7
+ data.tar.gz: 443d185d3acc0d65d3f673e34f1e050e754a87637cc6fae8c63fa1059d9f1150c5936437c0cfe662d8fd9952ca903fa90647036ee35a35fcb07f200909d67f40
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.7.1 (2015-11-29)
6
+
7
+ * (troessner) Reverse merge default directives into directory directives.
8
+
5
9
  ## 3.7.0 (2015-11-17)
6
10
 
7
11
  * (andyw8) Add Code Climate JSON report format: `--format code_climate`
data/README.md CHANGED
@@ -258,7 +258,29 @@ exclude_paths:
258
258
  - lib/rake/legacy_tasks
259
259
  ```
260
260
 
261
- Note you do not need a configuration file at all. If you're fine with all the [defaults](defaults.reek) we set you can skip this completely.
261
+ If you have a directory directive for which a default directive exists, the more specific
262
+ one (which is the directory directive) will take precedence.
263
+
264
+ This configuration for instance:
265
+
266
+ ```yaml
267
+ ---
268
+ IrresponsibleModule:
269
+ enabled: false
270
+
271
+ TooManyStatements:
272
+ max_statements: 5
273
+
274
+ "app/controllers":
275
+ TooManyStatements:
276
+ max_statements: 10
277
+ ```
278
+
279
+ translates to:
280
+
281
+ * IrresponsibleModule is disabled everywhere
282
+ * TooManyStatements#max_statements is 10 in "app/controllers"
283
+ * TooManyStatements#max_statements is 5 everywhere else
262
284
 
263
285
  For more details please check out the [Basic Smell Options](docs/Basic-Smell-Options.md)
264
286
  which are supported by every smell type. As you can see above, certain smell
@@ -268,6 +290,9 @@ All options that go beyond the [Basic Smell Options](docs/Basic-Smell-Options.md
268
290
  are documented in the corresponding smell type /docs page (if you want to get a quick overview over all possible
269
291
  configurations you can also check out [the `default.reek` file in this repository](defaults.reek).
270
292
 
293
+ Note that you do not need a configuration file at all.
294
+ If you're fine with all the [defaults](defaults.reek) we set you can skip this completely.
295
+
271
296
  ### Source code comments
272
297
 
273
298
  In case you need to suppress a smell warning and you can't or don't want to
@@ -90,10 +90,11 @@ module Reek
90
90
  #
91
91
  # @param source_via [String] - the source of the code inspected
92
92
  #
93
- # @return [Hash] the directory directive for the source or, if there is
94
- # none, the default directive
93
+ # @return [Hash] the directory directive for the source with the default directive
94
+ # reverse-merged into it.
95
95
  def directive_for(source_via)
96
- directory_directives.directive_for(source_via) || default_directive
96
+ hit = directory_directives.directive_for(source_via)
97
+ hit ? default_directive.merge(hit) : default_directive
97
98
  end
98
99
 
99
100
  def path_excluded?(path)
@@ -21,7 +21,7 @@ module Reek
21
21
  #
22
22
  # :reek:FeatureEnvy
23
23
  def inspect(ctx)
24
- ctx.local_nodes(:def) do |node| # FIXME: also search for :defs?
24
+ ctx.local_nodes(:def) do |node|
25
25
  if node.name.to_s == 'initialize'
26
26
  return [
27
27
  smell_warning(
data/lib/reek/version.rb CHANGED
@@ -6,6 +6,6 @@ module Reek
6
6
  # @public
7
7
  module Version
8
8
  # @public
9
- STRING = '3.7.0'
9
+ STRING = '3.7.1'
10
10
  end
11
11
  end
@@ -91,9 +91,8 @@ RSpec.describe Reek::Configuration::AppConfiguration do
91
91
  end
92
92
 
93
93
  describe '#directive_for' do
94
- let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
95
-
96
- context 'our source is in a directory for which we have a directive' do
94
+ context 'multiple directory directives and no default directive present' do
95
+ let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
97
96
  let(:baz_config) { { Reek::Smells::IrresponsibleModule => { enabled: false } } }
98
97
  let(:bang_config) { { Reek::Smells::Attribute => { enabled: true } } }
99
98
 
@@ -110,7 +109,30 @@ RSpec.describe Reek::Configuration::AppConfiguration do
110
109
  end
111
110
  end
112
111
 
113
- context 'our source is not in a directory for which we have a directive' do
112
+ context 'directory directive and default directive present' do
113
+ let(:directory) { 'spec/samples/two_smelly_files/' }
114
+ let(:directory_config) { { Reek::Smells::TooManyStatements => { max_statements: 8 } } }
115
+ let(:directory_directives) { { directory => directory_config } }
116
+ let(:default_directive) do
117
+ {
118
+ Reek::Smells::IrresponsibleModule => { enabled: false },
119
+ Reek::Smells::TooManyStatements => { max_statements: 15 }
120
+ }
121
+ end
122
+ let(:source_via) { "#{directory}/dummy.rb" }
123
+
124
+ it 'returns the directory directive with the default directive reverse-merged' do
125
+ configuration = described_class.from_map directory_directives: directory_directives,
126
+ default_directive: default_directive
127
+ actual = configuration.directive_for(source_via)
128
+ expect(actual[Reek::Smells::IrresponsibleModule]).to be_truthy
129
+ expect(actual[Reek::Smells::TooManyStatements]).to be_truthy
130
+ expect(actual[Reek::Smells::TooManyStatements][:max_statements]).to eq(8)
131
+ end
132
+ end
133
+
134
+ context 'no directory directive but a default directive present' do
135
+ let(:source_via) { 'spec/samples/three_clean_files/dummy.rb' }
114
136
  let(:default_directive) { { Reek::Smells::IrresponsibleModule => { enabled: false } } }
115
137
  let(:attribute_config) { { Reek::Smells::Attribute => { enabled: false } } }
116
138
  let(:directory_directives) do
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: 3.7.0
4
+ version: 3.7.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: 2015-11-18 00:00:00.000000000 Z
14
+ date: 2015-11-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb
@@ -530,7 +530,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
530
530
  version: '0'
531
531
  requirements: []
532
532
  rubyforge_project:
533
- rubygems_version: 2.5.0
533
+ rubygems_version: 2.4.5.1
534
534
  signing_key:
535
535
  specification_version: 4
536
536
  summary: Code smell detector for Ruby