reek 4.1.0 → 4.1.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: fb4b9a8e91de50f96e7fc83d96e72f92af778dfc
4
- data.tar.gz: f33a99fd21ffa8d82eb48d4e1cde69a0a01e0468
3
+ metadata.gz: cd5651b2cc5c8b32a2eb8d1297c190b67ebf3f6b
4
+ data.tar.gz: 948781b5c00280ff13499c1a31cf634f495e5736
5
5
  SHA512:
6
- metadata.gz: 82da2cb804ea9c2fe37665072c0666350c7a22ba0e857f3629589ca7f91e87a55ee84ae198cd01e06d51e7e00d16b1aabde1b5d7f3cd59523435118e6692d954
7
- data.tar.gz: 5177823be762c3c3354144a57abee5c1fea661d2ed9f947e63233a16de0aeae3dd8ac443bd3beb17cb7f3d22ac1d0d12f106a8e8eab568a934b878d8bf550cdd
6
+ metadata.gz: 16653eda1cae7ac27cf6f439f45b8d2f77e8c954bd9e989cd70fdfa0c5c553cebb3caa97bb6a8696312a5029120455a7e7c45e20a46b42b3823d77c25abc3a2d
7
+ data.tar.gz: ecc7e1105e00ae9e6f284889ad5fc58e19eee73d79fde9f6c6ae9194ed6ad2b29c06006e3eee8e74356a4f629b04cfb001ab6e8ea9c7ad1dc4e263051a1edb83
data/.rubocop.yml CHANGED
@@ -52,6 +52,10 @@ Style/FrozenStringLiteralComment:
52
52
  Style/MultilineBlockChain:
53
53
  Enabled: false
54
54
 
55
+ # Always put the closing brace on the last line
56
+ Style/MultilineMethodCallBraceLayout:
57
+ EnforcedStyle: same_line
58
+
55
59
  # Indent one level for follow-up lines
56
60
  Style/MultilineMethodCallIndentation:
57
61
  EnforcedStyle: indented
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change log
2
2
 
3
+ ## 4.1.1 (2016-07-05)
4
+
5
+ * (waldyr) Checking lambda should not raise error
6
+
3
7
  ## 4.1.0 (2016-06-23)
4
8
 
5
9
  * (waldyr) Add SubclassedFromCoreClass detector
data/Gemfile CHANGED
@@ -10,9 +10,10 @@ group :development do
10
10
  gem 'mutant-rspec', '~> 0.8.8'
11
11
  gem 'rake', '~> 11.1'
12
12
  gem 'rspec', '~> 3.0'
13
- gem 'rubocop', '~> 0.39.0'
13
+ gem 'rubocop', '~> 0.41.1'
14
14
  gem 'simplecov', '~> 0.11.1'
15
15
  gem 'yard', '~> 0.8.7'
16
+ gem 'activesupport', '~> 4.2.7.rc1'
16
17
 
17
18
  platforms :mri do
18
19
  gem 'redcarpet', '~> 3.3.1'
data/defaults.reek CHANGED
@@ -115,3 +115,4 @@ UnusedPrivateMethod:
115
115
  UtilityFunction:
116
116
  enabled: true
117
117
  exclude: []
118
+ public_methods_only: false
@@ -7,6 +7,10 @@ module Reek
7
7
  def name
8
8
  'lambda'
9
9
  end
10
+
11
+ def module_creation_call?
12
+ false
13
+ end
10
14
  end
11
15
  end
12
16
  end
@@ -109,8 +109,7 @@ module Reek
109
109
  parser.on(
110
110
  '-f', '--format FORMAT', [:html, :text, :yaml, :json, :xml, :code_climate],
111
111
  'Report smells in the given format:',
112
- ' html', ' text (default)', ' yaml', ' json', ' xml', ' code_climate'
113
- ) do |opt|
112
+ ' html', ' text (default)', ' yaml', ' json', ' xml', ' code_climate') do |opt|
114
113
  self.report_format = opt
115
114
  end
116
115
  end
@@ -72,10 +72,9 @@ module Reek
72
72
 
73
73
  def load_values(configuration_hash)
74
74
  configuration_hash.each do |key, value|
75
- case
76
- when key == EXCLUDE_PATHS_KEY
75
+ if key == EXCLUDE_PATHS_KEY
77
76
  excluded_paths.add value
78
- when smell_type?(key)
77
+ elsif smell_type?(key)
79
78
  default_directive.add key, value
80
79
  else
81
80
  directory_directives.add key, value
data/lib/reek/report.rb CHANGED
@@ -25,7 +25,8 @@ module Reek
25
25
 
26
26
  HEADING_FORMATTERS = {
27
27
  verbose: HeadingFormatter::Verbose,
28
- quiet: HeadingFormatter::Quiet }.freeze
28
+ quiet: HeadingFormatter::Quiet
29
+ }.freeze
29
30
 
30
31
  WARNING_FORMATTER_CLASSES = {
31
32
  wiki_links: WikiLinkWarningFormatter,
@@ -15,8 +15,7 @@ module Reek
15
15
  categories: categories,
16
16
  location: location,
17
17
  remediation_points: remediation_points,
18
- content: content
19
- ).render
18
+ content: content).render
20
19
  end
21
20
 
22
21
  private
@@ -39,8 +38,7 @@ module Reek
39
38
  warning_lines = warning.lines
40
39
  CCEngine::Location::LineRange.new(
41
40
  path: warning.source,
42
- line_range: warning_lines.first..warning_lines.last
43
- )
41
+ line_range: warning_lines.first..warning_lines.last)
44
42
  end
45
43
 
46
44
  def remediation_points
@@ -42,8 +42,7 @@ module Reek
42
42
  def self.default_config
43
43
  super.merge(
44
44
  MAX_COPIES_KEY => DEFAULT_MAX_COPIES,
45
- MIN_CLUMP_SIZE_KEY => DEFAULT_MIN_CLUMP_SIZE
46
- )
45
+ MIN_CLUMP_SIZE_KEY => DEFAULT_MIN_CLUMP_SIZE)
47
46
  end
48
47
 
49
48
  #
@@ -33,8 +33,7 @@ module Reek
33
33
  def self.default_config
34
34
  super.merge(
35
35
  MAX_ALLOWED_CALLS_KEY => DEFAULT_MAX_CALLS,
36
- ALLOW_CALLS_KEY => DEFAULT_ALLOW_CALLS
37
- )
36
+ ALLOW_CALLS_KEY => DEFAULT_ALLOW_CALLS)
38
37
  end
39
38
 
40
39
  #
@@ -25,8 +25,7 @@ module Reek
25
25
  MAX_ALLOWED_PARAMS_KEY => DEFAULT_MAX_ALLOWED_PARAMS,
26
26
  SmellConfiguration::OVERRIDES_KEY => {
27
27
  'initialize' => { MAX_ALLOWED_PARAMS_KEY => 5 }
28
- }
29
- )
28
+ })
30
29
  end
31
30
 
32
31
  #
@@ -31,8 +31,7 @@ module Reek
31
31
  def self.default_config
32
32
  super.merge(
33
33
  MAX_ALLOWED_NESTING_KEY => DEFAULT_MAX_ALLOWED_NESTING,
34
- IGNORE_ITERATORS_KEY => DEFAULT_IGNORE_ITERATORS
35
- )
34
+ IGNORE_ITERATORS_KEY => DEFAULT_IGNORE_ITERATORS)
36
35
  end
37
36
 
38
37
  # Generates a smell warning for each independent deepest nesting depth
@@ -25,8 +25,7 @@ module Reek
25
25
  def self.default_config
26
26
  super.merge(
27
27
  MAX_ALLOWED_IVARS_KEY => DEFAULT_MAX_IVARS,
28
- EXCLUDE_KEY => []
29
- )
28
+ EXCLUDE_KEY => [])
30
29
  end
31
30
 
32
31
  #
@@ -27,8 +27,7 @@ module Reek
27
27
  def self.default_config
28
28
  super.merge(
29
29
  MAX_ALLOWED_METHODS_KEY => DEFAULT_MAX_METHODS,
30
- EXCLUDE_KEY => []
31
- )
30
+ EXCLUDE_KEY => [])
32
31
  end
33
32
 
34
33
  #
@@ -19,8 +19,7 @@ module Reek
19
19
  def self.default_config
20
20
  super.merge(
21
21
  MAX_ALLOWED_STATEMENTS_KEY => DEFAULT_MAX_STATEMENTS,
22
- EXCLUDE_KEY => ['initialize']
23
- )
22
+ EXCLUDE_KEY => ['initialize'])
24
23
  end
25
24
 
26
25
  #
@@ -28,8 +28,7 @@ module Reek
28
28
  def self.default_config
29
29
  super.merge(
30
30
  REJECT_KEY => DEFAULT_REJECT_PATTERNS,
31
- ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS
32
- )
31
+ ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS)
33
32
  end
34
33
 
35
34
  #
@@ -33,8 +33,7 @@ module Reek
33
33
  def self.default_config
34
34
  super().merge(
35
35
  REJECT_KEY => DEFAULT_REJECT_PATTERNS,
36
- ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS
37
- )
36
+ ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS)
38
37
  end
39
38
 
40
39
  def self.contexts
@@ -30,8 +30,7 @@ module Reek
30
30
  def self.default_config
31
31
  super.merge(
32
32
  REJECT_KEY => DEFAULT_REJECT_PATTERNS,
33
- ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS
34
- )
33
+ ACCEPT_KEY => DEFAULT_ACCEPT_PATTERNS)
35
34
  end
36
35
 
37
36
  #
@@ -35,8 +35,7 @@ module Reek
35
35
  def self.default_config
36
36
  super.merge(
37
37
  REJECT_KEY => DEFAULT_REJECT_SET,
38
- ACCEPT_KEY => DEFAULT_ACCEPT_SET
39
- )
38
+ ACCEPT_KEY => DEFAULT_ACCEPT_SET)
40
39
  end
41
40
 
42
41
  def self.contexts
data/lib/reek/version.rb CHANGED
@@ -7,6 +7,6 @@ module Reek
7
7
  # @public
8
8
  module Version
9
9
  # @public
10
- STRING = '4.1.0'.freeze
10
+ STRING = '4.1.1'.freeze
11
11
  end
12
12
  end
@@ -466,6 +466,14 @@ RSpec.describe Reek::AST::SexpExtensions::CasgnNode do
466
466
  expect(exp.defines_module?).to be_truthy
467
467
  end
468
468
  end
469
+
470
+ context 'when assign a lambda to a constant' do
471
+ it 'does not define a module' do
472
+ exp = Reek::Source::SourceCode.from('C = ->{}').syntax_tree
473
+
474
+ expect(exp.defines_module?).to be_falsey
475
+ end
476
+ end
469
477
  end
470
478
 
471
479
  context '#superclass' do
@@ -11,34 +11,35 @@ RSpec.describe Reek::Report::CodeClimateFormatter, '#render' do
11
11
  source: 'a/ruby/source/file.rb')
12
12
  end
13
13
  let(:rendered) { Reek::Report::CodeClimateFormatter.new(warning).render }
14
+ let(:json) { JSON.parse rendered.chop }
14
15
 
15
16
  it "sets the type as 'issue'" do
16
- expect(rendered).to match(/\"type\":\"issue\"/)
17
+ expect(json['type']).to eq 'issue'
17
18
  end
18
19
 
19
20
  it 'sets the category' do
20
- expect(rendered).to match(/\"categories\":\[\"Complexity\"\]/)
21
+ expect(json['categories']).to eq ['Complexity']
21
22
  end
22
23
 
23
24
  it 'constructs a description based on the context and message' do
24
- expect(rendered).to match(/\"description\":\"context foo message bar\"/)
25
+ expect(json['description']).to eq 'context foo message bar'
25
26
  end
26
27
 
27
28
  it 'sets a check name based on the smell detector' do
28
- expect(rendered).to match(/\"check_name\":\"UtilityFunction\"/)
29
+ expect(json['check_name']).to eq 'UtilityFunction'
29
30
  end
30
31
 
31
32
  it 'sets the location' do
32
- expect(rendered).to match(%r{\"location\":{\"path\":\"a/ruby/source/file.rb\",\"lines\":{\"begin\":1,\"end\":2}}})
33
+ expect(json['location']).to eq('path' => 'a/ruby/source/file.rb',
34
+ 'lines' => { 'begin' => 1, 'end' => 2 })
33
35
  end
34
36
 
35
37
  it 'sets a content based on the smell detector' do
36
- expect(rendered).to match(
37
- /\"body\":\"A _Utility Function_ is any instance method that has no dependency on the state of the instance.\\n\"/
38
- )
38
+ expect(json['content']['body']).
39
+ to eq "A _Utility Function_ is any instance method that has no dependency on the state of the instance.\n"
39
40
  end
40
41
 
41
42
  it 'sets remediation points based on the smell detector' do
42
- expect(rendered).to match(/\"remediation_points\":250000/)
43
+ expect(json['remediation_points']).to eq 250_000
43
44
  end
44
45
  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.1.0
4
+ version: 4.1.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-06-23 00:00:00.000000000 Z
14
+ date: 2016-07-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: codeclimate-engine-rb