Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 89081df

Browse files
committed
Fix up rubocop violations
1 parent 95b2584 commit 89081df

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ Style/IdenticalConditionalBranches:
5555
Style/IfInsideElse:
5656
Enabled: false
5757

58+
Style/IfWithBooleanLiteralBranches:
59+
Enabled: false
60+
5861
Style/KeywordParametersOrder:
5962
Enabled: false
6063

lib/syntax_tree.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# We rely on Symbol#name being available, which is only available in Ruby 3.0+.
2424
# In case we're running on an older Ruby version, we polyfill it here.
2525
unless :+.respond_to?(:name)
26-
class Symbol
26+
class Symbol # rubocop:disable Style/Documentation
2727
def name
2828
to_s.freeze
2929
end

lib/syntax_tree/formatter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def group
148148

149149
# A similar version to the super, except that it calls back into the
150150
# separator proc with the instance of `self`.
151-
def seplist(list, sep = nil, iter_method = :each) # :yield: element
151+
def seplist(list, sep = nil, iter_method = :each)
152152
first = true
153153
list.__send__(iter_method) do |*v|
154154
if first

lib/syntax_tree/node.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,11 @@ def trailing_comma?
621621
return false unless arguments.is_a?(Args)
622622
parts = arguments.parts
623623

624-
if parts.last&.is_a?(ArgBlock)
624+
if parts.last.is_a?(ArgBlock)
625625
# If the last argument is a block, then we can't put a trailing comma
626626
# after it without resulting in a syntax error.
627627
false
628-
elsif parts.length == 1 && (part = parts.first) &&
628+
elsif (parts.length == 1) && (part = parts.first) &&
629629
(part.is_a?(Command) || part.is_a?(CommandCall))
630630
# If the only argument is a command or command call, then a trailing
631631
# comma would be parsed as part of that expression instead of on this
@@ -891,6 +891,7 @@ def format(q)
891891
#
892892
# provided the line length was hit between `bar` and `baz`.
893893
class VarRefsFormatter
894+
# The separator for the fill algorithm.
894895
class Separator
895896
def call(q)
896897
q.text(",")
@@ -2522,7 +2523,8 @@ def format_chain(q, children)
25222523
# https://github.com/prettier/plugin-ruby/issues/862.
25232524
else
25242525
# If we're at a Call node and not a MethodAddBlock node in the
2525-
# chain then we're going to add a newline so it indents properly.
2526+
# chain then we're going to add a newline so it indents
2527+
# properly.
25262528
q.breakable_empty
25272529
end
25282530
end
@@ -2701,15 +2703,15 @@ def format(q)
27012703
end
27022704
end
27032705

2706+
# Print out the arguments to this call. If there are no arguments, then do
2707+
#nothing.
27042708
def format_arguments(q)
27052709
case arguments
27062710
when ArgParen
27072711
q.format(arguments)
27082712
when Args
27092713
q.text(" ")
27102714
q.format(arguments)
2711-
else
2712-
# Do nothing if there are no arguments.
27132715
end
27142716
end
27152717

@@ -3180,6 +3182,8 @@ def format(q)
31803182
end
31813183
end
31823184

3185+
# Format the arguments for this command call here. If there are no
3186+
# arguments, then print nothing.
31833187
if arguments
31843188
parts = arguments.parts
31853189

@@ -3190,8 +3194,6 @@ def format(q)
31903194
q.text(" ")
31913195
q.nest(argument_alignment(q, doc)) { q.format(arguments) }
31923196
end
3193-
else
3194-
# If there are no arguments, print nothing.
31953197
end
31963198
end
31973199
end

lib/syntax_tree/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ def on_dot3(left, right)
13891389
# :call-seq:
13901390
# on_dyna_symbol: (StringContent string_content) -> DynaSymbol
13911391
def on_dyna_symbol(string_content)
1392-
if symbeg = find_token(SymBeg)
1392+
if (symbeg = find_token(SymBeg))
13931393
# A normal dynamic symbol
13941394
tokens.delete(symbeg)
13951395
tstring_end = consume_tstring_end(symbeg.location)

0 commit comments

Comments
 (0)