rubocop 0.34.0 → 0.34.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: 28abcf0a852c586dd74f51a997523666f7a139b0
4
- data.tar.gz: 352ca8a89138692d8a06341e0fe0bec72de5d55e
3
+ metadata.gz: cbf58da815cbd0b9614e7e1d4a7d994b43669e89
4
+ data.tar.gz: 0ce300ef83960cbdc9ee2e60fe0509c0b0a9a5b2
5
5
  SHA512:
6
- metadata.gz: d78c51015cbf72261a8493037c1cdf9ec868d00c965f3b816e48ffa4ecd080ac3e616e1b4d518cd6e22d3b27c80565a05ab73835d4e874575aa3f88fe1efbf99
7
- data.tar.gz: cbf3a9a14028fa911fef98766067c201f9acd7e1205770f5b75379c55467769760f5af76265237bc98f3964cd4c1febbed6a77143deea5c0e23ee770d63dadd8
6
+ metadata.gz: e8f6a145dbd313cac17cbd68b5e343048cd83a33d37744c4323b77e75a293cf97b691fc28d8679583eda67de9716eb87b4201145c2eb8dca146ebb2daa20ef2f
7
+ data.tar.gz: c5553328c5e35884f2136320f8420ec3d3e67c22515050c0c11e86170f090aad2020876a84e1d2b630454e1e1c9db938629f8296085acb657eda21da87c474ef
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.34.1 (09/09/2015)
6
+
7
+ ### Bug Fixes
8
+
9
+ * [#2212](https://github.com/bbatsov/rubocop/issues/2212): Handle methods without parentheses in auto-correct. ([@karreiro][])
10
+ * [#2214](https://github.com/bbatsov/rubocop/pull/2214): Fix `File name too long error` when `STDIN` option is provided. ([@mrfoto][])
11
+ * [#2217](https://github.com/bbatsov/rubocop/issues/2217): Allow block arguments in `Style/SymbolProc`. ([@lumeet][])
12
+ * [#2213](https://github.com/bbatsov/rubocop/issues/2213): Write to cache with binary encoding to avoid transcoding exceptions in some locales. ([@jonas054][])
13
+ * [#2218](https://github.com/bbatsov/rubocop/issues/2218): Fix loading config error when safe yaml is only partially loaded. ([@maxjacobson][])
14
+ * [#2161](https://github.com/bbatsov/rubocop/issues/2161): Allow an explicit receiver (except `Kernel`) in `Style/SignalException`. ([@lumeet][])
15
+
5
16
  ## 0.34.0 (05/09/2015)
6
17
 
7
18
  ### New features
@@ -1586,3 +1597,5 @@
1586
1597
  [@caseywebdev]: https://github.com/caseywebdev
1587
1598
  [@MGerrior]: https://github.com/MGerrior
1588
1599
  [@imtayadeway]: https://github.com/imtayadeway
1600
+ [@mrfoto]: https://github.com/mrfoto
1601
+ [@karreiro]: https://github.com/karreiro
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Coverage Status](http://img.shields.io/coveralls/bbatsov/rubocop/master.svg)](https://coveralls.io/r/bbatsov/rubocop)
5
5
  [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
6
  [![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
7
- [![Gratipay](http://img.shields.io/gratipay/bbatsov.svg)](https://www.gratipay.com/bbatsov/)
8
7
 
9
8
  <p align="center">
10
9
  <img src="https://raw.github.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
data/config/disabled.yml CHANGED
@@ -38,7 +38,7 @@ Style/MissingElse:
38
38
  EnforcedStyle: both
39
39
  SupportedStyles:
40
40
  # if - warn when an if expression is missing an else branch
41
- # case - warn when a case expression is misisng an else branch
41
+ # case - warn when a case expression is missing an else branch
42
42
  # both - warn when an if or case expression is missing an else branch
43
43
  - if
44
44
  - case
@@ -151,11 +151,11 @@ module RuboCop
151
151
  end
152
152
 
153
153
  def patterns_to_include
154
- self['AllCops']['Include']
154
+ @patterns_to_include ||= self['AllCops']['Include']
155
155
  end
156
156
 
157
157
  def patterns_to_exclude
158
- self['AllCops']['Exclude']
158
+ @patterns_to_exclude ||= self['AllCops']['Exclude']
159
159
  end
160
160
 
161
161
  def path_relative_to_config(path)
@@ -148,7 +148,7 @@ module RuboCop
148
148
  def yaml_safe_load(yaml_code)
149
149
  if YAML.respond_to?(:safe_load) # Ruby 2.1+
150
150
  if defined?(SafeYAML)
151
- YAML.safe_load(yaml_code, nil, whitelisted_tags: %w(!ruby/regexp))
151
+ SafeYAML.load(yaml_code, nil, whitelisted_tags: %w(!ruby/regexp))
152
152
  else
153
153
  YAML.safe_load(yaml_code, [Regexp])
154
154
  end
@@ -17,13 +17,13 @@ module RuboCop
17
17
 
18
18
  def index_of_first_token(node)
19
19
  b = node.loc.expression.begin
20
- token_table[[b.line, b.column]]
20
+ token_table[b.line][b.column]
21
21
  end
22
22
 
23
23
  def index_of_last_token(node)
24
24
  e = node.loc.expression.end
25
- (0...e.column).to_a.reverse.find do |c|
26
- ix = token_table[[e.line, c]]
25
+ (0...e.column).to_a.reverse_each do |c|
26
+ ix = token_table[e.line][c]
27
27
  return ix if ix
28
28
  end
29
29
  end
@@ -32,7 +32,8 @@ module RuboCop
32
32
  @token_table ||= begin
33
33
  table = {}
34
34
  @processed_source.tokens.each_with_index do |t, ix|
35
- table[[t.pos.line, t.pos.column]] = ix
35
+ table[t.pos.line] ||= {}
36
+ table[t.pos.line][t.pos.column] = ix
36
37
  end
37
38
  table
38
39
  end
@@ -28,7 +28,6 @@ module RuboCop
28
28
  TR = 'tr'.freeze
29
29
  BANG = '!'.freeze
30
30
  SINGLE_QUOTE = "'".freeze
31
- CLOSING_PAREN = ')'.freeze
32
31
 
33
32
  def on_send(node)
34
33
  _string, method, first_param, second_param = *node
@@ -164,13 +163,17 @@ module RuboCop
164
163
  StringHelp::ESCAPED_CHAR_REGEXP =~ string
165
164
  end
166
165
 
166
+ def method_suffix(node)
167
+ node.loc.end ? node.loc.end.source : ''
168
+ end
169
+
167
170
  def remove_second_param(corrector, node, first_param)
168
171
  end_range =
169
172
  Parser::Source::Range.new(node.loc.expression.source_buffer,
170
173
  first_param.loc.expression.end_pos,
171
174
  node.loc.expression.end_pos)
172
175
 
173
- corrector.replace(end_range, CLOSING_PAREN)
176
+ corrector.replace(end_range, method_suffix(node))
174
177
  end
175
178
  end
176
179
  end
@@ -37,7 +37,8 @@ module RuboCop
37
37
  lambda do |corrector|
38
38
  name =
39
39
  case style
40
- when :semantic then command?(:raise, node) ? 'fail' : 'raise'
40
+ when :semantic
41
+ command_or_kernel_call?(:raise, node) ? 'fail' : 'raise'
41
42
  when :only_raise then 'raise'
42
43
  when :only_fail then 'fail'
43
44
  end
@@ -63,30 +64,42 @@ module RuboCop
63
64
  return unless node
64
65
 
65
66
  if style == :semantic
66
- each_command(method_name, node) do |send_node|
67
+ each_command_or_kernel_call(method_name, node) do |send_node|
67
68
  next if ignored_node?(send_node)
68
69
 
69
70
  add_offense(send_node, :selector, message(method_name))
70
71
  ignore_node(send_node)
71
72
  end
72
- else
73
- _receiver, selector, _args = *node
74
-
75
- if [:raise, :fail].include?(selector) && selector != method_name
76
- add_offense(node, :selector, message(method_name))
77
- end
73
+ elsif command_or_kernel_call?(method_name == :raise ? :fail : :raise,
74
+ node)
75
+ add_offense(node, :selector, message(method_name))
78
76
  end
79
77
  end
80
78
 
79
+ def command_or_kernel_call?(name, node)
80
+ command?(name, node) || kernel_call?(name, node)
81
+ end
82
+
83
+ def kernel_call?(name, node)
84
+ return false unless node.type == :send
85
+ receiver, selector, _args = *node
86
+
87
+ return false unless name == selector
88
+ return false unless receiver.const_type?
89
+
90
+ _, constant = *receiver
91
+ constant == :Kernel
92
+ end
93
+
81
94
  def allow(method_name, node)
82
- each_command(method_name, node) do |send_node|
95
+ each_command_or_kernel_call(method_name, node) do |send_node|
83
96
  ignore_node(send_node)
84
97
  end
85
98
  end
86
99
 
87
- def each_command(method_name, node)
100
+ def each_command_or_kernel_call(method_name, node)
88
101
  on_node(:send, node, :rescue) do |send_node|
89
- yield send_node if command?(method_name, send_node)
102
+ yield send_node if command_or_kernel_call?(method_name, send_node)
90
103
  end
91
104
  end
92
105
  end
@@ -103,6 +103,7 @@ module RuboCop
103
103
  def can_shorten?(block_args, block_body)
104
104
  # something { |x, y| ... }
105
105
  return false unless block_args.children.size == 1
106
+ return false if block_args.children.first.blockarg_type?
106
107
  return false unless block_body && block_body.type == :send
107
108
 
108
109
  receiver, _method_name, args = *block_body
@@ -97,8 +97,8 @@ module RuboCop
97
97
  file_errors.each do |cop, errors|
98
98
  errors.each do |e|
99
99
  handle_error(e,
100
- Rainbow("An error occurred while #{cop.name}" /
101
- " cop was inspecting #{file}.".red))
100
+ Rainbow("An error occurred while #{cop.name}" \
101
+ " cop was inspecting #{file}.").red)
102
102
  end
103
103
  end
104
104
  end
@@ -8,6 +8,14 @@ module RuboCop
8
8
  class ProgressFormatter < ClangStyleFormatter
9
9
  include TextUtil
10
10
 
11
+ DOT = '.'.freeze
12
+ GREEN_DOT = Rainbow(DOT).green.freeze
13
+
14
+ def initialize(output)
15
+ super
16
+ @dot = @output.tty? ? GREEN_DOT : DOT
17
+ end
18
+
11
19
  def started(target_files)
12
20
  super
13
21
  @offenses_for_files = {}
@@ -36,14 +44,14 @@ module RuboCop
36
44
  end
37
45
  end
38
46
 
39
- report_summary(inspected_files.count,
47
+ report_summary(inspected_files.size,
40
48
  @total_offense_count,
41
49
  @total_correction_count)
42
50
  end
43
51
 
44
52
  def report_file_as_mark(offenses)
45
53
  mark = if offenses.empty?
46
- green('.')
54
+ @dot
47
55
  else
48
56
  highest_offense = offenses.max_by(&:severity)
49
57
  colored_severity_code(highest_offense)
@@ -44,7 +44,7 @@ module RuboCop
44
44
  def lines
45
45
  @lines ||= begin
46
46
  all_lines = raw_source.lines.map(&:chomp)
47
- last_token_line = tokens.any? ? tokens.last.pos.line : all_lines.count
47
+ last_token_line = tokens.any? ? tokens.last.pos.line : all_lines.size
48
48
  result = []
49
49
  all_lines.each_with_index do |line, ix|
50
50
  break if ix >= last_token_line && line == '__END__'
@@ -26,7 +26,7 @@ module RuboCop
26
26
  def save(offenses, disabled_line_ranges, comments)
27
27
  FileUtils.mkdir_p(File.dirname(@path))
28
28
  preliminary_path = "#{@path}_#{rand(1_000_000_000)}"
29
- File.open(preliminary_path, 'w') do |f|
29
+ File.open(preliminary_path, 'wb') do |f|
30
30
  # The Hash[x.sort] call is a trick that converts a Hash with a default
31
31
  # block to a Hash without a default block. Thus making it possible to
32
32
  # dump.
@@ -108,7 +108,7 @@ module RuboCop
108
108
  end
109
109
 
110
110
  NON_CHANGING = [:color, :format, :formatters, :out, :debug, :fail_level,
111
- :cache, :fail_fast]
111
+ :cache, :fail_fast, :stdin]
112
112
 
113
113
  # Return the options given at invocation, minus the ones that have no
114
114
  # effect on which offenses and disabled line ranges are found, and thus
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.34.0'
6
+ STRING = '0.34.1'
7
7
 
8
8
  MSG = '%s (using Parser %s, running on %s %s %s)'
9
9
 
data/relnotes/v0.34.0.md CHANGED
@@ -4,7 +4,7 @@ functionality will speed up tremendously consecutive RuboCop runs on
4
4
  the same codebase.
5
5
 
6
6
  Another news to share with you - the project now has a crowdfunding
7
- campaign [here](https://salt.bountysource.com/). If you like RuboCop
7
+ campaign [here](https://salt.bountysource.com/teams/rubocop). If you like RuboCop
8
8
  you might consider supporting its development.
9
9
 
10
10
  Enjoy!
@@ -0,0 +1,129 @@
1
+ ## RuboCop 0.34.1
2
+
3
+ ### Bug Fixes
4
+
5
+ * [#2212](https://github.com/bbatsov/rubocop/issues/2212): Handle methods without parentheses in auto-correct. ([@karreiro][])
6
+ * [#2214](https://github.com/bbatsov/rubocop/pull/2214): Fix `File name too long error` when `STDIN` option is provided. ([@mrfoto][])
7
+ * [#2217](https://github.com/bbatsov/rubocop/issues/2217): Allow block arguments in `Style/SymbolProc`. ([@lumeet][])
8
+ * [#2213](https://github.com/bbatsov/rubocop/issues/2213): Write to cache with binary encoding to avoid transcoding exceptions in some locales. ([@jonas054][])
9
+ * [#2218](https://github.com/bbatsov/rubocop/issues/2218): Fix loading config error when safe yaml is only partially loaded. ([@maxjacobson][])
10
+ * [#2161](https://github.com/bbatsov/rubocop/issues/2161): Allow an explicit receiver (except `Kernel`) in `Style/SignalException`. ([@lumeet][])
11
+
12
+ [@bbatsov]: https://github.com/bbatsov
13
+ [@jonas054]: https://github.com/jonas054
14
+ [@yujinakayama]: https://github.com/yujinakayama
15
+ [@dblock]: https://github.com/dblock
16
+ [@nevir]: https://github.com/nevir
17
+ [@daviddavis]: https://github.com/daviddavis
18
+ [@sds]: https://github.com/sds
19
+ [@fancyremarker]: https://github.com/fancyremarker
20
+ [@sinisterchipmunk]: https://github.com/sinisterchipmunk
21
+ [@vonTronje]: https://github.com/vonTronje
22
+ [@agrimm]: https://github.com/agrimm
23
+ [@pmenglund]: https://github.com/pmenglund
24
+ [@chulkilee]: https://github.com/chulkilee
25
+ [@codez]: https://github.com/codez
26
+ [@emou]: https://github.com/emou
27
+ [@skanev]: http://github.com/skanev
28
+ [@claco]: http://github.com/claco
29
+ [@rifraf]: http://github.com/rifraf
30
+ [@scottmatthewman]: https://github.com/scottmatthewman
31
+ [@ma2gedev]: http://github.com/ma2gedev
32
+ [@jeremyolliver]: https://github.com/jeremyolliver
33
+ [@hannestyden]: https://github.com/hannestyden
34
+ [@geniou]: https://github.com/geniou
35
+ [@jkogara]: https://github.com/jkogara
36
+ [@tmorris-fiksu]: https://github.com/tmorris-fiksu
37
+ [@mockdeep]: https://github.com/mockdeep
38
+ [@hiroponz]: https://github.com/hiroponz
39
+ [@tamird]: https://github.com/tamird
40
+ [@fshowalter]: https://github.com/fshowalter
41
+ [@cschramm]: https://github.com/cschramm
42
+ [@bquorning]: https://github.com/bquorning
43
+ [@bcobb]: https://github.com/bcobb
44
+ [@irrationalfab]: https://github.com/irrationalfab
45
+ [@tommeier]: https://github.com/tommeier
46
+ [@sfeldon]: https://github.com/sfeldon
47
+ [@biinari]: https://github.com/biinari
48
+ [@barunio]: https://github.com/barunio
49
+ [@molawson]: https://github.com/molawson
50
+ [@wndhydrnt]: https://github.com/wndhydrnt
51
+ [@ggilder]: https://github.com/ggilder
52
+ [@salbertson]: https://github.com/salbertson
53
+ [@camilleldn]: https://github.com/camilleldn
54
+ [@mcls]: https://github.com/mcls
55
+ [@yous]: https://github.com/yous
56
+ [@vrthra]: https://github.com/vrthra
57
+ [@SkuliOskarsson]: https://github.com/SkuliOskarsson
58
+ [@jspanjers]: https://github.com/jspanjers
59
+ [@sch1zo]: https://github.com/sch1zo
60
+ [@smangelsdorf]: https://github.com/smangelsdorf
61
+ [@mvz]: https://github.com/mvz
62
+ [@jfelchner]: https://github.com/jfelchner
63
+ [@janraasch]: https://github.com/janraasch
64
+ [@jcarbo]: https://github.com/jcarbo
65
+ [@oneamtu]: https://github.com/oneamtu
66
+ [@toy]: https://github.com/toy
67
+ [@Koronen]: https://github.com/Koronen
68
+ [@blainesch]: https://github.com/blainesch
69
+ [@marxarelli]: https://github.com/marxarelli
70
+ [@katieschilling]: https://github.com/katieschilling
71
+ [@kakutani]: https://github.com/kakutani
72
+ [@rrosenblum]: https://github.com/rrosenblum
73
+ [@mattjmcnaughton]: https://github.com/mattjmcnaughton
74
+ [@huerlisi]: https://github.com/huerlisi
75
+ [@volkert]: https://github.com/volkert
76
+ [@lumeet]: https://github.com/lumeet
77
+ [@mmozuras]: https://github.com/mmozuras
78
+ [@d4rk5eed]: https://github.com/d4rk5eed
79
+ [@cshaffer]: https://github.com/cshaffer
80
+ [@eitoball]: https://github.com/eitoball
81
+ [@iainbeeston]: https://github.com/iainbeeston
82
+ [@pimterry]: https://github.com/pimterry
83
+ [@palkan]: https://github.com/palkan
84
+ [@jdoconnor]: https://github.com/jdoconnor
85
+ [@meganemura]: https://github.com/meganemura
86
+ [@zvkemp]: https://github.com/zvkemp
87
+ [@vassilevsky]: https://github.com/vassilevsky
88
+ [@gerry3]: https://github.com/gerry3
89
+ [@ypresto]: https://github.com/ypresto
90
+ [@clowder]: https://github.com/clowder
91
+ [@mudge]: https://github.com/mudge
92
+ [@mzp]: https://github.com/mzp
93
+ [@bankair]: https://github.com/bankair
94
+ [@crimsonknave]: https://github.com/crimsonknave
95
+ [@renuo]: https://github.com/renuo
96
+ [@sdeframond]: https://github.com/sdeframond
97
+ [@til]: https://github.com/til
98
+ [@carhartl]: https://github.com/carhartl
99
+ [@dylandavidson]: https://github.com/dylandavidson
100
+ [@tmr08c]: https://github.com/tmr08c
101
+ [@hbd225]: https://github.com/hbd225
102
+ [@l8nite]: https://github.com/l8nite
103
+ [@sumeet]: https://github.com/sumeet
104
+ [@ojab]: https://github.com/ojab
105
+ [@chastell]: https://github.com/chastell
106
+ [@glasnt]: https://github.com/glasnt
107
+ [@crazydog115]: https://github.com/crazydog115
108
+ [@RGBD]: https://github.com/RGBD
109
+ [@panthomakos]: https://github.com/panthomakos
110
+ [@matugm]: https://github.com/matugm
111
+ [@m1foley]: https://github.com/m1foley
112
+ [@tejasbubane]: https://github.com/tejasbubane
113
+ [@bmorrall]: https://github.com/bmorrall
114
+ [@fphilipe]: https://github.com/fphilipe
115
+ [@gotrevor]: https://github.com/gotrevor
116
+ [@awwaiid]: https://github.com/awwaiid
117
+ [@segiddins]: https://github.com/segiddins
118
+ [@urbanautomaton]: https://github.com/urbanautomaton.com
119
+ [@unmanbearpig]: https://github.com/unmanbearpig
120
+ [@maxjacobson]: https://github.com/maxjacobson
121
+ [@sliuu]: https://github.com/sliuu
122
+ [@edmz]: https://github.com/edmz
123
+ [@syndbg]: https://github.com/syndbg
124
+ [@wli]: https://github.com/wli
125
+ [@caseywebdev]: https://github.com/caseywebdev
126
+ [@MGerrior]: https://github.com/MGerrior
127
+ [@imtayadeway]: https://github.com/imtayadeway
128
+ [@mrfoto]: https://github.com/mrfoto
129
+ [@karreiro]: https://github.com/karreiro
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.34.0
4
+ version: 0.34.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-09-05 00:00:00.000000000 Z
13
+ date: 2015-09-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow
@@ -532,6 +532,7 @@ files:
532
532
  - relnotes/v0.32.1.md
533
533
  - relnotes/v0.33.0.md
534
534
  - relnotes/v0.34.0.md
535
+ - relnotes/v0.34.1.md
535
536
  - rubocop.gemspec
536
537
  homepage: http://github.com/bbatsov/rubocop
537
538
  licenses: