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/unquoted_splice.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'lib/src/lints/unquoted_splice.rs') diff --git a/lib/src/lints/unquoted_splice.rs b/lib/src/lints/unquoted_splice.rs index 4d1ed69..c2fd6e4 100644 --- a/lib/src/lints/unquoted_splice.rs +++ b/lib/src/lints/unquoted_splice.rs @@ -1,4 +1,4 @@ -use crate::{make, Lint, Metadata, Report, Rule, Suggestion}; +use crate::{make, Metadata, Report, Rule, Suggestion}; use if_chain::if_chain; use macros::lint; @@ -7,6 +7,30 @@ use rnix::{ NodeOrToken, SyntaxElement, SyntaxKind, }; +/// ## What it does +/// Checks for antiquote/splice expressions that are not quoted. +/// +/// ## Why is this bad? +/// An *anti*quoted expression should always occur within a *quoted* +/// expression. +/// +/// ## Example +/// +/// ``` +/// let +/// pkgs = nixpkgs.legacyPackages.${system}; +/// in +/// pkgs +/// ``` +/// +/// Quote the splice expression: +/// +/// ``` +/// let +/// pkgs = nixpkgs.legacyPackages."${system}"; +/// in +/// pkgs +/// ``` #[lint( name = "unquoted splice", note = "Found unquoted splice expression", @@ -24,7 +48,7 @@ impl Rule for UnquotedSplice { let at = node.text_range(); let replacement = make::quote(&node).node().clone(); let message = "Consider quoting this splice expression"; - 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