Merge pull request #138 from bcardiff/crystal/0.34.0

Compatibility for Crystal 0.34
This commit is contained in:
Vitalii Elenhaupt 2020-03-27 17:49:19 +02:00 committed by GitHub
commit 441e7fa2bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 7 deletions

View file

@ -17,7 +17,7 @@ module Ameba::AST
Crystal::NamedTupleLiteral.new,
Crystal::NilLiteral.new,
Crystal::NumberLiteral.new(42),
Crystal::RegexLiteral.new(Crystal::NilLiteral.new),
Crystal::RegexLiteral.new(Crystal::StringLiteral.new("")),
Crystal::StringLiteral.new(""),
Crystal::SymbolLiteral.new(""),
Crystal::TupleLiteral.new([] of Crystal::ASTNode),

View file

@ -59,6 +59,8 @@ module Ameba::AST
end
when Crystal::BinaryOp
unreachable_nodes << current_node.right if flow_expression?(current_node.left, in_loop?)
else
# nop
end
unreachable_nodes

View file

@ -147,6 +147,8 @@ module Ameba::AST::Util
true
when Crystal::Call
node.name == "loop" && node.args.size == 0 && node.obj.nil?
else
false
end
end
end

View file

@ -28,6 +28,8 @@ module Ameba::AST
when Crystal::Case then traverse_case node
when Crystal::BinaryOp then traverse_binary_op node
when Crystal::ExceptionHandler then traverse_exception_handler node
else
# ok
end
end

View file

@ -161,19 +161,21 @@ module Ameba::AST
# :nodoc:
def visit(node : Crystal::Call)
case @current_scope
when .def?
case
when @current_scope.def?
if node.name == SUPER_NODE_NAME && node.args.empty?
@current_scope.arguments.each do |arg|
variable = arg.variable
variable.reference(variable.node, @current_scope).explicit = false
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
private def record_macro?(node)

View file

@ -49,6 +49,8 @@ module Ameba::Rule::Lint
issue_for start_token.not_nil!, issue.not_nil!
end
issue = start_token = nil
else
# nop
end
end
end
@ -59,6 +61,8 @@ module Ameba::Rule::Lint
check_array_entry entry, string_array_unwanted_symbols, "%w"
when .starts_with? "%i"
check_array_entry entry, symbol_array_unwanted_symbols, "%i"
else
# nop
end
end

View file

@ -42,6 +42,8 @@ module Ameba::Rule::Lint
report source, node, "Remove redundant with_index"
when "each_with_index"
report source, node, "Use each instead of each_with_index"
else
# nop
end
end

View file

@ -76,6 +76,8 @@ module Ameba::Rule::Style
redundant_begin_in_handler?(source, body, node)
when Crystal::Expressions
redundant_begin_in_expressions?(body)
else
# nop
end
end

View file

@ -68,6 +68,8 @@ module Ameba
break
when :"}"
break if break_on_rcurly
else
# go on
end
end
end
@ -84,6 +86,8 @@ module Ameba
run_normal_state lexer, break_on_rcurly: true, &block
when :EOF
break
else
# go on
end
end
end
@ -98,6 +102,8 @@ module Ameba
break
when :EOF
break
else
# go on
end
end
end