Skip to content

Commit b808dac

Browse files
committed
chore: Update code analysis
1 parent 19fb6ac commit b808dac

23 files changed

+187
-140
lines changed

BUILD.bazel

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1 @@
1-
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test", "rust_doc_test")
2-
load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
3-
4-
package(default_visibility = ["//visibility:public"])
5-
6-
rust_library(
7-
name = "singularity-code-analysis",
8-
srcs = glob(["src/**/*.rs"]),
9-
aliases = aliases(),
10-
deps = all_crate_deps() + [
11-
"//crates/vendor/singularity-code-analysis/enums",
12-
"//crates/vendor/singularity-language-registry",
13-
],
14-
proc_macro_deps = all_crate_deps(proc_macro = True),
15-
)
16-
17-
rust_test(
18-
name = "singularity_code_analysis_test",
19-
crate = ":singularity-code-analysis",
20-
deps = all_crate_deps(test = True),
21-
)
22-
23-
rust_doc_test(
24-
name = "singularity_code_analysis_doc_test",
25-
crate = ":singularity-code-analysis",
26-
)
1+
# singularity-code-analysis

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ keywords = ["metrics", "complexity", "analysis", "ai"]
99
repository = "https://github.com/mikkihugo/singularity-code-analysis"
1010
categories = ["development-tools", "parsing"]
1111

12+
# Mark as standalone crate (not part of parent workspace)
13+
[workspace]
14+
1215
[lib]
1316
name = "singularity_analysis_engine"
1417
crate-type = ["rlib", "cdylib"]
@@ -22,7 +25,7 @@ num-derive = "0.4"
2225
num-format = "0.4"
2326
petgraph = "0.8"
2427
regex = "1.0"
25-
serde = { workspace = true, features = ["derive"] }
28+
serde = { version = "1.0", features = ["derive"] }
2629
termcolor = "1.2"
2730
walkdir = "2.0"
2831

enums/BUILD.bazel

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1 @@
1-
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test", "rust_doc_test")
2-
load("@crate_index//:defs.bzl", "aliases", "all_crate_deps")
3-
4-
package(default_visibility = ["//visibility:public"])
5-
6-
rust_library(
7-
name = "enums",
8-
srcs = glob(["src/**/*.rs"]),
9-
aliases = aliases(),
10-
deps = all_crate_deps(),
11-
proc_macro_deps = all_crate_deps(proc_macro = True),
12-
)
13-
14-
rust_test(
15-
name = "enums_test",
16-
crate = ":enums",
17-
deps = all_crate_deps(test = True),
18-
)
19-
20-
rust_doc_test(
21-
name = "enums_doc_test",
22-
crate = ":enums",
23-
)
1+
# enums subpackage

enums/src/main.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ fn apply_existing_variants(
206206
existing: &mut HashMap<String, VecDeque<String>>,
207207
) -> Vec<KindInfo> {
208208
for kind in &mut kinds {
209-
if let Some(names) = existing.get_mut(&kind.literal) && let Some(existing_name) = names.pop_front() {
210-
kind.variant = existing_name;
209+
if let Some(names) = existing.get_mut(&kind.literal) {
210+
if let Some(existing_name) = names.pop_front() {
211+
kind.variant = existing_name;
211212
continue;
213+
}
212214
}
213215
}
214216
kinds

examples/inspect_elixir.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ end
4242
let Ok(kind_id) = u16::try_from(i) else {
4343
break;
4444
};
45-
if language.node_kind_is_named(kind_id) && let Some(kind) = language.node_kind_for_id(kind_id) {
46-
println!("{kind_id:3}: {kind}");
45+
if language.node_kind_is_named(kind_id) {
46+
if let Some(kind) = language.node_kind_for_id(kind_id) {
47+
println!("{kind_id:3}: {kind}");
48+
}
4749
}
4850
}
4951
}

examples/inspect_erlang.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ is_even(N) ->
3131

3232
println!("\n=== All Named Node Kinds ===");
3333
for i in 0..language.node_kind_count() {
34-
if language.node_kind_is_named(i as u16) && let Some(kind) = language.node_kind_for_id(i as u16) {
35-
println!("{:3}: {}", i, kind);
34+
if language.node_kind_is_named(i as u16) {
35+
if let Some(kind) = language.node_kind_for_id(i as u16) {
36+
println!("{:3}: {}", i, kind);
37+
}
3638
}
3739
}
3840
}

examples/inspect_gleam.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ fn private_function(x: Int) -> String {
3737

3838
println!("\n=== All Named Node Kinds ===");
3939
for i in 0..language.node_kind_count() {
40-
if language.node_kind_is_named(i as u16) && let Some(kind) = language.node_kind_for_id(i as u16) {
41-
println!("{:3}: {}", i, kind);
40+
if language.node_kind_is_named(i as u16) {
41+
if let Some(kind) = language.node_kind_for_id(i as u16) {
42+
println!("{:3}: {}", i, kind);
43+
}
4244
}
4345
}
4446
}

examples/inspect_python.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def f(a, b):
2525
let Ok(kind_id) = u16::try_from(i) else {
2626
break;
2727
};
28-
if language.node_kind_is_named(kind_id) && let Some(kind) = language.node_kind_for_id(kind_id) {
29-
println!("{kind_id:3}: {kind}");
28+
if language.node_kind_is_named(kind_id) {
29+
if let Some(kind) = language.node_kind_for_id(kind_id) {
30+
println!("{kind_id:3}: {kind}");
31+
}
3032
}
3133
}
3234
}

src/alterator.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ impl Alterator for CppCode {
8484
AstNode::new(node.kind(), text, span, Vec::new())
8585
}
8686
Cpp::PreprocDef | Cpp::PreprocFunctionDef | Cpp::PreprocCall => {
87-
if let Some(last) = children.last() && last.r#type == "\n" {
88-
children.pop();
87+
if let Some(last) = children.last() {
88+
if last.r#type == "\n" {
89+
children.pop();
90+
}
8991
}
9092
Self::get_default(node, code, span, children)
9193
}

src/bin/cli.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,12 @@ fn collect_files_recursive(dir: &Path) -> Result<Vec<PathBuf>> {
473473
let mut files = Vec::new();
474474
for entry in walkdir::WalkDir::new(dir).follow_links(true) {
475475
let entry = entry?;
476-
if entry.file_type().is_file() && let Some(ext) = entry.path().extension() && is_source_file(ext.to_str().unwrap_or("")) {
477-
files.push(entry.path().to_path_buf());
476+
if entry.file_type().is_file() {
477+
if let Some(ext) = entry.path().extension() {
478+
if is_source_file(ext.to_str().unwrap_or("")) {
479+
files.push(entry.path().to_path_buf());
480+
}
481+
}
478482
}
479483
}
480484
Ok(files)
@@ -484,8 +488,12 @@ fn collect_files_single(dir: &Path) -> Result<Vec<PathBuf>> {
484488
let mut files = Vec::new();
485489
for entry in fs::read_dir(dir)? {
486490
let entry = entry?;
487-
if entry.file_type()?.is_file() && let Some(ext) = entry.path().extension() && is_source_file(ext.to_str().unwrap_or("")) {
488-
files.push(entry.path());
491+
if entry.file_type()?.is_file() {
492+
if let Some(ext) = entry.path().extension() {
493+
if is_source_file(ext.to_str().unwrap_or("")) {
494+
files.push(entry.path());
495+
}
496+
}
489497
}
490498
}
491499
Ok(files)

0 commit comments

Comments
 (0)