remove isNull deprecation lint

see https://github.com/NixOS/nix/pull/9645
This commit is contained in:
seth 2024-07-09 16:16:27 -04:00
parent d324490e45
commit bc90852458
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
6 changed files with 0 additions and 82 deletions

View File

@ -1,6 +0,0 @@
let
e = null;
in
if isNull e
then "no"
else "yes"

View File

@ -59,7 +59,6 @@ test_lint! {
empty_pattern,
redundant_pattern_bind,
unquoted_uri,
deprecated_is_null,
empty_inherit,
faster_groupby => session_info!("2.5"),
faster_zipattrswith => session_info!("2.6"),

View File

@ -1,13 +0,0 @@
---
source: bin/tests/main.rs
expression: "&out"
---
[W13] Warning: Found usage of deprecated builtin isNull
╭─[data/deprecated_is_null.nix:4:4]
4 │ if isNull e
· ────┬───
· ╰───── isNull is deprecated, check equality with null instead
───╯

View File

@ -13,7 +13,6 @@ lints! {
empty_pattern,
redundant_pattern_bind,
unquoted_uri,
deprecated_is_null,
empty_inherit,
faster_groupby,
faster_zipattrswith,

View File

@ -1,60 +0,0 @@
use crate::{make, session::SessionInfo, Metadata, Report, Rule, Suggestion};
use if_chain::if_chain;
use macros::lint;
use rnix::{
types::{Apply, Ident, TokenWrapper, TypedNode},
NodeOrToken, SyntaxElement, SyntaxKind,
};
/// ## What it does
/// Checks for usage of the `isNull` function.
///
/// ## Why is this bad?
/// `isNull` is deprecated.
///
/// ## Example
///
/// Instead of `isNull` for `null` checks,
///
/// ```nix
/// isNull e
/// ```
///
/// use the equality operator:
///
/// ```nix
/// e == null
/// ```
#[lint(
name = "deprecated_is_null",
note = "Found usage of deprecated builtin isNull",
code = 13,
match_with = SyntaxKind::NODE_APPLY
)]
struct DeprecatedIsNull;
impl Rule for DeprecatedIsNull {
fn validate(&self, node: &SyntaxElement, _sess: &SessionInfo) -> Option<Report> {
if_chain! {
if let NodeOrToken::Node(node) = node;
if let Some(apply) = Apply::cast(node.clone());
if let Some(ident) = Ident::cast(apply.lambda()?);
if ident.as_str() == "isNull";
if let Some(value) = apply.value();
then {
let null = make::ident("null");
let binop = make::binary(&value, "==", null.node());
let parenthesized = make::parenthesize(binop.node());
let at = node.text_range();
let replacement = parenthesized.node().clone();
let message = "`isNull` is deprecated, check equality with `null` instead";
Some(self.report().suggest(at, message, Suggestion::new(at, replacement)))
} else {
None
}
}
}
}

View File

@ -136,7 +136,6 @@ useless_parens
empty_pattern
redundant_pattern_bind
unquoted_uri
deprecated_is_null
empty_inherit
faster_groupby
faster_zipattrswith