Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: No Single Clause Maybe Statements #293

Open
paulo-ferraz-oliveira opened this issue Mar 1, 2023 · 0 comments
Open

New rule: No Single Clause Maybe Statements #293

paulo-ferraz-oliveira opened this issue Mar 1, 2023 · 0 comments
Labels
Milestone

Comments

@paulo-ferraz-oliveira
Copy link
Collaborator

No Single Clause Maybe Statements

Brief Description

The following code...

maybe
    {ok, A} ?= a()
end

... should actually be written using pattern-matching:

{ok, A} = a()

The maybe statement is unnecessary and the only difference between the two is that the exception raised in the case of error changes from else_clause to badmatch.

If an else_clause is present, though, the rule should not be applied.

Should be on by default?

YES

Options

  • None.

Reasoning

Single-pattern maybe blocks may be written more concisely or removed entirely.

Origin

Inspired by #290.

@paulo-ferraz-oliveira paulo-ferraz-oliveira changed the title No Single Clause Maybe Statements New rule: No Single Clause Maybe Statements Mar 1, 2023
@elbrujohalcon elbrujohalcon added this to the 3.1.0 milestone Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants