a02d892f831f
string-error.yml
id: string-error
language: rust
severity: error
message: String as an error type
note: |
Return a #[derive(thiserror::Error)] enum, so a caller can match on what failed and the
messages live with their variants.
rule:
any:
- pattern:
context: type T = Result<$OK, String>;
selector: generic_type
- pattern: Err(format!($$$))
- pattern: Err($S.to_string())
- pattern: Err(String::from($$$))
- all:
- pattern: Err($S)
- has:
kind: arguments
has:
kind: string_literal
No file is open. Choose one in the tree, or press Ctrl+O (⌘O on a Mac) to find one by name.
Syntax highlighting could not load. The unmodified read-only text remains available above.