From e8c955da4cbb042e6f9b89307d143f5bfa6779fa Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 31 Oct 2021 14:35:26 +0530 Subject: add `explain` subcommand and explanations to all lints --- lib/src/lints/empty_let_in.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'lib/src/lints/empty_let_in.rs') diff --git a/lib/src/lints/empty_let_in.rs b/lib/src/lints/empty_let_in.rs index aae1377..b255c23 100644 --- a/lib/src/lints/empty_let_in.rs +++ b/lib/src/lints/empty_let_in.rs @@ -1,12 +1,30 @@ -use crate::{Lint, Metadata, Report, Rule, Suggestion}; +use crate::{Metadata, Report, Rule, Suggestion}; use if_chain::if_chain; use macros::lint; use rnix::{ - types::{LetIn, TypedNode, EntryHolder}, + types::{EntryHolder, LetIn, TypedNode}, NodeOrToken, SyntaxElement, SyntaxKind, }; +/// ## What it does +/// Checks for `let-in` expressions which create no new bindings. +/// +/// ## Why is this bad? +/// `let-in` expressions that create no new bindings are useless. +/// These are probably remnants from debugging or editing expressions. +/// +/// ## Example +/// +/// ``` +/// let in pkgs.statix +/// ``` +/// +/// Preserve only the body of the `let-in` expression: +/// +/// ``` +/// pkgs.statix +/// ``` #[lint( name = "empty let-in", note = "Useless let-in expression", @@ -31,11 +49,10 @@ impl Rule for EmptyLetIn { let at = node.text_range(); let replacement = body; let message = "This let-in expression has no entries"; - Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) + Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) } else { None } } } } - -- cgit v1.2.3