-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add language-frontend extractors for graph parity #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
5936e1a
feat: add language-frontend extractors for graph parity
jonathanong 7c62c29
Merge remote-tracking branch 'origin/main' into feat/language-parity
jonathanong e03b3b7
style: rustfmt language frontend modules
jonathanong e738c39
fix: wire language filters into the graph plan
jonathanong b7e9ae0
fix: tighten Kafka produce matching and Rust status docs
jonathanong a81584f
fix: honor tests.php.framework for Laravel extractors
jonathanong 696d22f
fix: tighten language extractors and split oversized modules
jonathanong 02f2afd
fix: match language graph keys and advertised edge kinds
jonathanong 5dc8413
fix: drop package cliques and tighten language extractors
jonathanong 3adc29f
merge: origin/main into feat/language-parity
jonathanong 0779195
fix: intern language queue and file nodes as Arc<Path>
jonathanong a58f2d6
merge: origin/main into feat/language-parity
jonathanong 8ef67f4
test: cover language frontend graph edges and extractor branches
jonathanong 81e8339
fix: prefix project queue globs and expand PHP grouped uses
jonathanong 84173fb
fix: index PHP composer.json and public Rust use items
jonathanong 43c9941
fix: prefer crate roots, Django as_view, and deepest Go modules
jonathanong 0f6f566
fix: index PHP interfaces and Ruby require paths
jonathanong b1264a9
fix: keep Rails controller namespaces and PHP import aliases
jonathanong 10b82cc
fix: tighten language extractors after review fix-thrash
jonathanong a11f5b7
fix: scope imports, namespaced Rails, and language graph invalidation
jonathanong de08218
fix: move Python import tests out of source and satisfy clippy
jonathanong 1406469
fix: more language extractor edge cases from review
jonathanong b460e8d
fix: resolve relative Rust uses and remaining extractor nits
jonathanong 8140935
test: cover language relationship sort keys and build-plan flags
jonathanong a5f2104
fix: extract language-frontend build-plan flag to cut CRAP
jonathanong 43a8dd3
fix: resolve framework import aliases and tighten enqueue matching
jonathanong ce69ab8
fix: prune nested Go modules, normalize Ruby requires, qualify Larave…
jonathanong 66f2851
fix: scope language edges and close remaining extractor gaps
jonathanong ff62bc1
fix: close remaining language extractor review gaps
jonathanong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
crates/no-mistakes/src/codebase/dependencies/graph/build_plan_facts.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| fn graph_plan_needs_config(plan: GraphBuildPlan) -> bool { | ||
| plan.ci | ||
| || plan.workflow_topology | ||
| || plan.routes | ||
| || plan.queues | ||
| || plan.http | ||
| || plan.tests | ||
| || plan.dotnet | ||
| || plan.swift | ||
| || plan.terraform | ||
| || plan.language_frontends | ||
| } | ||
|
|
||
| fn effective_ts_fact_plan( | ||
| plan: GraphBuildPlan, | ||
| options: Option<&GraphConfigOptions>, | ||
| ) -> TsFactPlan { | ||
| let mut fact_plan = plan.ts_fact_plan(); | ||
| let route_refs_configured = options.is_some_and(route_ref_facts_configured); | ||
| let route_backend_configured = options.is_some_and(route_backend_facts_configured); | ||
| let http_configured = options.is_some_and(http_facts_configured); | ||
| let queue_configured = options.is_some_and(queue_facts_configured); | ||
|
|
||
| fact_plan.route_refs &= route_refs_configured; | ||
| fact_plan.backend_routes &= route_backend_configured || http_configured; | ||
| fact_plan.http_calls &= http_configured; | ||
| fact_plan.symbols = plan.symbols || (fact_plan.symbols && queue_configured); | ||
| fact_plan.queue_usage &= queue_configured; | ||
| fact_plan.queue_factory &= queue_configured; | ||
| fact_plan.queue_project &= queue_configured; | ||
| fact_plan.server_routes = options.is_some_and(|options| { | ||
| options.project_route_globset.is_some() && (plan.routes || plan.swift) | ||
| }); | ||
| fact_plan | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
crates/no-mistakes/src/codebase/dependencies/graph/edge_lang_domains.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| fn emit_route_edges(facts: &LangFactMap, edges: &mut Vec<Edge>) { | ||
| for file in facts.files.values() { | ||
| for (_, handler) in &file.route_handlers { | ||
| for name in route_handler_names(handler) { | ||
| if let Some(targets) = facts.declarations.get(&name) { | ||
| let scoped: std::collections::BTreeSet<_> = targets | ||
| .iter() | ||
| .filter(|target| { | ||
| file.package.is_none() | ||
| || facts | ||
| .files | ||
| .get(*target) | ||
| .and_then(|other| other.package.as_ref()) | ||
| == file.package.as_ref() | ||
| }) | ||
| .cloned() | ||
| .collect(); | ||
| push_file_edges(edges, &file.path, &scoped, EdgeKind::RouteRef); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn route_handler_names(handler: &str) -> Vec<String> { | ||
| let trimmed = handler.replace(['\'', '"', ' '], ""); | ||
| if let Some((controller, _)) = trimmed.split_once('#') { | ||
| let mut name = controller.replace('/', "_"); | ||
|
jonathanong marked this conversation as resolved.
Outdated
|
||
| if !name.ends_with("Controller") { | ||
| name.push_str("Controller"); | ||
| } | ||
| return vec![snake_to_pascal(&name), name]; | ||
| } | ||
| if let Some((class, _)) = trimmed.split_once("::") { | ||
| return vec![class.rsplit('\\').next().unwrap_or(class).to_string()]; | ||
|
jonathanong marked this conversation as resolved.
Outdated
|
||
| } | ||
| vec![trimmed.rsplit('.').next().unwrap_or(&trimmed).to_string()] | ||
|
jonathanong marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| fn snake_to_pascal(name: &str) -> String { | ||
| name.split('_') | ||
| .filter(|part| !part.is_empty()) | ||
| .map(|part| { | ||
| let mut chars = part.chars(); | ||
| match chars.next() { | ||
| Some(first) => first.to_ascii_uppercase().to_string() + chars.as_str(), | ||
| None => String::new(), | ||
| } | ||
| }) | ||
| .collect() | ||
| } | ||
|
|
||
| fn emit_kafka_edges( | ||
| root: &Path, | ||
| all_files: &[PathBuf], | ||
| options: &GraphConfigOptions, | ||
| edges: &mut Vec<Edge>, | ||
| ) { | ||
| let cluster = options.queue_cluster.as_deref(); | ||
| let mut produces = Vec::new(); | ||
| let mut consumes = Vec::new(); | ||
| for path in all_files { | ||
| let Some((prod, cons)) = scan_kafka_file(path) else { | ||
| continue; | ||
|
jonathanong marked this conversation as resolved.
Outdated
|
||
| }; | ||
| let rel = path.strip_prefix(root).unwrap_or(path); | ||
| let rel_s = rel.to_string_lossy(); | ||
| if matches_any(&rel_s, &options.queue_enqueues) { | ||
| produces.push((path.clone(), prod)); | ||
| } | ||
| if matches_any(&rel_s, &options.queue_workers) { | ||
| consumes.push((path.clone(), cons)); | ||
| } | ||
| } | ||
| let mut workers: std::collections::HashMap<String, std::collections::BTreeSet<PathBuf>> = | ||
| std::collections::HashMap::new(); | ||
| for (path, topics) in &consumes { | ||
| for topic in topics { | ||
| workers | ||
| .entry(topic_identity(cluster, topic)) | ||
| .or_default() | ||
| .insert(path.clone()); | ||
| } | ||
| } | ||
| for (path, topics) in produces { | ||
| for topic in topics { | ||
| let identity = topic_identity(cluster, &topic); | ||
| let node = NodeId::QueueJob { | ||
| queue_file: path.clone(), | ||
| job: identity.clone(), | ||
| }; | ||
| edges.push(( | ||
| NodeId::File(path.clone()), | ||
| node.clone(), | ||
| EdgeKind::QueueEnqueue, | ||
| )); | ||
| if let Some(targets) = workers.get(&identity) { | ||
| for worker in targets { | ||
| edges.push(( | ||
| node.clone(), | ||
| NodeId::File(worker.clone()), | ||
| EdgeKind::QueueWorker, | ||
| )); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn matches_any(rel: &str, globs: &[String]) -> bool { | ||
| globs.iter().any(|glob| { | ||
| globset::Glob::new(glob) | ||
| .ok() | ||
| .is_some_and(|g| g.compile_matcher().is_match(rel)) | ||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.