mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Merge pull request #138 from bcardiff/crystal/0.34.0
Compatibility for Crystal 0.34
This commit is contained in:
commit
441e7fa2bb
9 changed files with 29 additions and 7 deletions
|
@ -17,7 +17,7 @@ module Ameba::AST
|
||||||
Crystal::NamedTupleLiteral.new,
|
Crystal::NamedTupleLiteral.new,
|
||||||
Crystal::NilLiteral.new,
|
Crystal::NilLiteral.new,
|
||||||
Crystal::NumberLiteral.new(42),
|
Crystal::NumberLiteral.new(42),
|
||||||
Crystal::RegexLiteral.new(Crystal::NilLiteral.new),
|
Crystal::RegexLiteral.new(Crystal::StringLiteral.new("")),
|
||||||
Crystal::StringLiteral.new(""),
|
Crystal::StringLiteral.new(""),
|
||||||
Crystal::SymbolLiteral.new(""),
|
Crystal::SymbolLiteral.new(""),
|
||||||
Crystal::TupleLiteral.new([] of Crystal::ASTNode),
|
Crystal::TupleLiteral.new([] of Crystal::ASTNode),
|
||||||
|
|
|
@ -59,6 +59,8 @@ module Ameba::AST
|
||||||
end
|
end
|
||||||
when Crystal::BinaryOp
|
when Crystal::BinaryOp
|
||||||
unreachable_nodes << current_node.right if flow_expression?(current_node.left, in_loop?)
|
unreachable_nodes << current_node.right if flow_expression?(current_node.left, in_loop?)
|
||||||
|
else
|
||||||
|
# nop
|
||||||
end
|
end
|
||||||
|
|
||||||
unreachable_nodes
|
unreachable_nodes
|
||||||
|
|
|
@ -147,6 +147,8 @@ module Ameba::AST::Util
|
||||||
true
|
true
|
||||||
when Crystal::Call
|
when Crystal::Call
|
||||||
node.name == "loop" && node.args.size == 0 && node.obj.nil?
|
node.name == "loop" && node.args.size == 0 && node.obj.nil?
|
||||||
|
else
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,8 @@ module Ameba::AST
|
||||||
when Crystal::Case then traverse_case node
|
when Crystal::Case then traverse_case node
|
||||||
when Crystal::BinaryOp then traverse_binary_op node
|
when Crystal::BinaryOp then traverse_binary_op node
|
||||||
when Crystal::ExceptionHandler then traverse_exception_handler node
|
when Crystal::ExceptionHandler then traverse_exception_handler node
|
||||||
|
else
|
||||||
|
# ok
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -161,19 +161,21 @@ module Ameba::AST
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
def visit(node : Crystal::Call)
|
def visit(node : Crystal::Call)
|
||||||
case @current_scope
|
case
|
||||||
when .def?
|
when @current_scope.def?
|
||||||
if node.name == SUPER_NODE_NAME && node.args.empty?
|
if node.name == SUPER_NODE_NAME && node.args.empty?
|
||||||
@current_scope.arguments.each do |arg|
|
@current_scope.arguments.each do |arg|
|
||||||
variable = arg.variable
|
variable = arg.variable
|
||||||
variable.reference(variable.node, @current_scope).explicit = false
|
variable.reference(variable.node, @current_scope).explicit = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when .top_level?
|
|
||||||
return false if record_macro?(node)
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
true
|
||||||
|
when @current_scope.top_level? && record_macro?(node)
|
||||||
|
false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def record_macro?(node)
|
private def record_macro?(node)
|
||||||
|
|
|
@ -49,6 +49,8 @@ module Ameba::Rule::Lint
|
||||||
issue_for start_token.not_nil!, issue.not_nil!
|
issue_for start_token.not_nil!, issue.not_nil!
|
||||||
end
|
end
|
||||||
issue = start_token = nil
|
issue = start_token = nil
|
||||||
|
else
|
||||||
|
# nop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,6 +61,8 @@ module Ameba::Rule::Lint
|
||||||
check_array_entry entry, string_array_unwanted_symbols, "%w"
|
check_array_entry entry, string_array_unwanted_symbols, "%w"
|
||||||
when .starts_with? "%i"
|
when .starts_with? "%i"
|
||||||
check_array_entry entry, symbol_array_unwanted_symbols, "%i"
|
check_array_entry entry, symbol_array_unwanted_symbols, "%i"
|
||||||
|
else
|
||||||
|
# nop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ module Ameba::Rule::Lint
|
||||||
report source, node, "Remove redundant with_index"
|
report source, node, "Remove redundant with_index"
|
||||||
when "each_with_index"
|
when "each_with_index"
|
||||||
report source, node, "Use each instead of each_with_index"
|
report source, node, "Use each instead of each_with_index"
|
||||||
|
else
|
||||||
|
# nop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ module Ameba::Rule::Style
|
||||||
redundant_begin_in_handler?(source, body, node)
|
redundant_begin_in_handler?(source, body, node)
|
||||||
when Crystal::Expressions
|
when Crystal::Expressions
|
||||||
redundant_begin_in_expressions?(body)
|
redundant_begin_in_expressions?(body)
|
||||||
|
else
|
||||||
|
# nop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@ module Ameba
|
||||||
break
|
break
|
||||||
when :"}"
|
when :"}"
|
||||||
break if break_on_rcurly
|
break if break_on_rcurly
|
||||||
|
else
|
||||||
|
# go on
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -84,6 +86,8 @@ module Ameba
|
||||||
run_normal_state lexer, break_on_rcurly: true, &block
|
run_normal_state lexer, break_on_rcurly: true, &block
|
||||||
when :EOF
|
when :EOF
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
# go on
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -98,6 +102,8 @@ module Ameba
|
||||||
break
|
break
|
||||||
when :EOF
|
when :EOF
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
# go on
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue