# Credo.Code.Block (Credo v1.6.0) View Source

This module provides helper functions to analyse blocks, e.g. the block taken by the `if` macro.

# Link to this section Summary

## Functions

Returns true if the given `ast` has an after block.

Returns a tuple {:ok, after_block} or nil for a given AST node.

Returns the after: block of a given AST node.

Returns the do: block of a given AST node.

Returns the children of the `do` block of the given AST node.

Returns the children of the `rescue` block of the given AST node.

Returns true if the given `ast` has a do block.

Returns a tuple {:ok, do_block} or nil for a given AST node.

Returns the do: block of a given AST node.

Returns true if the given `ast` has an else block.

Returns a tuple {:ok, else_block} or nil for a given AST node.

Returns the `else` block of a given AST node.

Returns true if the given `ast` has an rescue block.

Returns a tuple {:ok, rescue_block} or nil for a given AST node.

Returns the rescue: block of a given AST node.

# after_block?(ast)

View Source

Returns true if the given `ast` has an after block.

# after_block_for(arguments)

View Source

Returns a tuple {:ok, after_block} or nil for a given AST node.

# after_block_for!(ast)

View Source

Returns the after: block of a given AST node.

# all_blocks_for!(ast)

View Source

Returns the do: block of a given AST node.

# calls_in_do_block(arg)

View Source

Returns the children of the `do` block of the given AST node.

# calls_in_rescue_block(arg)

View Source

Returns the children of the `rescue` block of the given AST node.

# do_block?(ast)

View Source

Returns true if the given `ast` has a do block.

# do_block_for(arguments)

View Source

Returns a tuple {:ok, do_block} or nil for a given AST node.

# do_block_for!(ast)

View Source

Returns the do: block of a given AST node.

# else_block?(ast)

View Source

Returns true if the given `ast` has an else block.

# else_block_for(arguments)

View Source

Returns a tuple {:ok, else_block} or nil for a given AST node.

# else_block_for!(ast)

View Source

Returns the `else` block of a given AST node.

# rescue_block?(ast)

View Source

Returns true if the given `ast` has an rescue block.

# rescue_block_for(arguments)

View Source

Returns a tuple {:ok, rescue_block} or nil for a given AST node.