rubocop-fourshark 0.11.1 → 0.11.2
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 +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/rubocop/cop/layout/single_line_statement_spacing.rb +31 -3
- data/lib/rubocop/fourshark/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff1f92dab1c4c499529e7729afcfe28e449879582f476e2a911952ec3140f8df
|
|
4
|
+
data.tar.gz: 17f2ab8e91dd9392f74bc0cf333dcf58b54b847e67bd05224ad4394857b583b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad46dc84d1c4930addcb691f17b405685d684eaaa2fe12eb45353ce366ad352e9bc2c79ed65bc9e5b8da4c94579bebcaba65e1170ac809df467dde62d69c8196
|
|
7
|
+
data.tar.gz: f7a40f52df08988e967789e44bd7d74271a9074e14819bfc3e3c315afb7b07a6c0fdc9bba256a021b579c480158956aec9ef5066ba05c5210463d0c53fd1695d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [0.11.2] - 2026-10-07
|
|
2
2
|
|
|
3
3
|
### Added
|
|
4
4
|
|
|
5
5
|
- `Layout/SingleLineStatementSpacing` coverage for RSpec cops that forbid consecutive one-liners
|
|
6
6
|
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `Layout/SingleLineStatementSpacing` — the blank line after a module inclusion or attribute accessor run is no longer removed
|
|
10
|
+
|
|
7
11
|
## [0.11.1] - 2026-10-07
|
|
8
12
|
|
|
9
13
|
### Fixed
|
|
@@ -9,8 +9,9 @@ module RuboCop
|
|
|
9
9
|
# they are one run, so the blank reveals nothing. A blank that separates
|
|
10
10
|
# code from an adjacent comment is kept, as is one owned by another cop
|
|
11
11
|
# (a guard clause, a flow-control statement, an access modifier, the end
|
|
12
|
-
# of an RSpec `let`/`subject`/hook/example run,
|
|
13
|
-
#
|
|
12
|
+
# of an RSpec `let`/`subject`/hook/example run, the end of a module
|
|
13
|
+
# inclusion or attribute accessor run, a Bundler gem section) or one
|
|
14
|
+
# beside a multi-line or heredoc neighbour. Autocorrects by removing it.
|
|
14
15
|
class SingleLineStatementSpacing < ::RuboCop::Cop::Base
|
|
15
16
|
extend ::RuboCop::Cop::AutoCorrector
|
|
16
17
|
ACCESS_MODIFIERS = %i[private protected public module_function].freeze
|
|
@@ -62,11 +63,22 @@ module RuboCop
|
|
|
62
63
|
xspecify: :example
|
|
63
64
|
}.freeze
|
|
64
65
|
|
|
66
|
+
STATEMENT_RUN_KINDS = {
|
|
67
|
+
attr: :attribute_accessor,
|
|
68
|
+
attr_accessor: :attribute_accessor,
|
|
69
|
+
attr_reader: :attribute_accessor,
|
|
70
|
+
attr_writer: :attribute_accessor,
|
|
71
|
+
extend: :module_inclusion,
|
|
72
|
+
include: :module_inclusion,
|
|
73
|
+
prepend: :module_inclusion
|
|
74
|
+
}.freeze
|
|
75
|
+
|
|
65
76
|
def on_begin(node)
|
|
66
77
|
node.children.each_cons(2) do |first, second|
|
|
67
78
|
next unless first.is_a?(::RuboCop::AST::Node) && second.is_a?(::RuboCop::AST::Node)
|
|
68
79
|
next if structural?(first) || structural?(second)
|
|
69
|
-
next if rspec_run_ends?(first, second) ||
|
|
80
|
+
next if rspec_run_ends?(first, second) || statement_run_ends?(first, second)
|
|
81
|
+
next if gem_section_boundary?(first, second)
|
|
70
82
|
|
|
71
83
|
blanks = removable_blank_lines(first, second)
|
|
72
84
|
|
|
@@ -146,6 +158,22 @@ module RuboCop
|
|
|
146
158
|
RSPEC_KINDS[call.method_name]
|
|
147
159
|
end
|
|
148
160
|
|
|
161
|
+
# `Layout/EmptyLinesAfterModuleInclusion` and `Layout/EmptyLinesAroundAttributeAccessor`
|
|
162
|
+
# demand a blank after the last `include`/`extend`/`prepend` or `attr_*` of a run.
|
|
163
|
+
def statement_run_ends?(first, second)
|
|
164
|
+
kind = statement_run_kind(first)
|
|
165
|
+
|
|
166
|
+
return false if kind.nil?
|
|
167
|
+
|
|
168
|
+
kind != statement_run_kind(second)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def statement_run_kind(node)
|
|
172
|
+
return nil if !node.send_type? || node.receiver
|
|
173
|
+
|
|
174
|
+
STATEMENT_RUN_KINDS[node.method_name]
|
|
175
|
+
end
|
|
176
|
+
|
|
149
177
|
# `Bundler/OrderedGems` reads a blank between two `gem` lines as a section break.
|
|
150
178
|
def gem_section_boundary?(first, second)
|
|
151
179
|
gem_declaration?(first) && gem_declaration?(second)
|