nu-lint 1.2.0

Linter for Nu shell scripts that helpfully suggests improvements
Documentation
use super::RULE;

#[test]
fn test_if_with_else() {
    let good_code = r#"
if $x > 0 {
    if $y > 0 {
        print "both positive"
    } else {
        print "y not positive"
    }
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_outer_if_with_else() {
    let good_code = r#"
if $x > 0 {
    if $y > 0 {
        print "both positive"
    }
} else {
    print "x not positive"
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_single_if() {
    let good_code = r#"
if $x > 0 {
    print "positive"
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_if_with_multiple_statements() {
    let good_code = r#"
if $x > 0 {
    print "x is positive"
    if $y > 0 {
        print "y is also positive"
    }
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_separate_if_statements() {
    let good_code = r#"
if $x > 0 {
    print "x positive"
}
if $y > 0 {
    print "y positive"
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_already_combined_condition() {
    let good_code = r#"
if $x > 0 and $y > 0 {
    print "both positive"
}
"#;

    RULE.assert_ignores(good_code);
}

#[test]
fn test_nested_if_with_else_if() {
    let good_code = r#"
if $x > 0 {
    if $y > 0 {
        print "both positive"
    } else if $y < 0 {
        print "y negative"
    }
}
"#;

    RULE.assert_ignores(good_code);
}