rubocop 0.29.0 → 0.29.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a1f32b26b9ff39fe0348f90855ab63dccc0e3c8
4
- data.tar.gz: 30d21bcc89c00bb7cd629b9c5089fc4d041afeb7
3
+ metadata.gz: df6ad6e09fd8b5948ba0e46ebe68fae1ffd6d391
4
+ data.tar.gz: b72c490888b7453005265d7bd96414e8b1bab28b
5
5
  SHA512:
6
- metadata.gz: a82dd617f97b5bf6bacc3cab91c1888ba9db3d78dd866ae8a5c58fdf2235cff8ffc354ee0c99e69506db4353571d7292fc1ed4e03b20d1b590597be8dfeea45e
7
- data.tar.gz: af859406fb7c0100a90e2cd1356550124b7d473c252da59b15034d55a08a9c786cad6c3efd5906100a565acfd62ce5cf6488483561db2e8903f82c9a5adf762a
6
+ metadata.gz: 8c7437f405d30ba9571b0d2088b1bc0398857d55bd846437c1415bc39a573bdcf19c0e4f920e1ea2b835f18bcc4c6d733ffc72eea941e736080e8632e01d4d86
7
+ data.tar.gz: d140fbca7c9cc078c467491f00a5252272f81abaca6701647fd2a085f1c682170724e9601d46930dbae0f2faf0a38f4c1face6ac77e925ea33e2e1342c3b7ce8
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.29.1 (13/02/2015)
6
+
7
+ ### Bugs fixed
8
+
9
+ * [#1638](https://github.com/bbatsov/rubocop/issues/1638): Use Parser functionality rather than regular expressions for matching comments in `FirstParameterIndentation`. ([@jonas054][])
10
+ * [#1642](https://github.com/bbatsov/rubocop/issues/1642): Raise the correct exception if the configuration file is malformed. ([@bquorning][])
11
+ * [#1647](https://github.com/bbatsov/rubocop/issues/1647): Skip `SpaceAroundBlockParameters` when lambda has no argument. ([@eitoball][])
12
+ * [#1649](https://github.com/bbatsov/rubocop/issues/1649): Handle exception assignments in `UselessSetterCall`. ([@bbatsov][])
13
+ * [#1644](https://github.com/bbatsov/rubocop/issues/1644): Don't search the entire file system when a folder is named `,`. ([@bquorning][])
14
+
5
15
  ## 0.29.0 (05/02/2015)
6
16
 
7
17
  ### New features
@@ -1249,3 +1259,4 @@
1249
1259
  [@mmozuras]: https://github.com/mmozuras
1250
1260
  [@d4rk5eed]: https://github.com/d4rk5eed
1251
1261
  [@cshaffer]: https://github.com/cshaffer
1262
+ [@eitoball]: https://github.com/eitoball
@@ -29,7 +29,7 @@ module RuboCop
29
29
  $stderr.puts "Ambiguous cop name #{e.message} needs namespace " \
30
30
  'qualifier.'
31
31
  return 1
32
- rescue => e
32
+ rescue StandardError, SyntaxError => e
33
33
  $stderr.puts e.message
34
34
  $stderr.puts e.backtrace
35
35
  return 1
@@ -80,7 +80,7 @@ module RuboCop
80
80
  process_binary_operator_assignment(node)
81
81
  when *ASSIGNMENT_TYPES
82
82
  _, rhs_node = *node
83
- process_assignment(node, rhs_node)
83
+ process_assignment(node, rhs_node) if rhs_node
84
84
  end
85
85
  end
86
86
 
@@ -22,8 +22,6 @@ module RuboCop
22
22
  include AutocorrectAlignment
23
23
  include ConfigurableEnforcedStyle
24
24
 
25
- COMMENT_OR_BLANK_LINE = /^\s*(#.*)?$/
26
-
27
25
  def on_send(node)
28
26
  _receiver, method_name, *args = *node
29
27
  return if args.empty?
@@ -93,8 +91,13 @@ module RuboCop
93
91
  # containing the previous line that's not a comment line or a blank
94
92
  # line.
95
93
  def previous_code_line(line_number)
94
+ @comment_lines ||=
95
+ processed_source.comments
96
+ .select { |c| begins_its_line?(c.loc.expression) }
97
+ .map { |c| c.loc.line }
98
+
96
99
  line = ''
97
- while line =~ COMMENT_OR_BLANK_LINE
100
+ while line =~ /^\s*$/ || @comment_lines.include?(line_number)
98
101
  line_number -= 1
99
102
  line = processed_source.lines[line_number - 1]
100
103
  end
@@ -18,7 +18,7 @@ module RuboCop
18
18
  def on_block(node)
19
19
  _method, args, body = *node
20
20
  opening_pipe, closing_pipe = args.loc.begin, args.loc.end
21
- return unless opening_pipe
21
+ return unless !args.children.empty? && opening_pipe
22
22
 
23
23
  check_inside_pipes(args.children, opening_pipe, closing_pipe)
24
24
 
@@ -27,13 +27,28 @@ module RuboCop
27
27
 
28
28
  def run(paths)
29
29
  target_files = find_target_files(paths)
30
+ inspect_files(target_files)
31
+ end
32
+
33
+ def abort
34
+ @aborting = true
35
+ end
36
+
37
+ private
38
+
39
+ def find_target_files(paths)
40
+ target_finder = TargetFinder.new(@config_store, @options)
41
+ target_files = target_finder.find(paths)
42
+ target_files.each(&:freeze).freeze
43
+ end
30
44
 
45
+ def inspect_files(files)
31
46
  inspected_files = []
32
47
  all_passed = true
33
48
 
34
- formatter_set.started(target_files)
49
+ formatter_set.started(files)
35
50
 
36
- target_files.each do |file|
51
+ files.each do |file|
37
52
  break if aborting?
38
53
  offenses = process_file(file)
39
54
  all_passed = false if offenses.any? { |o| considered_failure?(o) }
@@ -47,18 +62,6 @@ module RuboCop
47
62
  formatter_set.close_output_files
48
63
  end
49
64
 
50
- def abort
51
- @aborting = true
52
- end
53
-
54
- private
55
-
56
- def find_target_files(paths)
57
- target_finder = TargetFinder.new(@config_store, @options)
58
- target_files = target_finder.find(paths)
59
- target_files.each(&:freeze).freeze
60
- end
61
-
62
65
  def process_file(file)
63
66
  puts "Scanning #{file}" if @options[:debug]
64
67
 
@@ -88,6 +88,7 @@ module RuboCop
88
88
  def find_files(base_dir, flags)
89
89
  wanted_toplevel_dirs = toplevel_dirs(base_dir, flags) -
90
90
  excluded_dirs(base_dir)
91
+ wanted_toplevel_dirs.map! { |dir| dir.gsub(',', '\,') }
91
92
 
92
93
  pattern = if wanted_toplevel_dirs.empty?
93
94
  # We need this special case to avoid creating the pattern
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.29.0'
6
+ STRING = '0.29.1'
7
7
 
8
8
  MSG = '%s (using Parser %s, running on %s %s %s)'
9
9
 
@@ -0,0 +1,12 @@
1
+ ### Bugs fixed
2
+
3
+ * [#1638](https://github.com/bbatsov/rubocop/issues/1638): Use Parser functionality rather than regular expressions for matching comments in `FirstParameterIndentation`. ([@jonas054][])
4
+ * [#1642](https://github.com/bbatsov/rubocop/issues/1642): Raise the correct exception if the configuration file is malformed. ([@bquorning][])
5
+ * [#1647](https://github.com/bbatsov/rubocop/issues/1647): Skip `SpaceAroundBlockParameters` when lambda has no argument. ([@eitoball][])
6
+ * [#1649](https://github.com/bbatsov/rubocop/issues/1649): Handle exception assignments in `UselessSetterCall`. ([@bbatsov][])
7
+ * [#1644](https://github.com/bbatsov/rubocop/issues/1644): Don't search the entire file system when a folder is named `,`. ([@bquorning][])
8
+
9
+ [@bbatsov]: https://github.com/bbatsov
10
+ [@jonas054]: https://github.com/jonas054
11
+ [@bquorning]: https://github.com/bquorning
12
+ [@eitoball]: https://github.com/eitoball
@@ -2692,6 +2692,17 @@ describe RuboCop::CLI, :isolated_environment do
2692
2692
  ''].join("\n"))
2693
2693
  end
2694
2694
 
2695
+ it 'fails when a configuration file has invalid YAML syntax' do
2696
+ create_file('example/.rubocop.yml', ['AllCops:',
2697
+ ' Exclude:',
2698
+ ' - **/*_old.rb'])
2699
+
2700
+ cli.run(['example'])
2701
+ expect($stderr.string)
2702
+ .to start_with('(<unknown>): did not find expected alphabetic or ' \
2703
+ 'numeric character while scanning an alias at line 3 column 7')
2704
+ end
2705
+
2695
2706
  context 'when a file inherits from the old auto generated file' do
2696
2707
  before do
2697
2708
  create_file('rubocop-todo.yml', '')
@@ -196,4 +196,16 @@ describe RuboCop::Cop::Lint::UselessSetterCall do
196
196
  ])
197
197
  expect(cop.offenses).to be_empty
198
198
  end
199
+
200
+ it 'handles exception assignments without exploding' do
201
+ inspect_source(cop,
202
+ ['def foo(bar)',
203
+ ' begin',
204
+ ' rescue StandardError => _',
205
+ ' end',
206
+ ' bar[:baz] = true',
207
+ 'end'
208
+ ])
209
+ expect(cop.offenses).to be_empty
210
+ end
199
211
  end
@@ -102,7 +102,7 @@ describe RuboCop::Cop::Style::FirstParameterIndentation, :config do
102
102
  context 'when preceded by a comment line' do
103
103
  it 'accepts a correctly indented first parameter' do
104
104
  inspect_source(cop, ['puts x.',
105
- ' merge(',
105
+ ' merge( # EOL comment',
106
106
  ' # comment',
107
107
  ' b: 2',
108
108
  ' )'])
@@ -239,6 +239,17 @@ describe RuboCop::Cop::Style::FirstParameterIndentation, :config do
239
239
  'more than the previous line.'])
240
240
  expect(cop.highlights).to eq(['bar: 3'])
241
241
  end
242
+
243
+ it 'accepts a correctly indented first parameter in interpolation' do
244
+ inspect_source(cop, ['puts %(',
245
+ ' <p>',
246
+ ' #{Array(',
247
+ ' 42',
248
+ ' )}',
249
+ ' </p>',
250
+ ')'])
251
+ expect(cop.offenses).to be_empty
252
+ end
242
253
  end
243
254
 
244
255
  context 'without outer parentheses' do
@@ -10,6 +10,11 @@ describe RuboCop::Cop::Style::SpaceAroundBlockParameters, :config do
10
10
  inspect_source(cop, '{}.each {}')
11
11
  expect(cop.offenses).to be_empty
12
12
  end
13
+
14
+ it 'skips lambda without args' do
15
+ inspect_source(cop, '->() { puts "a" }')
16
+ expect(cop.offenses).to be_empty
17
+ end
13
18
  end
14
19
 
15
20
  context 'when EnforcedStyleInsidePipes is no_space' do
@@ -140,6 +140,19 @@ describe RuboCop::TargetFinder, :isolated_environment do
140
140
  expect(found_basenames).not_to include('ruby1.rb')
141
141
  expect(found_basenames).to include('ruby3.rb')
142
142
  end
143
+
144
+ it 'works also if a folder is named ","' do
145
+ create_file(',/ruby4.rb', '# encoding: utf-8')
146
+
147
+ config = double('config')
148
+ exclude_property = { 'Exclude' => [File.expand_path('dir1/**/*')] }
149
+ allow(config).to receive(:[]).with('AllCops').and_return(exclude_property)
150
+ allow(config_store).to receive(:for).and_return(config)
151
+
152
+ expect(found_basenames).not_to include('ruby1.rb')
153
+ expect(found_basenames).to include('ruby3.rb')
154
+ expect(found_basenames).to include('ruby4.rb')
155
+ end
143
156
  end
144
157
 
145
158
  describe '#target_files_in_dir' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-05 00:00:00.000000000 Z
13
+ date: 2015-02-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow
@@ -491,6 +491,7 @@ files:
491
491
  - relnotes/v0.27.1.md
492
492
  - relnotes/v0.28.0.md
493
493
  - relnotes/v0.29.0.md
494
+ - relnotes/v0.29.1.md
494
495
  - rubocop.gemspec
495
496
  - spec/.rubocop.yml
496
497
  - spec/fixtures/html_formatter/expected.html