refactor(natu): rename xatu

This commit was merged in pull request #97.
This commit is contained in:
2026-09-26 20:12:57 -04:00
parent 27d9194ac3
commit 0c1a1c1ffa
26 changed files with 82 additions and 81 deletions

View File

@@ -105,7 +105,7 @@
Do not use `nix fmt` as a validation command until a formatter is added.
- The `fix` app passes its current directory to Deadnix.
Run `nix run .#fix` from the repository root so path exclusions match.
- During the Nix refactor, address each issue that comes up by adding either a Xatu rule or a new Nix style rule.
- During the Nix refactor, address each issue that comes up by adding either a Natu rule or a new Nix style rule.
- Git pathspec searches started in a subdirectory default to that subtree.
Use `git -C <repository-root>` or top-anchored pathspecs for repository-wide history searches.
- Ariadne extraction must preserve the game-root season prefix for archived source.

24
Cargo.lock generated
View File

@@ -190,6 +190,18 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
name = "monorepo"
version = "0.1.0"
[[package]]
name = "natu"
version = "0.1.0"
dependencies = [
"clap",
"googletest",
"monorepo",
"rnix",
"rowan",
"status",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -393,18 +405,6 @@ dependencies = [
"windows-link",
]
[[package]]
name = "xatu"
version = "0.1.0"
dependencies = [
"clap",
"googletest",
"monorepo",
"rnix",
"rowan",
"status",
]
[[package]]
name = "zmij"
version = "1.0.23"

View File

@@ -4,7 +4,7 @@ members = [
"src/machoke",
"src/monorepo",
"src/status",
"src/xatu",
"src/natu",
]
resolver = "3"

View File

@@ -14,4 +14,5 @@ rust = use_extension("//bazel:rust.bzl", "rust")
use_repo(rust, "rust")
register_toolchains("@python//:python")
register_toolchains("@rust//:rust")

View File

@@ -3,7 +3,7 @@
- machoke
- falinks
- dotfiles
- xatu
- natu
- nix-style / refactor
# project ideas
@@ -100,7 +100,7 @@
- https://www.youtube.com/watch?v=kzcI5F4tGiU
- https://www.youtube.com/watch?v=iKwPaB5TUdI
- https://www.youtube.com/watch?v=A-CtdQFRX64
- xatu literature
- natu literature
- https://rust-analyzer.github.io/book/contributing/syntax.html?utm_source=chatgpt.com
- https://github.com/dotnet/roslyn/blob/main/docs/compilers/Design/Red-Green%20Trees.md?utm_source=chatgpt.com
- https://github.com/rust-analyzer/rowan/blob/master/examples/s_expressions.rs?utm_source=chatgpt.com

View File

@@ -24,7 +24,7 @@ in
configs/nixos/hosts/neogaia/hardware-configuration.nix \
configs/nixos/hosts/pikachu/hardware-configuration.nix \
configs/nixos/hosts/zeus/hardware-configuration.nix \
src/xatu/testdata \
src/natu/testdata \
third_party \
-- .
treefmt

View File

@@ -6,7 +6,7 @@ inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} {
settings.formatter.nixfmt.excludes = [
"configs/nixos/hosts/*/hardware-configuration.nix"
"src/xatu/testdata/*.nix"
"src/natu/testdata/*.nix"
"third_party/**"
];
}

View File

@@ -1,11 +1,12 @@
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
rust_library(
name = "xatu_lib",
crate_name = "xatu",
name = "natu_lib",
crate_name = "natu",
srcs = [
"ast.rs",
"file_store.rs",
"natu.rs",
"parser.rs",
"rules.rs",
"rules/let_order.rs",
@@ -13,7 +14,6 @@ rust_library(
"rules/manual_inherit_from.rs",
"rules/unquoted_uri.rs",
"scope_graph.rs",
"xatu.rs",
],
deps = [
"//src/status:status",
@@ -25,30 +25,30 @@ rust_library(
rust_test(
name = "file_store_test",
srcs = ["file_store_test.rs"],
deps = [":xatu_lib"],
deps = [":natu_lib"],
)
rust_test(
name = "xatu_test",
srcs = ["xatu_test.rs"],
name = "natu_test",
srcs = ["natu_test.rs"],
data = [
"testdata/clean.nix",
"testdata/invalid.nix",
"testdata/lint_findings.nix",
],
deps = [
":xatu_lib",
":natu_lib",
"//src/status:status",
"//third_party/crates:googletest",
],
)
rust_binary(
name = "xatu",
crate_name = "xatu_cli",
srcs = ["xatu_main.rs"],
name = "natu",
crate_name = "natu_cli",
srcs = ["natu_main.rs"],
deps = [
":xatu_lib",
":natu_lib",
"//src/monorepo:monorepo",
"//src/status:status",
"//third_party/crates:clap",

View File

@@ -1,14 +1,14 @@
[package]
name = "xatu"
name = "natu"
version = "0.1.0"
edition = "2024"
[lib]
path = "xatu.rs"
path = "natu.rs"
[[bin]]
name = "xatu"
path = "xatu_main.rs"
name = "natu"
path = "natu_main.rs"
[dependencies]
clap = { workspace = true, features = ["derive"] }

View File

@@ -1,6 +1,6 @@
use std::path::PathBuf;
use xatu::{FileStore, SourceFile};
use natu::{FileStore, SourceFile};
fn source_file(path: &str, source: &str) -> SourceFile {
SourceFile {

View File

@@ -53,7 +53,7 @@ fn line_range(source: &str, range: ast::SourceRange) -> (usize, usize) {
(start, end)
}
/// Analyzes source files and returns the diagnostics Xatu finds.
/// Analyzes source files and returns the diagnostics Natu finds.
pub fn future_sight(files: Vec<SourceFile>) -> status::Result<Report> {
let mut store = FileStore::default();
let mut diagnostics = Vec::new();

View File

@@ -1,8 +1,8 @@
use clap::Parser;
use natu::{Report, SourceFile};
use status::ResultExt;
use std::path::{Path, PathBuf};
use std::process::ExitCode;
use xatu::{Report, SourceFile};
fn main() -> ExitCode {
let args = Args::parse();
@@ -44,7 +44,7 @@ fn analyze(args: Args) -> status::Result<Report> {
.flatten()
.collect();
xatu::future_sight(files)
natu::future_sight(files)
}
fn collect_source_files(path: &Path) -> status::Result<Vec<SourceFile>> {

View File

@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
use googletest::matchers::{contains, eq, is_true};
use googletest::{OrFail, expect_that, gtest};
use status::Code;
use xatu::SourceFile;
use natu::SourceFile;
fn fixture_source(path: &str) -> googletest::Result<SourceFile> {
Ok(SourceFile {
@@ -20,20 +20,20 @@ fn fixture_path(path: &str) -> googletest::Result<PathBuf> {
let runfiles = PathBuf::from(std::env::var("TEST_SRCDIR").or_fail()?);
let workspace = std::env::var("TEST_WORKSPACE").or_fail()?;
Ok(runfiles.join(workspace).join("src/xatu").join(path))
Ok(runfiles.join(workspace).join("src/natu").join(path))
}
#[gtest]
fn xatu_accepts_clean_source() -> googletest::Result<()> {
let report = xatu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?;
fn natu_accepts_clean_source() -> googletest::Result<()> {
let report = natu::future_sight(vec![fixture_source("testdata/clean.nix")?]).or_fail()?;
expect_that!(report.is_clean(), is_true());
Ok(())
}
#[gtest]
fn xatu_rejects_invalid_source() -> googletest::Result<()> {
let error = xatu::future_sight(vec![fixture_source("testdata/invalid.nix")?])
fn natu_rejects_invalid_source() -> googletest::Result<()> {
let error = natu::future_sight(vec![fixture_source("testdata/invalid.nix")?])
.err()
.or_fail()?;
@@ -42,8 +42,8 @@ fn xatu_rejects_invalid_source() -> googletest::Result<()> {
}
#[gtest]
fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
fn natu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
let let_order_count = report
.diagnostics
@@ -55,8 +55,8 @@ fn xatu_reports_out_of_order_let_bindings() -> googletest::Result<()> {
}
#[gtest]
fn xatu_reports_unquoted_uri() -> googletest::Result<()> {
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
fn natu_reports_unquoted_uri() -> googletest::Result<()> {
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
let findings = report
.diagnostics
@@ -79,8 +79,8 @@ fn xatu_reports_unquoted_uri() -> googletest::Result<()> {
}
#[gtest]
fn xatu_reports_manual_inherit() -> googletest::Result<()> {
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
fn natu_reports_manual_inherit() -> googletest::Result<()> {
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
let manual_inherit_count = report
.diagnostics
@@ -92,8 +92,8 @@ fn xatu_reports_manual_inherit() -> googletest::Result<()> {
}
#[gtest]
fn xatu_reports_manual_inherit_from() -> googletest::Result<()> {
let report = xatu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
fn natu_reports_manual_inherit_from() -> googletest::Result<()> {
let report = natu::future_sight(vec![fixture_source("testdata/lint_findings.nix")?]).or_fail()?;
let manual_inherit_from_count = report
.diagnostics

View File

@@ -314,8 +314,8 @@ _CRATE_EDITIONS = {
"src/ariadne": "2024",
"src/machoke": "2024",
"src/monorepo": "2024",
"src/natu": "2024",
"src/status": "2024",
"src/xatu": "2024",
}
_NORMAL_DEPENDENCIES = {
@@ -335,15 +335,15 @@ _NORMAL_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
},
"src/xatu": {
"src/natu": {
_COMMON_CONDITION: {
"clap": Label("//third_party/crates/clap-4.6.7:clap"),
"rnix": Label("//third_party/crates/rnix-0.14.0:rnix"),
"rowan": Label("//third_party/crates/rowan-0.16.1:rowan"),
},
},
"src/status": {
},
}
_NORMAL_ALIASES = {
@@ -359,12 +359,12 @@ _NORMAL_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
},
"src/xatu": {
"src/natu": {
_COMMON_CONDITION: {
},
},
"src/status": {
},
}
_NORMAL_DEV_DEPENDENCIES = {
@@ -376,13 +376,13 @@ _NORMAL_DEV_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
},
"src/xatu": {
"src/natu": {
_COMMON_CONDITION: {
"googletest": Label("//third_party/crates/googletest-0.14.3:googletest"),
},
},
"src/status": {
},
}
_NORMAL_DEV_ALIASES = {
@@ -394,12 +394,12 @@ _NORMAL_DEV_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
},
"src/xatu": {
"src/natu": {
_COMMON_CONDITION: {
},
},
"src/status": {
},
}
_PROC_MACRO_DEPENDENCIES = {
@@ -411,9 +411,9 @@ _PROC_MACRO_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -426,9 +426,9 @@ _PROC_MACRO_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -441,9 +441,9 @@ _PROC_MACRO_DEV_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -456,12 +456,12 @@ _PROC_MACRO_DEV_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
},
"src/xatu": {
"src/natu": {
_COMMON_CONDITION: {
},
},
"src/status": {
},
}
_BUILD_DEPENDENCIES = {
@@ -473,9 +473,9 @@ _BUILD_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -488,9 +488,9 @@ _BUILD_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -503,9 +503,9 @@ _BUILD_PROC_MACRO_DEPENDENCIES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}
@@ -518,9 +518,9 @@ _BUILD_PROC_MACRO_ALIASES = {
},
"src/monorepo": {
},
"src/status": {
"src/natu": {
},
"src/xatu": {
"src/status": {
},
}