Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 6 additions & 34 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.2.7"
[workspace.dependencies]
whitaker-common = { path = "common", version = "0.2.7" }
whitaker-installer = { path = "installer", version = "0.2.7" }
whitaker = { path = ".", version = "0.2.7" }
whitaker_lint_core = { path = "crates/whitaker_lint_core", version = "0.2.7" }
camino = "1.2.1"
cap-std = { version = "4.0.2", features = ["fs_utf8"] }
cargo_metadata = "0.23.0"
Expand Down Expand Up @@ -69,42 +69,14 @@ rustc_span = { path = "crates/rustc_span", version = "0.2.7" }
name = "whitaker"
version = "0.2.7"
edition = "2024"

[features]
default = []
dylint-driver = [
"dep:dylint_linting",
"dep:rustc_ast",
"dep:rustc_hir",
"dep:rustc_lint",
"dep:rustc_span",
]
description = "Whitaker command-line interface"
license.workspace = true
repository.workspace = true
homepage.workspace = true
documentation.workspace = true

[dependencies]

camino = { workspace = true }
cargo_metadata = { workspace = true }
clap = { workspace = true, features = ["derive"] }
serde = { workspace = true }
toml = { workspace = true }
thiserror = { workspace = true }
whitaker-common = { workspace = true }
whitaker-installer = { workspace = true }

rustc_ast = { workspace = true, optional = true }
rustc_hir = { workspace = true, optional = true }
rustc_lint = { workspace = true, optional = true }
rustc_span = { workspace = true, optional = true }
dylint_linting = { workspace = true, optional = true }

[dev-dependencies]
whitaker_test_macros = { workspace = true }
whitaker-common = { workspace = true }
rstest = { workspace = true }
rstest-bdd = { workspace = true }
rstest-bdd-macros = { workspace = true }
dylint_testing = { workspace = true }

[lints]
workspace = true

Expand Down
30 changes: 17 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ CARGO_FLAGS ?= --workspace --all-targets --all-features
# Lint every other target rather than `--all-targets`; `typecheck` still builds
# the fixtures, and the suite still lints them through the UI harness.
CLIPPY_FLAGS ?= --workspace --lib --bins --tests --benches --all-features
TEST_EXCLUDES ?= --exclude rustc_ast --exclude rustc_attr_data_structures --exclude rustc_hir --exclude rustc_lint --exclude rustc_middle --exclude rustc_session --exclude rustc_span --exclude whitaker --exclude function_attrs_follow_docs --exclude module_max_lines --exclude no_expect_outside_tests
TEST_EXCLUDES ?= --exclude rustc_ast --exclude rustc_attr_data_structures --exclude rustc_hir --exclude rustc_lint --exclude rustc_middle --exclude rustc_session --exclude rustc_span --exclude whitaker_lint_core --exclude function_attrs_follow_docs --exclude module_max_lines --exclude no_expect_outside_tests
TEST_CARGO_FLAGS ?= $(CARGO_FLAGS) $(TEST_EXCLUDES)
# The Dylint driver feature links compiler-private crates. Cargo unifies that
# feature for the all-workspace pass, so exercise core's ordinary tests in a
# dedicated feature-free invocation rather than excluding their coverage.
CORE_TEST_CARGO_FLAGS ?= -p whitaker_lint_core --no-default-features
NEXTEST_PROFILE ?=
# The cargo test driver. `test` runs `cargo nextest run`; `coverage`
# overrides this with `cargo llvm-cov nextest ...` so instrumentation runs
Expand Down Expand Up @@ -56,14 +60,12 @@ SPELLING_HELPER_PYTEST = PYTHONPATH=scripts $(SPELLING_PY_ENV) \
--with pytest-cov==7.0.0 python -m pytest
WORKFLOW_TEST_VENV ?= .venv
LINT_CRATES ?= bumpy_road_function conditional_max_n_branches function_attrs_follow_docs module_max_lines module_must_have_inner_docs no_expect_outside_tests test_must_not_have_example no_std_fs_operations no_unwrap_or_else_panic whitaker_suite
# Doctests compile as their own crate and do not inherit the lib's
# `#![cfg_attr(feature = "dylint-driver", feature(rustc_private))]`, so the
# Dylint driver crates cannot link `rustc_driver` from a doctest and fail with
# "use of unstable library feature `rustc_private`". Their examples are covered
# by the unit and UI suites instead, so exclude them from the doctest run.
# Doctests for the Dylint driver crates cannot link `rustc_driver`, because
# doctest crates do not inherit the `rustc_private` feature configuration.
# Their examples are covered by the unit and UI suites instead.
DOCTEST_EXCLUDES ?= --exclude rustc_ast --exclude rustc_attr_data_structures \
--exclude rustc_hir --exclude rustc_lint --exclude rustc_middle \
--exclude rustc_session --exclude rustc_span --exclude whitaker \
--exclude rustc_session --exclude rustc_span --exclude whitaker_lint_core \
--exclude rstest_helper_should_be_fixture \
$(foreach crate,$(LINT_CRATES),--exclude $(crate))
CARGO_DYLINT_VERSION ?= 6.0.1
Expand All @@ -73,12 +75,11 @@ DYLINT_LINK_VERSION ?= 6.0.1
DYLINT_TOOLS_TOOLCHAIN ?= stable
WHITAKER_SCRIPT ?= $(HOME)/.local/bin/whitaker
WHITAKER ?= whitaker
# Crates linted by the Whitaker suite. The rustc_* proxy shims, the lint
# crates, the aggregated suite, and the whitaker root crate all require
# rustc_private plumbing (dylint-driver feature, prefer-dynamic RUSTFLAGS)
# that `cargo dylint`'s plain check build cannot provide, so the suite runs
# over the support crates that build as ordinary libraries.
WHITAKER_PACKAGES ?= -p whitaker-common -p whitaker-installer -p whitaker_clones_core -p whitaker_sarif
# Crates linted by the Whitaker suite. The rustc_* proxy shims, lint crates,
# aggregated suite, and `whitaker_lint_core` require `rustc_private` plumbing
# that `cargo dylint`'s plain check build cannot provide. The root CLI does
# not, so the suite covers it with the ordinary support crates.
WHITAKER_PACKAGES ?= -p whitaker -p whitaker-common -p whitaker-installer -p whitaker_clones_core -p whitaker_sarif

build: target/debug/$(APP) ## Build debug binary
release: target/release/$(APP) ## Build release binary
Expand Down Expand Up @@ -133,7 +134,9 @@ test: ## Run tests with warnings treated as errors
WHITAKER_BACKUP=""; \
fi; \
RUSTFLAGS="-C prefer-dynamic -Z force-unstable-if-unmarked $(RUST_FLAGS)" $(CARGO) $(TEST_RUNNER) $(CARGO_LOCKED) $(TEST_CARGO_FLAGS) $(BUILD_JOBS) $(if $(NEXTEST_PROFILE),--profile $(NEXTEST_PROFILE)); \
RUSTFLAGS="$(RUST_FLAGS)" $(CARGO) nextest run $(CARGO_LOCKED) $(CORE_TEST_CARGO_FLAGS) $(BUILD_JOBS) $(if $(NEXTEST_PROFILE),--profile $(NEXTEST_PROFILE)); \
RUSTFLAGS="$(RUST_FLAGS)" $(CARGO) test --workspace --doc --all-features $(DOCTEST_EXCLUDES) $(BUILD_JOBS); \
RUSTFLAGS="$(RUST_FLAGS)" $(CARGO) test $(CARGO_LOCKED) $(CORE_TEST_CARGO_FLAGS) --doc $(BUILD_JOBS); \
if [ "$${ACT_WORKFLOW_TESTS:-0}" = "1" ]; then \
$(MAKE) workflow-test; \
fi
Expand Down Expand Up @@ -323,6 +326,7 @@ publish-check: ## Build, test, and validate packages before publishing
rustup component add --toolchain "$$TOOLCHAIN" rust-src rustc-dev llvm-tools-preview; \
RUSTFLAGS="$(RUST_FLAGS)" $(CARGO) build $(CARGO_LOCKED) --workspace --all-features $(BUILD_JOBS); \
RUSTFLAGS="-Z force-unstable-if-unmarked $(RUST_FLAGS)" $(CARGO) +$$TOOLCHAIN nextest run $(CARGO_LOCKED) --profile ci $(TEST_CARGO_FLAGS) $(BUILD_JOBS); \
RUSTFLAGS="$(RUST_FLAGS)" $(CARGO) +$$TOOLCHAIN nextest run $(CARGO_LOCKED) --profile ci $(CORE_TEST_CARGO_FLAGS) $(BUILD_JOBS); \
TMP_DIR=$$(mktemp -d); \
trap 'rm -rf "$$TMP_DIR"' 0 INT TERM HUP; \
DYLINT_TOOLS_DIR="$$TMP_DIR/dylint-tools"; \
Expand Down
6 changes: 3 additions & 3 deletions crates/bumpy_road_function/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dylint-driver = [
"dep:rustc_session",
"dep:rustc_span",
"dep:serde",
"dep:whitaker",
"dep:whitaker_lint_core",
]
constituent = ["dylint-driver", "dylint_linting/constituent"]

Expand All @@ -39,7 +39,7 @@ rustc_lint = { workspace = true, optional = true }
rustc_session = { workspace = true, optional = true }
rustc_span = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
whitaker = { workspace = true, features = ["dylint-driver"], optional = true }
whitaker_lint_core = { workspace = true, features = ["dylint-driver"], optional = true }

[dev-dependencies]
whitaker_test_macros = { workspace = true }
Expand All @@ -48,7 +48,7 @@ rstest-bdd = { workspace = true }
rstest-bdd-macros = { workspace = true }
dylint_testing = { workspace = true }
toml = { workspace = true }
whitaker = { workspace = true }
whitaker_lint_core = { workspace = true }
whitaker-common = { workspace = true }
camino = { workspace = true }
tempfile = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/bumpy_road_function/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use rustc_hir as hir;
use rustc_hir::ExprKind;
use rustc_lint::{LateContext, LateLintPass};
use rustc_span::{Ident, Span, symbol::Symbol};
use whitaker::SharedConfig;
use whitaker_common::{
Localizer,
complexity_signal::{rasterize_signal, smooth_moving_average},
get_localizer_for_lint,
i18n::MessageKey,
};
use whitaker_lint_core::SharedConfig;

use crate::analysis::{Settings, detect_bumps, normalize_settings};

Expand Down
7 changes: 3 additions & 4 deletions crates/bumpy_road_function/tests/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ use whitaker_common::test_support::{prepare_fixture, run_fixtures_with, run_test
fn ui() {
let crate_name = env!("CARGO_PKG_NAME");
let directory = "ui";
whitaker::testing::ui::run_with_runner(crate_name, directory, run_fixtures).unwrap_or_else(
|error| {
whitaker_lint_core::testing::ui::run_with_runner(crate_name, directory, run_fixtures)
.unwrap_or_else(|error| {
panic!(
"UI tests should execute without diffs: RunnerFailure {{ crate_name: \
\"{crate_name}\", directory: \"{directory}\", message: {error} }}"
)
},
);
});
}

fn run_fixtures(crate_name: &str, directory: &Utf8Path) -> Result<(), String> {
Expand Down
6 changes: 3 additions & 3 deletions crates/conditional_max_n_branches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dylint-driver = [
"dep:rustc_session",
"dep:rustc_span",
"dep:serde",
"dep:whitaker"
"dep:whitaker_lint_core"
]
constituent = ["dylint-driver", "dylint_linting/constituent"]

Expand All @@ -39,12 +39,12 @@ rustc_lint = { workspace = true, optional = true }
rustc_session = { workspace = true, optional = true }
rustc_span = { workspace = true, optional = true }
serde = { workspace = true, optional = true }
whitaker = { workspace = true, features = ["dylint-driver"], optional = true }
whitaker_lint_core = { workspace = true, features = ["dylint-driver"], optional = true }

[dev-dependencies]
whitaker_test_macros = { workspace = true }
whitaker-common = { workspace = true }
whitaker = { workspace = true }
whitaker_lint_core = { workspace = true }
camino = { workspace = true }
glob = "0.3.0"
tempfile = "3.14.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/conditional_max_n_branches/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rustc_hir::{BinOpKind, ExprKind, LoopSource, UnOp};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_span::{DesugaringKind, Span};
use serde::Deserialize;
use whitaker::SharedConfig;
use whitaker_common::{
Arguments,
FALLBACK_LOCALE,
Expand All @@ -26,6 +25,7 @@ use whitaker_common::{
noop_reporter,
safe_resolve_message_set,
};
use whitaker_lint_core::SharedConfig;

const LINT_NAME: &str = "conditional_max_n_branches";
const MESSAGE_KEY: MessageKey<'static> = MessageKey::new(LINT_NAME);
Expand Down
Loading
Loading