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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69cc71527797fec14e62169599832f3807636964ae36c971a625002392f2eb8f
4
- data.tar.gz: b48916db29a2562de541d537a5204c2a11029cff89f91b2d8bd90c932dbeabc6
3
+ metadata.gz: ff1f92dab1c4c499529e7729afcfe28e449879582f476e2a911952ec3140f8df
4
+ data.tar.gz: 17f2ab8e91dd9392f74bc0cf333dcf58b54b847e67bd05224ad4394857b583b8
5
5
  SHA512:
6
- metadata.gz: 74d395cab432995d01f8b5b7a86c3fbe1bb3bab3f4166452fc01c72ff18d3ef07d177bbeb4970d797a48812028c5c84e82e1623c0e860022d9baca5c530ea960
7
- data.tar.gz: 3ac8c3575cbbefc7bbfd843cb6c21a651a80e15ff60a8eb89442e86e60b7f241917eface0fc2db701678647f60160ef8d3d37aff96c98cabac9b043ea1a649f3
6
+ metadata.gz: ad46dc84d1c4930addcb691f17b405685d684eaaa2fe12eb45353ce366ad352e9bc2c79ed65bc9e5b8da4c94579bebcaba65e1170ac809df467dde62d69c8196
7
+ data.tar.gz: f7a40f52df08988e967789e44bd7d74271a9074e14819bfc3e3c315afb7b07a6c0fdc9bba256a021b579c480158956aec9ef5066ba05c5210463d0c53fd1695d
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
- ## [Unreleased]
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, a Bundler gem section) or
13
- # one beside a multi-line or heredoc neighbour. Autocorrects by removing it.
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) || gem_section_boundary?(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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Fourshark
5
- VERSION = '0.11.1'
5
+ VERSION = '0.11.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-fourshark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Ribeiro