+
Skip to content
Open
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
1,427 changes: 1,427 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ env_logger = "0.11.8"
eon = "0.2"
itertools = "0.14"
log = "0.4.28"
log-once = "0.4.1"
object = "0.37.3"
petgraph = "0.8.2"
proc-macro2 = "1.0.101"
Expand Down Expand Up @@ -61,6 +60,7 @@ broken_intra_doc_links = "warn"
all = { level = "warn", priority = -1 }

allow_attributes = "warn"
allow_attributes_without_reason = "warn"
as_ptr_cast_mut = "warn"
await_holding_lock = "warn"
bool_to_int_with_if = "warn"
Expand Down Expand Up @@ -89,6 +89,7 @@ empty_line_after_outer_attr = "warn"
enum_glob_use = "warn"
equatable_if_let = "warn"
exit = "warn"
expect_used = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
Expand Down Expand Up @@ -220,7 +221,7 @@ unused_peekable = "warn"
unused_rounding = "warn"
unused_self = "warn"
unused_trait_names = "warn"
# unwrap_used = "warn" // TODO:
unwrap_used = "warn" # TODO:
use_self = "warn"
useless_let_if_seq = "warn"
useless_transmute = "warn"
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-unwrap-in-tests = true
1 change: 0 additions & 1 deletion crates/cargo-caps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ cpp_demangle.workspace = true
env_logger.workspace = true
eon.workspace = true
itertools.workspace = true
log-once.workspace = true
log.workspace = true
object.workspace = true
petgraph.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/cargo-caps/src/build_graph_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl DepGraph {
let mut queue = VecDeque::new();

// Start with all nodes that have non-empty 'kind' field
#[expect(clippy::iter_over_hash_type)]
#[expect(clippy::iter_over_hash_type, reason = "We need both key and value")]
for &node_idx in self.package_to_node.values() {
if !self.graph[node_idx].kind.is_empty() {
queue.push_back(node_idx);
Expand Down Expand Up @@ -250,7 +250,7 @@ fn dependency_kind_from_edge_and_dependent(edge: &Edge, dependent: &Node) -> BTr

#[cfg(test)]
mod tests {
#![allow(clippy::single_char_pattern)]
#![allow(clippy::single_char_pattern, reason = "Test code")]

use cargo_metadata::PackageId;

Expand Down
4 changes: 4 additions & 0 deletions crates/cargo-caps/src/cap_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ pub struct SymbolRules {
}

impl SymbolRules {
#[expect(
clippy::expect_used,
reason = "Default rules are hardcoded, so this should never fail"
)]
pub fn load_default() -> Self {
static DEFAULT_RULES_EON: &str = include_str!("default_rules.eon");

Expand Down
11 changes: 8 additions & 3 deletions crates/cargo-caps/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{
config::WorkspaceConfig,
src_analysis::ParsedRust,
};
use anyhow::Context as _;
use cargo_metadata::{
Artifact, DependencyKind, Metadata, Package, PackageId, TargetKind, camino::Utf8Path,
};
Expand Down Expand Up @@ -48,7 +49,7 @@ impl Checker {
.packages
.iter()
.find(|p| p.id == artifact.package_id)
.unwrap(); // TODO
.context("Failed to find package in metadata")?;

let set = if let Some(set) = crate_infos.get(&artifact.package_id) {
// TODO
Expand Down Expand Up @@ -164,12 +165,16 @@ impl Checker {

// Extend capabilities with the capabilities of our supposed dependencies.
// TODO: we do it already above, but differently
let resolve = self.metadata.resolve.as_ref().unwrap();
let resolve = self
.metadata
.resolve
.as_ref()
.context("Failed to resolve dependencies in metadata")?;
let node = resolve
.nodes
.iter()
.find(|node| node.id == package.id)
.unwrap();
.context("Failed to find package in dependency tree")?;
for dependency in &node.deps {
if !dependency
.dep_kinds
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-caps/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CheckCommand {

let mut child = cmd.stdout(Stdio::piped()).spawn()?;

let stdout = child.stdout.take().unwrap();
let stdout = child.stdout.take().context("Failed to capture stdout")?;
let reader = BufReader::new(stdout);

let checker = Checker {
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-caps/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::Context as _;
pub struct InitCommand;

impl InitCommand {
#[expect(clippy::unused_self)]
#[expect(clippy::unused_self, reason = "we need the self parameter for clap")]
pub fn execute(self) -> anyhow::Result<()> {
let config_path = Path::new("cargo-caps.eon");

Expand Down
5 changes: 4 additions & 1 deletion crates/cargo-caps/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ fn collect_file_symbols(all_symbols: &mut Vec<Symbol>, file: &object::File<'_>)
ObjectSymbolScope::Dynamic => SymbolScope::Dynamic,
};

#[expect(clippy::match_same_arms)]
#[expect(
clippy::match_same_arms,
reason = "For readability, we want to list all cases"
)]
let kind = match symbol.kind() {
ObjectSymbolKind::Unknown => SymbolKind::Unknown,
ObjectSymbolKind::Text => SymbolKind::Text,
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-caps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct Args {
}

fn main() {
#![allow(clippy::exit)]
#![allow(clippy::exit, reason = "we want to exit with code 1 on error")] // --> we could also return a Result from main so its more clear?

env_logger::init();

Expand Down
6 changes: 5 additions & 1 deletion crates/cargo-caps/src/rust_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ impl RustPath {
use std::sync::LazyLock;

// Compile the regex once at program startup
#[expect(
clippy::expect_used,
reason = "The regex is hardcoded and should never fail to compile"
)]
static PATH_REGEX: LazyLock<regex::Regex> = LazyLock::new(|| {
regex::RegexBuilder::new(
r"
Expand All @@ -58,7 +62,7 @@ impl RustPath {
.ignore_whitespace(true)
.unicode(false)
.build()
.unwrap()
.expect("Failed to build regex")
});

PATH_REGEX
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-caps/src/src_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'ast> Visit<'ast> for ParserState {
}

fn visit_attribute(&mut self, input: &'ast syn::Attribute) {
#[expect(clippy::match_same_arms)]
#[expect(clippy::match_same_arms, reason = "We will add more cases later")]
match &input.meta {
syn::Meta::Path(_) => {
// e.g. `#[test]`
Expand Down
4 changes: 4 additions & 0 deletions crates/cargo-caps/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl Tree {
}

/// Collapse nodes that contain only a single leaf, recursively
#[expect(
clippy::expect_used,
reason = "Child node should exist since we checked children.len() == 1"
)]
pub fn collapse_single_nodes(self, depth: usize, may_collapse: bool) -> Self {
match self {
Self::Leaf(_) => self,
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载