struct Ameba::Rules::UnlessElse

Overview

A rule that disallows the use of an else block with the unless.

For example, the rule considers these valid:

unless something
  :ok
end

if something
  :one
else
  :two
end

But it considers this one invalid as it is an unless with an else:

unless something
  :one
else
  :two
end

The solution is to swap the order of the blocks, and change the unless to an if, so the previous invalid example would become this:

if something
  :two
else
  :one
end

Defined in:

ameba/rules/unless_else.cr

Instance Method Summary

Instance methods inherited from struct Ameba::Rule

catch(source : Source) catch, initialize initialize, name name, test(source : Source, node : Crystal::ASTNode)
test(source : Source)
test

Constructor methods inherited from struct Ameba::Rule

new new

Class methods inherited from struct Ameba::Rule

rules rules

Instance Method Detail

def test(source, node : Crystal::Unless) #

[View source]
def test(source) #

[View source]