rubocop-tablecop 0.3.0 → 0.3.1
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 +16 -0
- data/lib/rubocop/cop/tablecop/safe_endless_method.rb +23 -0
- data/lib/rubocop/tablecop/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b4eae624919db229c2973bf708c98fbb3493ae26c1442df19daded0b9f8b598
|
|
4
|
+
data.tar.gz: 1c0f7a64dc50fec124730b4d45c2a9b49044e05bad6984a91f45db43c5188e15
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cd4fae66c17a7da85a859414f627475dc012902ceb4848a1ef84c9abd1c0236faad97ffdae718c3c9a635d1946d3b6c2a5c1e81734fd84f8916d32ad7d5e13e
|
|
7
|
+
data.tar.gz: 8cee4c0a8e542bebc8c7ea4e8a50fc4bb6c4cac8936f423cb45b7d08c650aced17c30d57484a0df8040834416d4a69b9e32d816e3274affa8ad9c0753a270907
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.1] - 2026-05-18
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **`Tablecop/SafeEndlessMethod` no longer corrupts methods whose body
|
|
13
|
+
contains a multi-statement `begin … end` nested as a sub-expression**
|
|
14
|
+
(e.g. the memoization idiom `@memo ||= begin; a; b; end`). The body
|
|
15
|
+
is an `or_asgn`, so the existing direct-body `:begin` guard missed
|
|
16
|
+
it, and it is not a `{}`/`do-end` block so the block guard missed it
|
|
17
|
+
too; autocorrect collapsed `a\n b` into `a b` (no separator) →
|
|
18
|
+
syntactically invalid Ruby. Found when it broke a downstream project
|
|
19
|
+
at parse time. Single-statement `begin x end` still converts.
|
|
20
|
+
|
|
21
|
+
> Note: 0.3.0 was released without a changelog entry; entries resume
|
|
22
|
+
> here rather than reconstruct unrecorded history.
|
|
23
|
+
|
|
8
24
|
## [0.2.0] - 2025-12-13
|
|
9
25
|
|
|
10
26
|
### Changed
|
|
@@ -66,6 +66,16 @@ module RuboCop
|
|
|
66
66
|
# Body must be single expression (not begin block with multiple children)
|
|
67
67
|
return false if node.body.begin_type?
|
|
68
68
|
|
|
69
|
+
# ...and must not CONTAIN a multi-statement sequence anywhere
|
|
70
|
+
# (e.g. `@memo ||= begin; a; b; end` — body is an or_asgn, so
|
|
71
|
+
# the check above misses it, and it is not a {}/do-end block so
|
|
72
|
+
# contains_multi_statement_block? misses it too). Collapsing its
|
|
73
|
+
# newlines to spaces would jam `a b` with no separator → invalid
|
|
74
|
+
# Ruby. This was a real corruption: rubocop-tablecop#<safe-
|
|
75
|
+
# endless> turned a valid memoized method into an unparseable
|
|
76
|
+
# one in a downstream project.
|
|
77
|
+
return false if contains_multi_statement_sequence?(node.body)
|
|
78
|
+
|
|
69
79
|
# No heredocs
|
|
70
80
|
return false if contains_heredoc?(node.body)
|
|
71
81
|
|
|
@@ -151,6 +161,19 @@ module RuboCop
|
|
|
151
161
|
false
|
|
152
162
|
end
|
|
153
163
|
|
|
164
|
+
# True if `body` is, or contains anywhere, a statement sequence
|
|
165
|
+
# with more than one statement. Two AST shapes (verified, not
|
|
166
|
+
# assumed): an implicit multi-statement body is a `:begin`
|
|
167
|
+
# sequence; an explicit `begin … end` is a `:kwbegin` whose
|
|
168
|
+
# children ARE the statements (no inner `:begin`). Either with
|
|
169
|
+
# >1 child is unsafe to space-join. Single-statement `begin x
|
|
170
|
+
# end` is a 1-child :kwbegin and stays convertible.
|
|
171
|
+
def contains_multi_statement_sequence?(body)
|
|
172
|
+
return false unless body
|
|
173
|
+
|
|
174
|
+
body.each_node(:begin, :kwbegin).any? { |seq| seq.children.size > 1 }
|
|
175
|
+
end
|
|
176
|
+
|
|
154
177
|
def contains_complex_control_flow?(node)
|
|
155
178
|
return false unless node
|
|
156
179
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-tablecop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joseph Wecker
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rubocop
|
|
@@ -68,7 +67,6 @@ metadata:
|
|
|
68
67
|
changelog_uri: https://github.com/v2-io/rubocop-tablecop/blob/main/CHANGELOG.md
|
|
69
68
|
rubygems_mfa_required: 'true'
|
|
70
69
|
default_lint_roller_plugin: RuboCop::Tablecop::Plugin
|
|
71
|
-
post_install_message:
|
|
72
70
|
rdoc_options: []
|
|
73
71
|
require_paths:
|
|
74
72
|
- lib
|
|
@@ -83,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
81
|
- !ruby/object:Gem::Version
|
|
84
82
|
version: '0'
|
|
85
83
|
requirements: []
|
|
86
|
-
rubygems_version:
|
|
87
|
-
signing_key:
|
|
84
|
+
rubygems_version: 4.0.3
|
|
88
85
|
specification_version: 4
|
|
89
86
|
summary: RuboCop extension for table-like, condensed Ruby formatting
|
|
90
87
|
test_files: []
|