feat(xatu): report empty let expressions
This commit was merged in pull request #83.
This commit is contained in:
@@ -113,6 +113,51 @@ fn xatu_reports_empty_inherit() -> googletest::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_empty_let_in() -> googletest::Result<()> {
|
||||
let source = fixture_source("testdata/lint_findings.nix")?;
|
||||
let range_start = source.source.find("let in src").or_fail()?;
|
||||
let range_end = range_start + "let in src".len();
|
||||
let report = xatu::future_sight(vec![source]).or_fail()?;
|
||||
|
||||
let finding = report
|
||||
.diagnostics
|
||||
.iter()
|
||||
.map(|diagnostic| &diagnostic.finding)
|
||||
.find(|finding| finding.rule_id == "empty_let_in")
|
||||
.or_fail()?;
|
||||
let expected_range = format!("{range_start}..{range_end}");
|
||||
expect_that!(finding.range.to_string(), eq(&expected_range));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_commented_empty_let_in() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_variants.nix")?]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
.iter()
|
||||
.map(|diagnostic| diagnostic.finding.rule_id)
|
||||
.collect::<Vec<_>>();
|
||||
expect_that!(findings, contains(eq(&"empty_let_in")));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_empty_let_with_empty_inherit() -> googletest::Result<()> {
|
||||
let report =
|
||||
xatu::future_sight(vec![fixture_source("testdata/lint_interactions.nix")?]).or_fail()?;
|
||||
|
||||
let findings = report
|
||||
.diagnostics
|
||||
.iter()
|
||||
.map(|diagnostic| diagnostic.finding.rule_id)
|
||||
.collect::<Vec<_>>();
|
||||
expect_that!(findings, eq(&vec!["empty_let_in", "empty_inherit"]));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[gtest]
|
||||
fn xatu_reports_unquoted_uri() -> googletest::Result<()> {
|
||||
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
|
||||
|
||||
Reference in New Issue
Block a user