rubocop-rbs_inline 1.5.3 → 1.5.4
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/.claude/hooks/pre-commit-check.sh +6 -2
- data/.claude/hooks/rbs-inline.sh +6 -8
- data/.claude/hooks/setup.sh +10 -11
- data/.vscode/settings.json +6 -0
- data/CHANGELOG.md +8 -0
- data/CLAUDE.md +9 -9
- data/Rakefile +2 -1
- data/Steepfile +3 -1
- data/lib/rubocop/cop/rbs_inline_cops.rb +1 -0
- data/lib/rubocop/cop/style/rbs_inline/ast_utils.rb +46 -0
- data/lib/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rb +12 -5
- data/lib/rubocop/cop/style/rbs_inline/invalid_comment.rb +1 -1
- data/lib/rubocop/cop/style/rbs_inline/keyword_separator.rb +2 -2
- data/lib/rubocop/cop/style/rbs_inline/method_comment_spacing.rb +4 -3
- data/lib/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rb +17 -8
- data/lib/rubocop/cop/style/rbs_inline/missing_type_annotation.rb +53 -47
- data/lib/rubocop/cop/style/rbs_inline/parameters_separator.rb +10 -5
- data/lib/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rb +3 -3
- data/lib/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rb +5 -6
- data/lib/rubocop/cop/style/rbs_inline/redundant_type_annotation.rb +9 -5
- data/lib/rubocop/cop/style/rbs_inline/require_rbs_inline_comment.rb +3 -2
- data/lib/rubocop/cop/style/rbs_inline/unmatched_annotations.rb +6 -6
- data/lib/rubocop/cop/style/rbs_inline/untyped_instance_variable.rb +16 -14
- data/lib/rubocop/rbs_inline/version.rb +1 -1
- data/rbs_collection.lock.yaml +17 -25
- data/rbs_collection.yaml +0 -1
- data/sig/gems/rubocop/rubocop.rbs +0 -22
- data/sig/rubocop/cop/style/rbs_inline/ast_utils.rbs +28 -0
- data/sig/rubocop/cop/style/rbs_inline/data_class_comment_alignment.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/keyword_separator.rbs +4 -4
- data/sig/rubocop/cop/style/rbs_inline/missing_data_class_annotation.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/missing_type_annotation.rbs +45 -43
- data/sig/rubocop/cop/style/rbs_inline/parameters_separator.rbs +1 -1
- data/sig/rubocop/cop/style/rbs_inline/redundant_annotation_with_skip.rbs +6 -6
- data/sig/rubocop/cop/style/rbs_inline/redundant_argument_type.rbs +4 -4
- data/sig/rubocop/cop/style/rbs_inline/redundant_instance_variable_annotation.rbs +2 -0
- data/sig/rubocop/cop/style/rbs_inline/redundant_return_type.rbs +4 -4
- data/sig/rubocop/cop/style/rbs_inline/redundant_type_annotation.rbs +14 -10
- data/sig/rubocop/cop/style/rbs_inline/unmatched_annotations.rbs +10 -10
- data/sig/rubocop/cop/style/rbs_inline/untyped_instance_variable.rbs +16 -14
- metadata +4 -4
- data/sig/gems/lint_roller/lint_roller.rbs +0 -16
- data/sig/gems/parser/parser.rbs +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 887dbca0ede20b0bc2f948c4468a1795bdd59a22e377602769c6b96cdefa628a
|
|
4
|
+
data.tar.gz: b12ec5654d6a54b2dd5389a67c47a8b4adcc8a6ff6784b6426b413fad8a8c0b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c490a7ed73c4ca80d535ab4bff1e7399a26e414c5d72d86779e6def4d414194635bed3c4ce2e6c7432da78db5d19c32ce745502721d2c7b26b4426553703c9b8
|
|
7
|
+
data.tar.gz: bead6840e55e119ba47a58210ba622cd4874131477465790c06621080deb34bd02baa1c60e9029cecf3931211bd2f0ca57242dc2c389a953dff01120d054f080
|
|
@@ -12,15 +12,19 @@ fi
|
|
|
12
12
|
|
|
13
13
|
cd "$CLAUDE_PROJECT_DIR" || exit 1
|
|
14
14
|
|
|
15
|
+
if [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]; then
|
|
16
|
+
eval "$(rbenv init - bash)"
|
|
17
|
+
fi
|
|
18
|
+
|
|
15
19
|
echo "Running pre-commit checks..." >&2
|
|
16
20
|
|
|
17
21
|
# Generate RBS and run all checks
|
|
18
|
-
if !
|
|
22
|
+
if ! bundle exec rbs-inline --opt-out --output=sig/ lib/ >&2; then
|
|
19
23
|
echo "Error: RBS generation failed" >&2
|
|
20
24
|
exit 2
|
|
21
25
|
fi
|
|
22
26
|
|
|
23
|
-
if !
|
|
27
|
+
if ! bundle exec rake >&2; then
|
|
24
28
|
echo "Error: rake checks failed" >&2
|
|
25
29
|
exit 2
|
|
26
30
|
fi
|
data/.claude/hooks/rbs-inline.sh
CHANGED
|
@@ -6,6 +6,10 @@ tool_name=$(echo "$input" | jq -r '.tool_name')
|
|
|
6
6
|
|
|
7
7
|
cd "$CLAUDE_PROJECT_DIR" || exit 1
|
|
8
8
|
|
|
9
|
+
if [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]; then
|
|
10
|
+
eval "$(rbenv init - bash)"
|
|
11
|
+
fi
|
|
12
|
+
|
|
9
13
|
# Handle Edit or Write tools
|
|
10
14
|
if [[ "$tool_name" == "Edit" || "$tool_name" == "Write" ]]; then
|
|
11
15
|
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
|
|
@@ -20,7 +24,7 @@ if [[ "$tool_name" == "Edit" || "$tool_name" == "Write" ]]; then
|
|
|
20
24
|
|
|
21
25
|
echo "Running rbs-inline for $file_path..." >&2
|
|
22
26
|
|
|
23
|
-
if !
|
|
27
|
+
if ! bundle exec rbs-inline --opt-out --output=sig/ "$file_path" >&2; then
|
|
24
28
|
echo "Warning: RBS generation failed for $file_path" >&2
|
|
25
29
|
exit 0
|
|
26
30
|
fi
|
|
@@ -39,12 +43,8 @@ if [[ "$tool_name" == "Bash" ]]; then
|
|
|
39
43
|
fi
|
|
40
44
|
|
|
41
45
|
# Extract source and destination paths from mv command
|
|
42
|
-
# Handle common patterns: mv src dest, git mv src dest
|
|
43
|
-
# Remove the mv/git mv prefix and get the paths
|
|
44
46
|
paths=$(echo "$command" | sed -E 's/^[[:space:]]*(git[[:space:]]+)?mv[[:space:]]+//')
|
|
45
47
|
|
|
46
|
-
# Split into source and destination (simple case, space-separated)
|
|
47
|
-
# This handles: mv old.rb new.rb, mv old.rb dir/
|
|
48
48
|
source_path=$(echo "$paths" | awk '{print $1}')
|
|
49
49
|
dest_path=$(echo "$paths" | awk '{print $2}')
|
|
50
50
|
|
|
@@ -56,7 +56,6 @@ if [[ "$tool_name" == "Bash" ]]; then
|
|
|
56
56
|
echo "Detected mv of Ruby file in lib/: $source_path -> $dest_path" >&2
|
|
57
57
|
|
|
58
58
|
# Calculate the corresponding .rbs file path for the source
|
|
59
|
-
# Convert lib/path/to/file.rb to sig/path/to/file.rbs
|
|
60
59
|
source_rbs=$(echo "$source_path" | sed -E 's|^(.*/)?lib/|sig/|; s|\.rb$|.rbs|')
|
|
61
60
|
|
|
62
61
|
# Remove the old .rbs file if it exists
|
|
@@ -66,7 +65,6 @@ if [[ "$tool_name" == "Bash" ]]; then
|
|
|
66
65
|
fi
|
|
67
66
|
|
|
68
67
|
# Determine the new .rb file path
|
|
69
|
-
# If dest is a directory, append the source filename
|
|
70
68
|
if [[ -d "$dest_path" ]]; then
|
|
71
69
|
dest_file="$dest_path/$(basename "$source_path")"
|
|
72
70
|
else
|
|
@@ -83,7 +81,7 @@ if [[ "$tool_name" == "Bash" ]]; then
|
|
|
83
81
|
if [[ -f "$dest_file" ]]; then
|
|
84
82
|
echo "Running rbs-inline for $dest_file..." >&2
|
|
85
83
|
|
|
86
|
-
if !
|
|
84
|
+
if ! bundle exec rbs-inline --opt-out --output=sig/ "$dest_file" >&2; then
|
|
87
85
|
echo "Warning: RBS generation failed for $dest_file" >&2
|
|
88
86
|
exit 0
|
|
89
87
|
fi
|
data/.claude/hooks/setup.sh
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
set -
|
|
2
|
+
set -eu
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exit 0
|
|
7
|
-
fi
|
|
4
|
+
if [ "${CLAUDE_CODE_REMOTE:-}" = "true" ]; then
|
|
5
|
+
eval "$(rbenv init - bash)"
|
|
8
6
|
|
|
9
|
-
#
|
|
10
|
-
|
|
11
|
-
# references @@accept_charset before it's initialized in Ruby 3.3.
|
|
12
|
-
# Pre-loading the CGI library via RUBYOPT resolves this.
|
|
13
|
-
echo 'export RUBYOPT="-rcgi"' >> "$CLAUDE_ENV_FILE"
|
|
7
|
+
# Set the latest installed Ruby version as the global default
|
|
8
|
+
rbenv global `rbenv versions --bare | sort -rV | head -1`
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
echo 'eval "$(rbenv init - bash)"' >> "$CLAUDE_ENV_FILE"
|
|
11
|
+
echo 'export RUBYOPT="-rcgi"' >> "$CLAUDE_ENV_FILE"
|
|
12
|
+
RUBYOPT="-rcgi" bundle install
|
|
13
|
+
bundle exec rbs collection install --frozen
|
|
14
|
+
fi
|
data/.vscode/settings.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cSpell.words": [
|
|
3
|
+
"argname",
|
|
4
|
+
"Autocorrection",
|
|
3
5
|
"bindir",
|
|
4
6
|
"blockarg",
|
|
7
|
+
"boolish",
|
|
5
8
|
"Ivar",
|
|
9
|
+
"ivars",
|
|
10
|
+
"ivasgn",
|
|
6
11
|
"KOMIYA",
|
|
7
12
|
"kwarg",
|
|
8
13
|
"kwoptarg",
|
|
@@ -13,6 +18,7 @@
|
|
|
13
18
|
"restarg",
|
|
14
19
|
"rubocop",
|
|
15
20
|
"rubygems",
|
|
21
|
+
"sclass",
|
|
16
22
|
"strscan",
|
|
17
23
|
"Takeshi",
|
|
18
24
|
"tk0miya"
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.4 (2026-03-30)
|
|
4
|
+
|
|
5
|
+
### Internal
|
|
6
|
+
|
|
7
|
+
- Extracted `ASTUtils` module to consolidate shared AST helper methods across cops.
|
|
8
|
+
- Removed duplicate RBS type definitions from `sig/gems` and fixed hidden type errors.
|
|
9
|
+
- Fixed node type annotations to use `RuboCop::AST::Node` instead of `Parser::AST::Node`.
|
|
10
|
+
- Removed binstubs; use `bundle exec` instead.
|
|
3
11
|
## 1.5.3 (2026-03-02)
|
|
4
12
|
|
|
5
13
|
### Enhancements
|
data/CLAUDE.md
CHANGED
|
@@ -10,23 +10,23 @@ rubocop-rbs_inline is a RuboCop extension gem that provides cops for validating
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# Run tests
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
bundle exec rspec
|
|
14
|
+
bundle exec rspec spec/rubocop/cop/style/rbs_inline/invalid_comment_spec.rb # single file
|
|
15
|
+
bundle exec rspec spec/rubocop/cop/style/rbs_inline/invalid_comment_spec.rb:8 # single example
|
|
16
16
|
|
|
17
17
|
# Lint
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
bundle exec rake rubocop
|
|
19
|
+
bundle exec rake rubocop:autocorrect # safe autocorrect
|
|
20
|
+
bundle exec rake rubocop:autocorrect_all # all autocorrect
|
|
21
21
|
|
|
22
22
|
# Type check
|
|
23
|
-
|
|
23
|
+
bundle exec rake rbs:check # runs steep check
|
|
24
24
|
|
|
25
25
|
# Default rake task (runs specs, rubocop, and type check)
|
|
26
|
-
|
|
26
|
+
bundle exec rake
|
|
27
27
|
|
|
28
28
|
# Generate a new cop
|
|
29
|
-
|
|
29
|
+
bundle exec rake 'new_cop[Style/RbsInline/CopName]'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Architecture
|
data/Rakefile
CHANGED
data/Steepfile
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Style
|
|
6
|
+
module RbsInline
|
|
7
|
+
module ASTUtils
|
|
8
|
+
# @rbs node: RuboCop::AST::Node
|
|
9
|
+
# @rbs default: Integer
|
|
10
|
+
def end_line(node, default:) #: Integer
|
|
11
|
+
location = node.location #: untyped
|
|
12
|
+
location.end&.line || default
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# @rbs node: RuboCop::AST::Node
|
|
16
|
+
def name_location(node) #: untyped
|
|
17
|
+
location = node.location #: untyped
|
|
18
|
+
location.name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @rbs node: RuboCop::AST::Node
|
|
22
|
+
def source!(node) #: String
|
|
23
|
+
node.source || raise
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
#: (RuboCop::AST::SymbolNode) -> Symbol
|
|
27
|
+
#: (RuboCop::AST::StrNode) -> Symbol
|
|
28
|
+
#: (RuboCop::AST::Node) -> Symbol?
|
|
29
|
+
def value_to_sym(node)
|
|
30
|
+
case node
|
|
31
|
+
when RuboCop::AST::SymbolNode
|
|
32
|
+
node.value
|
|
33
|
+
when RuboCop::AST::StrNode
|
|
34
|
+
case (v = node.value)
|
|
35
|
+
when String
|
|
36
|
+
v.to_sym
|
|
37
|
+
else
|
|
38
|
+
value_to_sym(v)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -26,6 +26,7 @@ module RuboCop
|
|
|
26
26
|
# )
|
|
27
27
|
#
|
|
28
28
|
class DataClassCommentAlignment < Base
|
|
29
|
+
include ASTUtils
|
|
29
30
|
include RangeHelp
|
|
30
31
|
include SourceCodeHelper
|
|
31
32
|
extend AutoCorrector
|
|
@@ -46,7 +47,12 @@ module RuboCop
|
|
|
46
47
|
def data_define?(node) #: bool
|
|
47
48
|
return false unless node.method_name == :define
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
case (r = node.receiver)
|
|
51
|
+
when RuboCop::AST::ConstNode
|
|
52
|
+
r.short_name == :Data
|
|
53
|
+
else
|
|
54
|
+
false
|
|
55
|
+
end
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
# @rbs arg: RuboCop::AST::Node
|
|
@@ -72,7 +78,7 @@ module RuboCop
|
|
|
72
78
|
def check_annotation_alignment(node) #: void
|
|
73
79
|
annotated = data_attributes(node).filter_map do |arg|
|
|
74
80
|
comment = inline_type_comment(arg.location.line)
|
|
75
|
-
[arg, comment] if comment
|
|
81
|
+
[arg, comment] if comment #: [RuboCop::AST::Node, Parser::Source::Comment]
|
|
76
82
|
end
|
|
77
83
|
return if annotated.size < 2
|
|
78
84
|
|
|
@@ -98,7 +104,7 @@ module RuboCop
|
|
|
98
104
|
last_arg = node.arguments.last
|
|
99
105
|
max_end_col = node.arguments.map do |arg|
|
|
100
106
|
comma_length = arg.equal?(last_arg) ? 0 : 1
|
|
101
|
-
arg.location.column + arg.
|
|
107
|
+
arg.location.column + source!(arg).length + comma_length
|
|
102
108
|
end.max || 0 # steep:ignore
|
|
103
109
|
|
|
104
110
|
max_end_col + 2
|
|
@@ -111,8 +117,9 @@ module RuboCop
|
|
|
111
117
|
def correct_alignment(corrector, arg, comment, expected_col) #: void # rubocop:disable Metrics/AbcSize
|
|
112
118
|
line = arg.location.line
|
|
113
119
|
line_source = source_code_at(line)
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
source = line_source[...comment.location.column] || raise
|
|
121
|
+
content_end_col = source.rstrip.length
|
|
122
|
+
padding = [expected_col - content_end_col, 1].max || raise
|
|
116
123
|
|
|
117
124
|
line_begin = processed_source.buffer.line_range(line).begin_pos
|
|
118
125
|
replace_start = line_begin + content_end_col
|
|
@@ -72,7 +72,7 @@ module RuboCop
|
|
|
72
72
|
comments.reject do |comment|
|
|
73
73
|
if (match = comment.text.match(/\A#(\s+)@rbs!(\s+|\Z)/))
|
|
74
74
|
in_embedded = true
|
|
75
|
-
indent = match[1].size
|
|
75
|
+
indent = match[1].to_s.size
|
|
76
76
|
line = comment.loc.line
|
|
77
77
|
true
|
|
78
78
|
elsif in_embedded && comment.loc.line == line + 1 &&
|
|
@@ -37,12 +37,12 @@ module RuboCop
|
|
|
37
37
|
@method_annotation_lines = Set.new #: Set[Integer]
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
# @rbs node:
|
|
40
|
+
# @rbs node: RuboCop::AST::DefNode
|
|
41
41
|
def on_def(node) #: void
|
|
42
42
|
collect_method_annotation_comments(node.loc.line)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# @rbs node:
|
|
45
|
+
# @rbs node: RuboCop::AST::DefNode
|
|
46
46
|
def on_defs(node) #: void
|
|
47
47
|
collect_method_annotation_comments(node.loc.line)
|
|
48
48
|
end
|
|
@@ -93,7 +93,8 @@ module RuboCop
|
|
|
93
93
|
first_comment = comment.comments.first or return false
|
|
94
94
|
line_number = first_comment.location.start_line
|
|
95
95
|
line = processed_source.lines[line_number - 1] or return false
|
|
96
|
-
|
|
96
|
+
source = line[0, first_comment.location.start_column] || raise
|
|
97
|
+
!source.strip.empty?
|
|
97
98
|
end
|
|
98
99
|
|
|
99
100
|
# @rbs comment: RBS::Inline::AnnotationParser::ParsingResult
|
|
@@ -164,9 +165,9 @@ module RuboCop
|
|
|
164
165
|
|
|
165
166
|
# @rbs comment: RBS::Inline::AnnotationParser::ParsingResult
|
|
166
167
|
def skip_only_annotation?(comment) #: bool
|
|
167
|
-
annotations = []
|
|
168
|
+
annotations = [] #: Array[RBS::Inline::AST::Annotations::t]
|
|
168
169
|
comment.each_annotation { |a| annotations << a }
|
|
169
|
-
annotations.any? && annotations.all?
|
|
170
|
+
annotations.any? && annotations.all?(RBS::Inline::AST::Annotations::Skip)
|
|
170
171
|
end
|
|
171
172
|
|
|
172
173
|
# @rbs line_number: Integer
|
|
@@ -20,7 +20,8 @@ module RuboCop
|
|
|
20
20
|
# :visibility #: Symbol
|
|
21
21
|
# )
|
|
22
22
|
#
|
|
23
|
-
class MissingDataClassAnnotation < Base
|
|
23
|
+
class MissingDataClassAnnotation < Base # rubocop:disable Metrics/ClassLength
|
|
24
|
+
include ASTUtils
|
|
24
25
|
include RangeHelp
|
|
25
26
|
include SourceCodeHelper
|
|
26
27
|
extend AutoCorrector
|
|
@@ -44,7 +45,12 @@ module RuboCop
|
|
|
44
45
|
def data_define?(node) #: bool
|
|
45
46
|
return false unless node.method_name == :define
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
case (r = node.receiver)
|
|
49
|
+
when RuboCop::AST::ConstNode
|
|
50
|
+
r.short_name == :Data
|
|
51
|
+
else
|
|
52
|
+
false
|
|
53
|
+
end
|
|
48
54
|
end
|
|
49
55
|
|
|
50
56
|
# @rbs arg: RuboCop::AST::Node
|
|
@@ -80,8 +86,11 @@ module RuboCop
|
|
|
80
86
|
add_offense(arg)
|
|
81
87
|
else
|
|
82
88
|
replacement = build_multiline_replacement(node)
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
loc = node.loc
|
|
90
|
+
if loc.begin && loc.end
|
|
91
|
+
add_offense(arg) { _1.replace(loc.begin.join(loc.end), replacement) }
|
|
92
|
+
corrected = true
|
|
93
|
+
end
|
|
85
94
|
end
|
|
86
95
|
end
|
|
87
96
|
end
|
|
@@ -89,7 +98,7 @@ module RuboCop
|
|
|
89
98
|
# @rbs node: RuboCop::AST::SendNode
|
|
90
99
|
def longest_argname(node) #: String
|
|
91
100
|
last_index = node.arguments.size - 1
|
|
92
|
-
args = node.arguments.each_with_index.map { |a, i| i < last_index ? "#{a.source}," : a.source }
|
|
101
|
+
args = node.arguments.each_with_index.map { |a, i| i < last_index ? "#{a.source}," : a.source.to_s }
|
|
93
102
|
args.max_by(&:length) || ''
|
|
94
103
|
end
|
|
95
104
|
|
|
@@ -102,7 +111,7 @@ module RuboCop
|
|
|
102
111
|
args_source = node.arguments.each_with_index.map do |arg, i|
|
|
103
112
|
comma = i < last_index ? ',' : ''
|
|
104
113
|
prefix = "#{base_indent} #{arg.source}#{comma}"
|
|
105
|
-
padding = ' ' * (longest.length - arg.
|
|
114
|
+
padding = ' ' * (longest.length - source!(arg).length - comma.length + 2)
|
|
106
115
|
data_attribute?(arg) ? "#{prefix}#{padding}#: untyped" : prefix
|
|
107
116
|
end.join("\n")
|
|
108
117
|
|
|
@@ -139,7 +148,7 @@ module RuboCop
|
|
|
139
148
|
line = arg.location.line
|
|
140
149
|
line_source = source_code_at(line)
|
|
141
150
|
content_end_col = line_source.rstrip.length
|
|
142
|
-
padding = [annotation_column(node) - content_end_col, 1].max
|
|
151
|
+
padding = [annotation_column(node) - content_end_col, 1].max || raise
|
|
143
152
|
line_begin = processed_source.buffer.line_range(line).begin_pos
|
|
144
153
|
insert_pos = line_begin + content_end_col
|
|
145
154
|
|
|
@@ -151,7 +160,7 @@ module RuboCop
|
|
|
151
160
|
last_arg = node.arguments.last
|
|
152
161
|
max_end_col = node.arguments.map do |arg|
|
|
153
162
|
comma_length = arg.equal?(last_arg) ? 0 : 1
|
|
154
|
-
arg.location.column + arg.
|
|
163
|
+
arg.location.column + source!(arg).length + comma_length
|
|
155
164
|
end.max || 0 # steep:ignore
|
|
156
165
|
|
|
157
166
|
max_end_col + 2
|