rubocop 0.26.0 → 0.26.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: 800751d069262c05789ef58ff88e1b89cc84926f
4
- data.tar.gz: 87c0f2ae5445f9a95671dc7bdcc949545adcbf2f
3
+ metadata.gz: 8dd2c1c375e842c50e244af47472085016e9214e
4
+ data.tar.gz: 355612f83c8f6774162368b1dfdaaa677bd9dbb9
5
5
  SHA512:
6
- metadata.gz: 85b985829442ce2e4fe87a526c5f214a78ea7956b0589e34620473e426a62783e2944e46acb28cef8fb7a2bd4e84e11e00fbf7e5f86025d6f5f88dc19047d27d
7
- data.tar.gz: 3908cc133515d66b1d8e861c3caa7fd1e5a7eab03a4217a03c856586d9f2f1d9f31b4c949cd8c6aabc870dc5d2655a3bbc530eb4be17cd4c4550205e6710a626
6
+ metadata.gz: 3b9b20e7c9eca832d37b245745fe68c9b6d2bb0132c98b752ff530a2988e4d65cffd9d17d1d3a06785a75010dda8d69f827460cf1a141db6c6ca3da614f34e01
7
+ data.tar.gz: 909ee8bd3302d9c32c9340980d67f03b757de1745523f38d914173ec48203edf224145cc0890e79cdb6336ed7cea03aa0b1169692aec3db31ca3aa6f4fcea4c9
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.26.1 (18/09/2014)
6
+
7
+ ### Bugs fixed
8
+
9
+ * [#1326](https://github.com/bbatsov/rubocop/issues/1326): Fix problem in `SpaceInsideParens` with detecting space inside parentheses used for grouping expressions. ([@jonas054][])
10
+ * [#1335](https://github.com/bbatsov/rubocop/issues/1335): Restrict URI schemes permitted by `LineLength` when `AllowURI` is enabled. ([@smangelsdorf][])
11
+ * [#1339](https://github.com/bbatsov/rubocop/issues/1339): Handle `eql?` and `equal?` in `OpMethod`. ([@bbatsov][])
12
+ * [#1340](https://github.com/bbatsov/rubocop/issues/1340): Fix crash in `Style/SymbolProc` cop when the block calls a method with no explicit receiver. ([@smangelsdorf][])
13
+
5
14
  ## 0.26.0 (03/09/2014)
6
15
 
7
16
  ### New features
@@ -1093,3 +1102,4 @@
1093
1102
  [@SkuliOskarsson]: https://github.com/SkuliOskarsson
1094
1103
  [@jspanjers]: https://github.com/jspanjers
1095
1104
  [@sch1zo]: https://github.com/sch1zo
1105
+ [@smangelsdorf]: https://github.com/smangelsdorf
data/README.md CHANGED
@@ -5,7 +5,9 @@
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
7
 
8
- # RuboCop
8
+ <p align="center">
9
+ <img src="https://raw.github.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
10
+ </p>
9
11
 
10
12
  > Role models are important. <br/>
11
13
  > -- Officer Alex J. Murphy / RoboCop
@@ -68,6 +70,7 @@ release.**
68
70
  - [Creating Custom Formatter](#creating-custom-formatter)
69
71
  - [Using Custom Formatter in Command Line](#using-custom-formatter-in-command-line)
70
72
  - [Team](#team)
73
+ - [Logo](#logo)
71
74
  - [Contributors](#contributors)
72
75
  - [Mailing List](#mailing-list)
73
76
  - [Changelog](#changelog)
@@ -766,6 +769,14 @@ Here's a list of RuboCop's core developers:
766
769
  * [Yuji Nakayama](https://github.com/yujinakayama)
767
770
  * [Evgeni Dzhelyov](https://github.com/edzhelyov)
768
771
 
772
+ ## Logo
773
+
774
+ RuboCop's logo was created by [Dimiter Petrov](https://www.chadomoto.com/). You can find the logo in various
775
+ formats [here](https://github.com/bbatsov/rubocop/tree/master/logo).
776
+
777
+ The logo is licensed under a
778
+ [Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/deed.en_GB).
779
+
769
780
  ## Contributors
770
781
 
771
782
  Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
data/Rakefile CHANGED
@@ -14,9 +14,7 @@ require 'rake'
14
14
  require 'rspec/core'
15
15
  require 'rspec/core/rake_task'
16
16
  require 'rubocop/rake_task'
17
- RSpec::Core::RakeTask.new(:spec) do |spec|
18
- spec.pattern = FileList['spec/**/*_spec.rb']
19
- end
17
+ RSpec::Core::RakeTask.new(:spec)
20
18
 
21
19
  desc 'Run RSpec with code coverage'
22
20
  task :coverage do
@@ -503,6 +503,9 @@ Metrics/CyclomaticComplexity:
503
503
  Metrics/LineLength:
504
504
  Max: 80
505
505
  AllowURI: true
506
+ URISchemes:
507
+ - http
508
+ - https
506
509
 
507
510
  Metrics/MethodLength:
508
511
  CountComments: false # count full line comments?
@@ -142,6 +142,7 @@ Style/CommentAnnotation:
142
142
  Description: >-
143
143
  Checks formatting of special comments
144
144
  (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
145
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
145
146
  Enabled: true
146
147
 
147
148
  Style/CommentIndentation:
@@ -155,6 +156,7 @@ Style/ConstantName:
155
156
 
156
157
  Style/DefWithParentheses:
157
158
  Description: 'Use def with parentheses when there are arguments.'
159
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens'
158
160
  Enabled: true
159
161
 
160
162
  Style/DeprecatedHashMethods:
@@ -335,6 +337,7 @@ Style/ModuleFunction:
335
337
 
336
338
  Style/MultilineBlockChain:
337
339
  Description: 'Avoid multi-line chains of blocks.'
340
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks'
338
341
  Enabled: true
339
342
 
340
343
  Style/MultilineBlockLayout:
@@ -447,6 +450,7 @@ Style/RaiseArgs:
447
450
 
448
451
  Style/RedundantBegin:
449
452
  Description: "Don't use begin blocks when they are not needed."
453
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit'
450
454
  Enabled: true
451
455
 
452
456
  Style/RedundantException:
@@ -64,7 +64,7 @@ module RuboCop
64
64
  unscanned_position = 0
65
65
 
66
66
  loop do
67
- match_data = string.match(URI.regexp, unscanned_position)
67
+ match_data = string.match(uri_regexp, unscanned_position)
68
68
  break unless match_data
69
69
 
70
70
  uri_ish_string = match_data[0]
@@ -82,6 +82,10 @@ module RuboCop
82
82
  rescue
83
83
  false
84
84
  end
85
+
86
+ def uri_regexp
87
+ URI.regexp(cop_config['URISchemes'])
88
+ end
85
89
  end
86
90
  end
87
91
  end
@@ -8,17 +8,25 @@ module RuboCop
8
8
  class OpMethod < Cop
9
9
  MSG = 'When defining the `%s` operator, name its argument `other`.'
10
10
 
11
+ OP_LIKE_METHODS = [:eql?, :equal?]
12
+
11
13
  BLACKLISTED = [:+@, :-@, :[], :[]=, :<<]
12
14
 
13
15
  TARGET_ARGS = [s(:args, s(:arg, :other)), s(:args, s(:arg, :_other))]
14
16
 
15
17
  def on_def(node)
16
18
  name, args, _body = *node
17
- return unless name !~ /\A\w/ && !BLACKLISTED.include?(name) &&
18
- args.children.size == 1 && !TARGET_ARGS.include?(args)
19
+ return unless op_method?(name) &&
20
+ args.children.size == 1 &&
21
+ !TARGET_ARGS.include?(args)
19
22
 
20
23
  add_offense(args.children[0], :expression, format(MSG, name))
21
24
  end
25
+
26
+ def op_method?(name)
27
+ return false if BLACKLISTED.include?(name)
28
+ name !~ /\A\w/ || OP_LIKE_METHODS.include?(name)
29
+ end
22
30
  end
23
31
  end
24
32
  end
@@ -9,7 +9,7 @@ module RuboCop
9
9
  #
10
10
  # @example
11
11
  #
12
- # def test
12
+ # def redundant
13
13
  # begin
14
14
  # ala
15
15
  # bala
@@ -17,6 +17,13 @@ module RuboCop
17
17
  # something
18
18
  # end
19
19
  # end
20
+ #
21
+ # def preferred
22
+ # ala
23
+ # bala
24
+ # rescue StandardError => e
25
+ # something
26
+ # end
20
27
  class RedundantBegin < Cop
21
28
  include OnMethod
22
29
 
@@ -8,7 +8,7 @@ module RuboCop
8
8
  include SpaceInside
9
9
 
10
10
  def specifics
11
- [:tLPAREN2, :tRPAREN, 'parentheses']
11
+ [[:tLPAREN, :tLPAREN2], :tRPAREN, 'parentheses']
12
12
  end
13
13
  end
14
14
  end
@@ -24,21 +24,9 @@ module RuboCop
24
24
  return if ignored_method?(bmethod_name)
25
25
  # File.open(file) { |f| f.readlines }
26
26
  return if bargs
27
- # something { |x, y| ... }
28
- return unless block_args.children.size == 1
29
- return unless block_body && block_body.type == :send
30
-
31
- receiver, method_name, args = *block_body
32
-
33
- # method in block must be invoked on a lvar without args
34
- return if args
35
- return if receiver.type != :lvar
36
-
37
- block_arg_name, = *block_args.children.first
38
- receiver_name, = *receiver
39
-
40
- return if block_arg_name != receiver_name
27
+ return unless can_shorten?(block_args, block_body)
41
28
 
29
+ _receiver, method_name, _args = *block_body
42
30
  add_offense(node,
43
31
  :expression,
44
32
  format(MSG,
@@ -65,6 +53,23 @@ module RuboCop
65
53
  def ignored_method?(name)
66
54
  ignored_methods.include?(name.to_s)
67
55
  end
56
+
57
+ def can_shorten?(block_args, block_body)
58
+ # something { |x, y| ... }
59
+ return false unless block_args.children.size == 1
60
+ return false unless block_body && block_body.type == :send
61
+
62
+ receiver, _method_name, args = *block_body
63
+
64
+ # method in block must be invoked on a lvar without args
65
+ return false if args
66
+ return false unless receiver && receiver.type == :lvar
67
+
68
+ block_arg_name, = *block_args.children.first
69
+ receiver_name, = *receiver
70
+
71
+ block_arg_name == receiver_name
72
+ end
68
73
  end
69
74
  end
70
75
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.26.0'
6
+ STRING = '0.26.1'
7
7
 
8
8
  MSG = '%s (using Parser %s, running on %s %s %s)'
9
9
 
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ RuboCop 0.26.1 is a bugfix-only release. Below is a list of the bugs we've fixed since 0.26.0:
2
+
3
+ ### Bugs fixed
4
+
5
+ * [#1326](https://github.com/bbatsov/rubocop/issues/1326): Fix problem in `SpaceInsideParens` with detecting space inside parentheses used for grouping expressions. ([@jonas054][])
6
+ * [#1335](https://github.com/bbatsov/rubocop/issues/1335): Restrict URI schemes permitted by `LineLength` when `AllowURI` is enabled. ([@smangelsdorf][])
7
+ * [#1339](https://github.com/bbatsov/rubocop/issues/1339): Handle `eql?` and `equal?` in `OpMethod`. ([@bbatsov][])
8
+ * [#1340](https://github.com/bbatsov/rubocop/issues/1340): Fix crash in `Style/SymbolProc` cop when the block calls a method with no explicit receiver. ([@smangelsdorf][])
9
+
10
+ [@bbatsov]: https://github.com/bbatsov
11
+ [@jonas054]: https://github.com/jonas054
12
+ [@smangelsdorf]: https://github.com/smangelsdorf
@@ -589,7 +589,7 @@ describe RuboCop::CLI, :isolated_environment do
589
589
  expect(cli.run(['--auto-gen-config'])).to eq(1)
590
590
  expect(IO.readlines('.rubocop_todo.yml')[7..-1].map(&:chomp))
591
591
  .to eq(['# Offense count: 1',
592
- '# Configuration parameters: AllowURI.',
592
+ '# Configuration parameters: AllowURI, URISchemes.',
593
593
  'Metrics/LineLength:',
594
594
  ' Max: 85',
595
595
  '',
@@ -652,7 +652,7 @@ describe RuboCop::CLI, :isolated_environment do
652
652
  'again.',
653
653
  '',
654
654
  '# Offense count: 2',
655
- '# Configuration parameters: AllowURI.',
655
+ '# Configuration parameters: AllowURI, URISchemes.',
656
656
  'Metrics/LineLength:',
657
657
  ' Max: 90',
658
658
  '',
@@ -195,7 +195,8 @@ describe RuboCop::ConfigLoader do
195
195
  'https://github.com/bbatsov/ruby-style-guide#80-character-limits',
196
196
  'Enabled' => true,
197
197
  'Max' => 77,
198
- 'AllowURI' => true
198
+ 'AllowURI' => true,
199
+ 'URISchemes' => %w(http https)
199
200
  },
200
201
  'Metrics/MethodLength' => {
201
202
  'Description' =>
@@ -79,6 +79,10 @@ describe RuboCop::Cop::Metrics::LineLength, :config do
79
79
 
80
80
  context 'and an error other than URI::InvalidURIError is raised ' \
81
81
  'while validating an URI-ish string' do
82
+ let(:cop_config) do
83
+ { 'Max' => 80, 'AllowURI' => true, 'URISchemes' => %w(LDAP) }
84
+ end
85
+
82
86
  # rubocop:disable Metrics/LineLength
83
87
  let(:source) { <<-END }
84
88
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxzxxxxxxxxxxx = LDAP::DEFAULT_GROUP_UNIQUE_MEMBER_LIST_KEY
@@ -89,6 +93,30 @@ describe RuboCop::Cop::Metrics::LineLength, :config do
89
93
  expect { inspect_source(cop, source) }.not_to raise_error
90
94
  end
91
95
  end
96
+
97
+ context 'and the URL does not have a http(s) scheme' do
98
+ # rubocop:disable Metrics/LineLength
99
+ let(:source) { <<-END }
100
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxzxxxxxxxxxxx = 'otherprotocol://a.very.long.line.which.violates.LineLength/sadf'
101
+ END
102
+ # rubocop:enable Metrics/LineLength
103
+
104
+ it 'rejects the line' do
105
+ inspect_source(cop, source)
106
+ expect(cop.offenses.size).to eq(1)
107
+ end
108
+
109
+ context 'and the scheme has been configured' do
110
+ let(:cop_config) do
111
+ { 'Max' => 80, 'AllowURI' => true, 'URISchemes' => %w(otherprotocol) }
112
+ end
113
+
114
+ it 'accepts the line' do
115
+ inspect_source(cop, source)
116
+ expect(cop.offenses).to be_empty
117
+ end
118
+ end
119
+ end
92
120
  end
93
121
 
94
122
  context 'when AllowURI option is disabled' do
@@ -5,14 +5,17 @@ require 'spec_helper'
5
5
  describe RuboCop::Cop::Style::OpMethod do
6
6
  subject(:cop) { described_class.new }
7
7
 
8
- it 'registers an offense for arg not named other' do
9
- inspect_source(cop,
10
- ['def +(another)',
11
- ' another',
12
- 'end'])
13
- expect(cop.offenses.size).to eq(1)
14
- expect(cop.messages)
15
- .to eq(['When defining the `+` operator, name its argument `other`.'])
8
+ [:+, :eql?, :equal?].each do |op|
9
+ it "registers an offense for #{op} with arg not named other" do
10
+ inspect_source(cop,
11
+ ["def #{op}(another)",
12
+ ' another',
13
+ 'end'])
14
+ expect(cop.offenses.size).to eq(1)
15
+ expect(cop.messages)
16
+ .to eq(["When defining the `#{op}` operator, " \
17
+ 'name its argument `other`.'])
18
+ end
16
19
  end
17
20
 
18
21
  it 'works properly even if the argument not surrounded with braces' do
@@ -7,10 +7,8 @@ describe RuboCop::Cop::Style::SpaceInsideParens do
7
7
 
8
8
  it 'registers an offense for spaces inside parens' do
9
9
  inspect_source(cop, ['f( 3)',
10
- 'g(3 )'])
11
- expect(cop.messages).to eq(
12
- ['Space inside parentheses detected.',
13
- 'Space inside parentheses detected.'])
10
+ 'g = (a + 3 )'])
11
+ expect(cop.messages).to eq(['Space inside parentheses detected.'] * 2)
14
12
  end
15
13
 
16
14
  it 'accepts parentheses in block parameter list' do
@@ -39,8 +37,8 @@ describe RuboCop::Cop::Style::SpaceInsideParens do
39
37
 
40
38
  it 'auto-corrects unwanted space' do
41
39
  new_source = autocorrect_source(cop, ['f( 3)',
42
- 'g(3 )'])
40
+ 'g = ( a + 3 )'])
43
41
  expect(new_source).to eq(['f(3)',
44
- 'g(3)'].join("\n"))
42
+ 'g = (a + 3)'].join("\n"))
45
43
  end
46
44
  end
@@ -73,4 +73,9 @@ describe RuboCop::Cop::Style::SymbolProc, :config do
73
73
  corrected = autocorrect_source(cop, ['coll.map { |s| s.upcase }'])
74
74
  expect(corrected).to eq 'coll.map(&:upcase)'
75
75
  end
76
+
77
+ it 'does not crash with a bare method call' do
78
+ run = -> { inspect_source(cop, ['coll.map { |s| bare_method }']) }
79
+ expect(&run).not_to raise_error
80
+ end
76
81
  end
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.26.0
4
+ version: 0.26.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: 2014-09-03 00:00:00.000000000 Z
13
+ date: 2014-09-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rainbow
@@ -454,6 +454,10 @@ files:
454
454
  - lib/rubocop/target_finder.rb
455
455
  - lib/rubocop/token.rb
456
456
  - lib/rubocop/version.rb
457
+ - logo/rubo-logo-horizontal.png
458
+ - logo/rubo-logo-square.png
459
+ - logo/rubo-logo-symbol.png
460
+ - logo/rubocop-final-logo.eps
457
461
  - relnotes/v0.19.0.md
458
462
  - relnotes/v0.19.1.md
459
463
  - relnotes/v0.20.0.md
@@ -465,6 +469,7 @@ files:
465
469
  - relnotes/v0.24.1.md
466
470
  - relnotes/v0.25.0.md
467
471
  - relnotes/v0.26.0.md
472
+ - relnotes/v0.26.1.md
468
473
  - rubocop.gemspec
469
474
  - spec/.rubocop.yml
470
475
  - spec/isolated_environment_spec.rb