mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Comply exhaustive case check
This commit is contained in:
parent
24b9156f19
commit
6259e26457
8 changed files with 28 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue