barsoom_utils 0.2.0.64 → 0.2.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cccdc6fc4265ea2cd6ae9f045fef87d7ef796ca5b330c35abff20006872c59d
4
- data.tar.gz: b4fdf5c17d092dad93656925955f87cbbd0590307269ae7acea6a30b49127474
3
+ metadata.gz: f85cdf8a1dce5c728cf624248b7a98af640dd2c1fb331bb3a3bb99b5e9b80a2c
4
+ data.tar.gz: 91204dcd93f3458155f0e5b4e6d93875656601f965eb21f8602641ba87874d99
5
5
  SHA512:
6
- metadata.gz: 7cc2fec26acb707bcff01af5f29ea62db07b41c90f157687d9591a452fe3281a8a3a7111063418daeb4da0560621995b58412db59c94691e33c7d0949a519e6c
7
- data.tar.gz: d44aebbadb9488b219d881a61f35da778168894e2b4cf23468f34b82ed02741dd02c112c85fae1850b11e8875b24ba4db16dfc778c1267d397bf65eea989d3dc
6
+ metadata.gz: fd327952fc415218f8346b1a098a0cdb6406cd828876a7f62d993ed7121046f6fb05471ebf0c077052c5d30faac2357c1488ccfc7585115a088decf512c59860
7
+ data.tar.gz: 749e5a3e143553728f50934a73559cfbcb1fa03390d9e168e71ded9ba100e1f39740af8c95b361805e4d9a82a3e8786f41cb2f6f21e8946991d0f151d9247a7b
data/Gemfile CHANGED
@@ -15,5 +15,4 @@ group :development, :test do
15
15
  gem "redis"
16
16
  gem "rspec"
17
17
  gem "rubocop"
18
- gem "rubocop-rspec" # For `expect_offense` test helpers.
19
18
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.64
1
+ 0.2.0.65
data/shared_rubocop.yml CHANGED
@@ -1,8 +1,5 @@
1
1
  # Configuration for the Rubocop code linting tool. See README.
2
2
 
3
- require:
4
- - barsoom_utils/rubocop
5
-
6
3
  AllCops:
7
4
  ActiveSupportExtensionsEnabled: true
8
5
  DisabledByDefault: true
@@ -231,10 +228,10 @@ Style/RedundantBegin:
231
228
  Style/MethodCallWithoutArgsParentheses:
232
229
  Enabled: true
233
230
 
234
- # Replaces Style/TrailingCommaInArguments, which doesn't support our preferred style:
235
- # require trailing comma only when `)` is on its own line.
236
- Barsoom/TrailingCommaInArguments:
231
+ # https://docs.rubocop.org/rubocop/cops_style.html#enforcedstyleformultiline-comma
232
+ Style/TrailingCommaInArguments:
237
233
  Enabled: true
234
+ EnforcedStyleForMultiline: diff_comma
238
235
 
239
236
  # https://docs.rubocop.org/rubocop/cops_style.html#stylereturnnilinpredicatemethoddefinition
240
237
  Style/ReturnNilInPredicateMethodDefinition:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barsoom_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.64
4
+ version: 0.2.0.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Skogberg
@@ -29,8 +29,6 @@ files:
29
29
  - lib/barsoom_utils.rb
30
30
  - lib/barsoom_utils/exception_notifier.rb
31
31
  - lib/barsoom_utils/feature_toggle.rb
32
- - lib/barsoom_utils/rubocop.rb
33
- - lib/barsoom_utils/rubocop/cop/barsoom/trailing_comma_in_arguments.rb
34
32
  - lib/barsoom_utils/spec/debug_helpers.rb
35
33
  - lib/barsoom_utils/version.rb
36
34
  - script/test
@@ -38,7 +36,6 @@ files:
38
36
  - shared_rubocop_rails.yml
39
37
  - spec/exception_notifier_spec.rb
40
38
  - spec/feature_toggle_spec.rb
41
- - spec/rubocop/cop/barsoom/trailing_comma_in_arguments_spec.rb
42
39
  - spec/spec/debug_helpers_spec.rb
43
40
  - spec/spec_helper.rb
44
41
  homepage: https://dev.auctionet.com/
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Barsoom
6
- # Require a trailing comma in multiline method arguments when the
7
- # closing `)` is on its own line. Disallow it when `)` is on the
8
- # same line as the last argument.
9
- #
10
- # This differs from the built-in `Style/TrailingCommaInArguments`:
11
- # - `comma` disallows trailing commas when args share a line.
12
- # - `consistent_comma` requires them even when `)` is on the same line.
13
- #
14
- # @example
15
- # # good
16
- # foo(
17
- # a,
18
- # b,
19
- # )
20
- #
21
- # # good – args sharing a line is fine as long as there's a trailing comma
22
- # foo(
23
- # a, b,
24
- # )
25
- #
26
- # # good – single-line
27
- # foo(a, b)
28
- #
29
- # # good – closing paren on same line as last arg
30
- # foo(
31
- # a, b)
32
- #
33
- # # bad – missing trailing comma
34
- # foo(
35
- # a,
36
- # b
37
- # )
38
- #
39
- # # bad – trailing comma but closing paren on same line
40
- # foo(
41
- # a, b,)
42
- class TrailingCommaInArguments < Base
43
- extend AutoCorrector
44
-
45
- MSG_MISSING = "Put a trailing comma after the last argument when `)` is on the next line."
46
- MSG_UNWANTED = "Remove the trailing comma when `)` is on the same line as the last argument."
47
-
48
- def on_send(node)
49
- check(node)
50
- end
51
- alias on_csend on_send
52
-
53
- private
54
-
55
- def check(node)
56
- return unless node.arguments? && node.parenthesized?
57
-
58
- close_paren_line = node.source_range.end.line
59
- last_arg = node.last_argument
60
- last_arg_line = last_arg.source_range.end.line
61
-
62
- return if close_paren_line == last_arg_line && close_paren_line == node.first_argument.first_line
63
-
64
- # A trailing comma after `&` is a syntax error.
65
- return if last_arg.block_pass_type?
66
-
67
- trailing_comma = trailing_comma_token(node)
68
- paren_on_own_line = close_paren_line > last_arg_line
69
-
70
- if paren_on_own_line && !trailing_comma
71
- add_offense_missing(last_arg)
72
- elsif !paren_on_own_line && trailing_comma
73
- add_offense_unwanted(trailing_comma)
74
- end
75
- end
76
-
77
- def add_offense_missing(last_arg)
78
- add_offense(last_arg, message: MSG_MISSING) do |corrector|
79
- corrector.insert_after(last_arg, ",")
80
- end
81
- end
82
-
83
- def add_offense_unwanted(comma_token)
84
- range = comma_token.pos
85
- add_offense(range, message: MSG_UNWANTED) do |corrector|
86
- corrector.remove(range)
87
- end
88
- end
89
-
90
- def trailing_comma_token(node)
91
- close_paren_idx = node.loc.end
92
- tokens = processed_source.tokens
93
-
94
- # Find the non-whitespace token just before the closing paren.
95
- tokens.reverse_each do |token|
96
- next if token.pos.end_pos > close_paren_idx.begin_pos
97
- next if token.comment? || token.type == :tNL
98
- return token if token.comma?
99
- return nil
100
- end
101
- end
102
- end
103
- end
104
- end
105
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "rubocop/cop/barsoom/trailing_comma_in_arguments"
@@ -1,179 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubocop"
4
- require "rubocop/rspec/support"
5
- require "barsoom_utils/rubocop"
6
-
7
- RSpec.describe RuboCop::Cop::Barsoom::TrailingCommaInArguments, :config do
8
- include RuboCop::RSpec::ExpectOffense
9
-
10
- context "when closing paren is on its own line" do
11
- it "registers an offense when trailing comma is missing" do
12
- expect_offense(<<~RUBY)
13
- foo(
14
- a,
15
- b
16
- ^ Put a trailing comma after the last argument when `)` is on the next line.
17
- )
18
- RUBY
19
-
20
- expect_correction(<<~RUBY)
21
- foo(
22
- a,
23
- b,
24
- )
25
- RUBY
26
- end
27
-
28
- it "accepts trailing comma" do
29
- expect_no_offenses(<<~RUBY)
30
- foo(
31
- a,
32
- b,
33
- )
34
- RUBY
35
- end
36
-
37
- it "accepts trailing comma when args share a line" do
38
- expect_no_offenses(<<~RUBY)
39
- foo(
40
- a, b,
41
- )
42
- RUBY
43
- end
44
-
45
- it "registers an offense for missing comma when args share a line" do
46
- expect_offense(<<~RUBY)
47
- foo(
48
- a, b
49
- ^ Put a trailing comma after the last argument when `)` is on the next line.
50
- )
51
- RUBY
52
-
53
- expect_correction(<<~RUBY)
54
- foo(
55
- a, b,
56
- )
57
- RUBY
58
- end
59
- end
60
-
61
- context "when closing paren is on the same line as last arg" do
62
- it "registers an offense when trailing comma is present" do
63
- expect_offense(<<~RUBY)
64
- foo(
65
- a,
66
- b,)
67
- ^ Remove the trailing comma when `)` is on the same line as the last argument.
68
- RUBY
69
-
70
- expect_correction(<<~RUBY)
71
- foo(
72
- a,
73
- b)
74
- RUBY
75
- end
76
-
77
- it "accepts no trailing comma" do
78
- expect_no_offenses(<<~RUBY)
79
- foo(
80
- a,
81
- b)
82
- RUBY
83
- end
84
- end
85
-
86
- context "single-line calls" do
87
- it "accepts no trailing comma" do
88
- expect_no_offenses(<<~RUBY)
89
- foo(a, b)
90
- RUBY
91
- end
92
-
93
- it "accepts a single argument" do
94
- expect_no_offenses(<<~RUBY)
95
- foo(a)
96
- RUBY
97
- end
98
- end
99
-
100
- context "safe navigation calls" do
101
- it "registers an offense when trailing comma is missing" do
102
- expect_offense(<<~RUBY)
103
- foo&.bar(
104
- a,
105
- b
106
- ^ Put a trailing comma after the last argument when `)` is on the next line.
107
- )
108
- RUBY
109
-
110
- expect_correction(<<~RUBY)
111
- foo&.bar(
112
- a,
113
- b,
114
- )
115
- RUBY
116
- end
117
- end
118
-
119
- context "with keyword arguments" do
120
- it "registers an offense when trailing comma is missing" do
121
- expect_offense(<<~RUBY)
122
- foo(
123
- key: "value"
124
- ^^^^^^^^^^^^ Put a trailing comma after the last argument when `)` is on the next line.
125
- )
126
- RUBY
127
-
128
- expect_correction(<<~RUBY)
129
- foo(
130
- key: "value",
131
- )
132
- RUBY
133
- end
134
-
135
- it "accepts trailing comma" do
136
- expect_no_offenses(<<~RUBY)
137
- foo(
138
- key: "value",
139
- )
140
- RUBY
141
- end
142
-
143
- it "accepts trailing comma followed by a comment" do
144
- expect_no_offenses(<<~RUBY)
145
- foo(
146
- key: "value", # some comment
147
- )
148
- RUBY
149
- end
150
- end
151
-
152
- context "with block pass argument" do
153
- it "ignores block pass on its own line" do
154
- expect_no_offenses(<<~RUBY)
155
- bar(
156
- a,
157
- &block
158
- )
159
- RUBY
160
- end
161
- end
162
-
163
- context "without parentheses" do
164
- it "ignores calls without parentheses" do
165
- expect_no_offenses(<<~RUBY)
166
- foo a,
167
- b
168
- RUBY
169
- end
170
- end
171
-
172
- context "without arguments" do
173
- it "ignores calls without arguments" do
174
- expect_no_offenses(<<~RUBY)
175
- foo()
176
- RUBY
177
- end
178
- end
179
- end