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

anyhow specific lint. Suggest users use bail! macro. #37

Open
cowlicks opened this issue Apr 4, 2023 · 0 comments
Open

anyhow specific lint. Suggest users use bail! macro. #37

cowlicks opened this issue Apr 4, 2023 · 0 comments
Labels
A-user-story Area: A user story or a related issue

Comments

@cowlicks
Copy link

cowlicks commented Apr 4, 2023

Lint explanation

Warn when code has suboptimal usage of anyhow. Specifically tell the user to use the bail! macro instead doing: return Err(anyhow!("...")).

Example code

Bad code

fn foo(x: bool) -> Result<()> {
  if x {
    return Err(anyhow!("x was {x}"));
  }
  Ok(())
}

Good code

fn foo(x: bool) -> Result<()> {
  if x {
    return bail!("x was {x}");
  }
  Ok(())
}

Notes

@cowlicks cowlicks added the A-user-story Area: A user story or a related issue label Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-user-story Area: A user story or a related issue
Projects
None yet
Development

No branches or pull requests

1 participant