tiny.smg.analysis
Defined in tiny.smg.
API (8)
Actions
Public operations.
Types and contracts
Public types and contracts.
Namespaces
Public namespaces.
Source
Source: tools/smg/src/analysis/report.zig:15
zig
pub const DeltaFilter = struct { git_ref: []const u8, names: []const []const u8,};Source: tools/smg/src/analysis/overview.zig:12
zig
pub fn overview(allocator: std.mem.Allocator, graph: graph_mod.Graph, top: i64, json: bool) ![]const u8 { const connected = try connectedRows(allocator, graph); const modules = try moduleRows(allocator, graph); const connected_display = paging.sliceEnd(connected.len, top); const module_display = paging.sliceEnd(modules.len, top); if (json) { var out: std.Io.Writer.Allocating = .init(allocator); errdefer out.deinit(); var writer = pretty_json.Writer.init(&out.writer, .minified); try writer.beginObject(); try writer.objectField("nodes"); try writer.write(graph.nodes.items.len); try writer.objectField("edges"); try writer.write(graph.edges.items.len); try writer.objectField("top_connected_basis"); try writer.write("architecture_coupling"); try writer.objectField("top_connected"); try writer.beginArray(); for (connected[0..connected_display]) |entry| { try writer.beginObject(); try writer.objectField("name"); try writer.write(entry.name); try writer.objectField("type"); try writer.write(entry.type); try writer.objectField("incoming"); try writer.write(entry.incoming); try writer.objectField("outgoing"); try writer.write(entry.outgoing); try writer.objectField("total"); try writer.write(entry.total); try writer.endObject(); } try writer.endArray(); try writer.objectField("modules"); try writer.beginArray(); for (modules) |entry| { try writer.beginObject(); try writer.objectField("name"); try writer.write(entry.name); try writer.objectField("type"); try writer.write(entry.type); try writer.objectField("children"); try writer.write(entry.children); try writer.endObject(); } try writer.endArray(); try writer.objectField("modules_basis"); try writer.write("direct_declarations"); try writer.endObject(); try out.writer.writeByte('\n'); return try out.toOwnedSlice(); } var out: std.Io.Writer.Allocating = .init(allocator); errdefer out.deinit(); try out.writer.print("Full graph: {d} nodes, {d} edges\n\n", .{ graph.nodes.items.len, graph.edges.items.len }); try out.writer.print("Architecture Coupling (top {d})\n", .{top}); try writeConnectedTable(allocator, &out.writer, connected[0..connected_display]); if (module_display != 0) { try out.writer.writeByte('\n'); try out.writer.print("Modules by Direct Declarations (top {d})\n", .{top}); try writeModuleTable(allocator, &out.writer, modules[0..module_display], modules.len, top); } return try out.toOwnedSlice();}Source: tools/smg/src/analysis/report.zig:121
zig
pub fn analyze(allocator: std.mem.Allocator, graph: graph_mod.Graph, summary: bool, json: bool, top: i64, full: bool, scope_label: ?[]const u8, concept_analysis: ?concepts_mod.Analysis, root: ?[]const u8, churn_days: i64, include_betweenness: bool, delta_filter: ?DeltaFilter, limits: smg.AnalysisLimits) ![]const u8 { const include_full_metrics = !summary; if (json) return try analyzeJson(allocator, graph, top, !full, include_full_metrics, concept_analysis, root, churn_days, include_betweenness, delta_filter, limits); return try analyzeText(allocator, graph, top, !full, !summary, scope_label, concept_analysis, root, churn_days, include_betweenness, delta_filter, limits);}Source: tools/smg/src/analysis/report.zig:2041
zig
pub fn classMetricValue(allocator: std.mem.Allocator, graph: graph_mod.Graph, class_name: []const u8, metric_name: []const u8) !?f64 { const metrics = try classMetrics(allocator, graph, true); for (metrics) |metric| { if (!std.mem.eql(u8, metric.name, class_name)) continue; if (std.mem.eql(u8, metric_name, "wmc")) return @floatFromInt(metric.wmc); if (std.mem.eql(u8, metric_name, "cbo")) return @floatFromInt(metric.cbo); if (std.mem.eql(u8, metric_name, "rfc")) return @floatFromInt(metric.rfc); if (std.mem.eql(u8, metric_name, "lcom4")) return @floatFromInt(metric.lcom4); if (std.mem.eql(u8, metric_name, "dit")) return @floatFromInt(metric.dit); if (std.mem.eql(u8, metric_name, "noc")) return @floatFromInt(metric.noc); if (std.mem.eql(u8, metric_name, "max_method_cc")) return @floatFromInt(metric.max_method_cc); return null; } return null;}Source: tools/smg/src/analysis/report.zig:2057
zig
pub fn moduleMetricValue(allocator: std.mem.Allocator, graph: graph_mod.Graph, module_name: []const u8, metric_name: []const u8) !?f64 { const metrics = try martinMetrics(allocator, graph); const metric = moduleMetricFor(metrics, module_name) orelse return null; if (std.mem.eql(u8, metric_name, "instability")) return metric.instability; if (std.mem.eql(u8, metric_name, "abstractness")) return metric.abstractness; if (std.mem.eql(u8, metric_name, "distance")) return metric.distance; return null;}Source: tools/smg/src/analysis/report.zig:2086
zig
pub fn totalMetricBool(allocator: std.mem.Allocator, graph: graph_mod.Graph, name: []const u8, metric_name: []const u8) !?bool { if (std.mem.eql(u8, metric_name, "dead")) return containsString(try deadCodeRows(allocator, graph), name); if (std.mem.eql(u8, metric_name, "in_cycle")) { for (try findCycles(allocator, graph)) |cycle| { if (containsString(cycle, name)) return true; } return false; } return null;}Source: tools/smg/src/analysis/report.zig:2066
zig
pub fn totalMetricValue(allocator: std.mem.Allocator, graph: graph_mod.Graph, name: []const u8, metric_name: []const u8, limits: smg.AnalysisLimits) !?f64 { if (std.mem.eql(u8, metric_name, "fan_in") or std.mem.eql(u8, metric_name, "fan_out")) { const rows = try fanRows(allocator, graph); for (rows) |row| { if (!std.mem.eql(u8, row.name, name)) continue; return @floatFromInt(if (std.mem.eql(u8, metric_name, "fan_in")) row.fan_in else row.fan_out); } return 0; } if (std.mem.eql(u8, metric_name, "layer")) return @floatFromInt(layerValue(try topologicalLayers(allocator, graph), name) orelse 0); if (std.mem.eql(u8, metric_name, "pagerank")) return rankedValue(try pagerankRows(allocator, graph), name) orelse 0; if (std.mem.eql(u8, metric_name, "betweenness")) return rankedValue(try betweennessRows(allocator, graph, false, limits), name) orelse 0; if (std.mem.eql(u8, metric_name, "kcore")) { const rows = try kcoreRows(allocator, graph); for (rows) |row| if (std.mem.eql(u8, row.name, name)) return @floatFromInt(row.value); return 0; } return null;}Source: tools/smg/src/analysis/root.zig
zig
const overview_mod = @import("overview.zig");const report = @import("report.zig");pub const paging = @import("paging.zig");pub const DeltaFilter = report.DeltaFilter;pub const analyze = report.analyze;pub const classMetricValue = report.classMetricValue;pub const moduleMetricValue = report.moduleMetricValue;pub const overview = overview_mod.overview;pub const totalMetricBool = report.totalMetricBool;pub const totalMetricValue = report.totalMetricValue;Source: tools/smg/src/root.zig:9
zig
pub const analysis = @import("analysis/root.zig");Complete caller list for analysis.analyze
10 direct callers.
tools.smg.src.analysis.report.test_analyze_json_full_module_graph_matches_python_contract[function] — test; no exact target attools/smg/src/analysis/report.zig:3019in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_json_full_path_graph_matches_python_contract[function] — test; no exact target attools/smg/src/analysis/report.zig:3035in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_json_summary_full_skips_full_metric_computation_like_python[function] — test; no exact target attools/smg/src/analysis/report.zig:3082in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_reports_code_smells_like_python[function] — test; no exact target attools/smg/src/analysis/report.zig:3290in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_reports_stable_dependency_principle_violations_like_python[function] — test; no exact target attools/smg/src/analysis/report.zig:3231in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_since_delta_filters_python_result_surfaces[function] — test; no exact target attools/smg/src/analysis/report.zig:3417in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_text_full_path_graph_matches_python_contract[function] — test; no exact target attools/smg/src/analysis/report.zig:3437in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_text_summary_module_graph_matches_python_contract[function] — test; no exact target attools/smg/src/analysis/report.zig:3368in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_analyze_text_summary_scoped_label_matches_python_contract[function] — test; no exact target attools/smg/src/analysis/report.zig:3394in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.test_module_members_handle_containment_cycles_like_python[function] — test; no exact target attools/smg/src/analysis/report.zig:3213in nearest public ownertools.smg.src.analysis.report
Complete call list for analysis.totalMetricValue
7 direct calls.
tools.smg.src.analysis.report.betweennessRows[function] — private; no exact target attools/smg/src/analysis/report.zig:1605in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.fanRows[function] — private; no exact target attools/smg/src/analysis/report.zig:1171in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.kcoreRows[function] — private; no exact target attools/smg/src/analysis/report.zig:1687in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.layerValue[function] — private; no exact target attools/smg/src/analysis/report.zig:2920in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.pagerankRows[function] — private; no exact target attools/smg/src/analysis/report.zig:1566in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.rankedValue[function] — private; no exact target attools/smg/src/analysis/report.zig:2250in nearest public ownertools.smg.src.analysis.reporttools.smg.src.analysis.report.topologicalLayers[function] — private; no exact target attools/smg/src/analysis/report.zig:1499in nearest public ownertools.smg.src.analysis.report
Audit
| Definitions | 8 |
|---|---|
| Public names | 8 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |