@lamentis/naome 1.3.14 → 1.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +2 -2
- package/crates/naome-cli/Cargo.toml +1 -1
- package/crates/naome-cli/src/quality_commands.rs +4 -4
- package/crates/naome-core/Cargo.toml +1 -1
- package/crates/naome-core/src/architecture/config/parser/sections.rs +1 -1
- package/crates/naome-core/src/architecture/config.rs +1 -1
- package/crates/naome-core/src/architecture/model.rs +19 -0
- package/crates/naome-core/src/architecture/output.rs +1 -20
- package/crates/naome-core/src/architecture/rules/budgets.rs +2 -1
- package/crates/naome-core/src/architecture/rules.rs +1 -1
- package/crates/naome-core/src/architecture.rs +3 -3
- package/crates/naome-core/src/intent/legacy.rs +1 -1
- package/crates/naome-core/src/intent/model.rs +27 -0
- package/crates/naome-core/src/intent/resolver.rs +3 -28
- package/crates/naome-core/src/intent/resolver_baseline.rs +1 -2
- package/crates/naome-core/src/intent/resolver_policy.rs +1 -2
- package/crates/naome-core/src/intent.rs +2 -1
- package/crates/naome-core/src/quality/adapter_ios.rs +3 -1
- package/crates/naome-core/src/quality/adapter_support.rs +32 -0
- package/crates/naome-core/src/quality/adapters.rs +8 -25
- package/crates/naome-core/src/quality/analysis_model.rs +33 -0
- package/crates/naome-core/src/quality/cache.rs +1 -1
- package/crates/naome-core/src/quality/checks/duplicate_blocks.rs +2 -1
- package/crates/naome-core/src/quality/checks/near_duplicates.rs +2 -1
- package/crates/naome-core/src/quality/mod.rs +1 -0
- package/crates/naome-core/src/quality/scanner/analysis.rs +1 -1
- package/crates/naome-core/src/quality/scanner.rs +1 -32
- package/crates/naome-core/src/quality/semantic/extract.rs +2 -1
- package/crates/naome-core/src/quality/structure/adapter_ios.rs +1 -1
- package/crates/naome-core/src/quality/structure/adapter_model.rs +23 -0
- package/crates/naome-core/src/quality/structure/adapters.rs +2 -23
- package/crates/naome-core/src/quality/structure/config.rs +2 -1
- package/crates/naome-core/src/quality/structure/defaults.rs +2 -2
- package/crates/naome-core/src/quality/structure/mod.rs +1 -0
- package/crates/naome-core/src/quality/structure/model.rs +6 -6
- package/crates/naome-core/src/repository_model.rs +6 -1
- package/crates/naome-core/src/route/builtin_checks.rs +1 -1
- package/crates/naome-core/src/route/builtin_require.rs +1 -1
- package/crates/naome-core/src/route/execution.rs +2 -34
- package/crates/naome-core/src/route/execution_baselines.rs +1 -1
- package/crates/naome-core/src/route/execution_model.rs +37 -0
- package/crates/naome-core/src/route/execution_support.rs +1 -1
- package/crates/naome-core/src/route/execution_tasks.rs +1 -1
- package/crates/naome-core/src/route/quality_gate.rs +0 -1
- package/crates/naome-core/src/route.rs +3 -1
- package/crates/naome-core/src/task_state/api.rs +5 -4
- package/crates/naome-core/src/task_state/commit_gate.rs +1 -1
- package/crates/naome-core/src/task_state/compact_proof.rs +2 -2
- package/crates/naome-core/src/task_state/completed_refresh.rs +0 -13
- package/crates/naome-core/src/task_state/completion.rs +13 -4
- package/crates/naome-core/src/task_state/mod.rs +1 -1
- package/crates/naome-core/src/task_state/progress.rs +1 -1
- package/crates/naome-core/src/task_state/proof.rs +1 -4
- package/crates/naome-core/src/task_state/proof_entry.rs +1 -1
- package/crates/naome-core/src/task_state/proof_model.rs +2 -18
- package/crates/naome-core/src/task_state/proof_sources.rs +2 -2
- package/crates/naome-core/src/task_state/proof_types.rs +17 -0
- package/crates/naome-core/src/task_state/shape.rs +1 -1
- package/crates/naome-core/src/task_state/task_diff_api.rs +1 -1
- package/crates/naome-core/src/verification_contract_policy.rs +2 -6
- package/crates/naome-core/src/workflow/agent/proof.rs +1 -1
- package/crates/naome-core/src/workflow/agent.rs +1 -1
- package/crates/naome-core/src/workflow/mod.rs +3 -1
- package/crates/naome-core/src/workflow/phase_inference.rs +1 -1
- package/crates/naome-core/src/workflow/phase_model.rs +22 -0
- package/crates/naome-core/src/workflow/phases.rs +1 -21
- package/native/darwin-arm64/naome +0 -0
- package/native/linux-x64/naome +0 -0
- package/package.json +1 -1
- package/crates/naome-core/src/task_state/reconcile.rs +0 -7
package/Cargo.lock
CHANGED
|
@@ -76,7 +76,7 @@ checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
|
|
76
76
|
|
|
77
77
|
[[package]]
|
|
78
78
|
name = "naome-cli"
|
|
79
|
-
version = "1.3.
|
|
79
|
+
version = "1.3.15"
|
|
80
80
|
dependencies = [
|
|
81
81
|
"naome-core",
|
|
82
82
|
"serde_json",
|
|
@@ -84,7 +84,7 @@ dependencies = [
|
|
|
84
84
|
|
|
85
85
|
[[package]]
|
|
86
86
|
name = "naome-core"
|
|
87
|
-
version = "1.3.
|
|
87
|
+
version = "1.3.15"
|
|
88
88
|
dependencies = [
|
|
89
89
|
"serde",
|
|
90
90
|
"serde_json",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
use std::path::Path;
|
|
2
2
|
|
|
3
3
|
use naome_core::{
|
|
4
|
-
check_repository_quality, check_repository_quality_paths, check_semantic_legacy,
|
|
5
|
-
clear_quality_cache, explain_repository_structure,
|
|
6
|
-
plan_quality_cleanup, quality_cache_status,
|
|
7
|
-
QualityInitMode, QualityMode,
|
|
4
|
+
check_repository_quality, check_repository_quality_paths, check_semantic_legacy,
|
|
5
|
+
check_semantic_legacy_paths, clear_quality_cache, explain_repository_structure,
|
|
6
|
+
init_repository_quality_with_mode, plan_quality_cleanup, quality_cache_status,
|
|
7
|
+
route_quality_cleanup, semantic_route_for_finding, QualityInitMode, QualityMode,
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
use crate::cli_args::option_value;
|
|
@@ -5,7 +5,7 @@ use super::ConfigParser;
|
|
|
5
5
|
use crate::architecture::config::{
|
|
6
6
|
ContextConfig, ExternalDependencyPolicy, IgnoreRule, LayerConfig, RuleConfig,
|
|
7
7
|
};
|
|
8
|
-
use crate::architecture::
|
|
8
|
+
use crate::architecture::model::Severity;
|
|
9
9
|
|
|
10
10
|
pub(super) fn parse_layers(parser: &mut ConfigParser<'_>) -> Result<(), NaomeError> {
|
|
11
11
|
while let Some((_, line)) = parser.peek_line() {
|
|
@@ -38,6 +38,25 @@ pub struct SourceRange {
|
|
|
38
38
|
pub end_column: usize,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
42
|
+
#[serde(rename_all = "snake_case")]
|
|
43
|
+
pub enum Severity {
|
|
44
|
+
Error,
|
|
45
|
+
Warning,
|
|
46
|
+
Info,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
impl Severity {
|
|
50
|
+
pub fn parse(value: &str) -> Option<Self> {
|
|
51
|
+
match value {
|
|
52
|
+
"error" => Some(Self::Error),
|
|
53
|
+
"warning" | "warn" => Some(Self::Warning),
|
|
54
|
+
"info" => Some(Self::Info),
|
|
55
|
+
_ => None,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
42
61
|
pub struct ArchitectureMetadata {
|
|
43
62
|
pub path: Option<String>,
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
use serde::{Deserialize, Serialize};
|
|
2
2
|
|
|
3
|
-
use super::model::SourceRange;
|
|
3
|
+
use super::model::{Severity, SourceRange};
|
|
4
4
|
use super::scan::ArchitectureScanReport;
|
|
5
5
|
|
|
6
|
-
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
|
7
|
-
#[serde(rename_all = "snake_case")]
|
|
8
|
-
pub enum Severity {
|
|
9
|
-
Error,
|
|
10
|
-
Warning,
|
|
11
|
-
Info,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
6
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
15
7
|
#[serde(rename_all = "camelCase")]
|
|
16
8
|
pub struct ViolationSummary {
|
|
@@ -74,17 +66,6 @@ pub const ARCHITECTURE_RULE_IDS: &[&str] = &[
|
|
|
74
66
|
"arch.external_dependency_policy",
|
|
75
67
|
];
|
|
76
68
|
|
|
77
|
-
impl Severity {
|
|
78
|
-
pub fn parse(value: &str) -> Option<Self> {
|
|
79
|
-
match value {
|
|
80
|
-
"error" => Some(Self::Error),
|
|
81
|
-
"warning" | "warn" => Some(Self::Warning),
|
|
82
|
-
"info" => Some(Self::Info),
|
|
83
|
-
_ => None,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
69
|
pub fn architecture_agent_feedback(
|
|
89
70
|
violations: &[ArchitectureViolation],
|
|
90
71
|
) -> Vec<ArchitectureAgentFeedback> {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
use crate::architecture::
|
|
1
|
+
use crate::architecture::model::Severity;
|
|
2
|
+
use crate::architecture::output::ArchitectureViolation;
|
|
2
3
|
use crate::architecture::scan::{ArchitectureScanReport, FileFact, ImportTarget};
|
|
3
4
|
|
|
4
5
|
pub(super) fn validate_file_size_budget(
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
use crate::paths;
|
|
2
2
|
|
|
3
|
+
use super::model::Severity;
|
|
3
4
|
use super::output::{
|
|
4
5
|
architecture_agent_feedback, summary_for, ArchitectureValidation, ArchitectureViolation,
|
|
5
|
-
Severity,
|
|
6
6
|
};
|
|
7
7
|
use super::scan::ArchitectureScanReport;
|
|
8
8
|
use crate::architecture::model::ArchitectureEdgeKind;
|
|
@@ -13,12 +13,12 @@ pub use config::{
|
|
|
13
13
|
};
|
|
14
14
|
pub use model::{
|
|
15
15
|
ArchitectureEdge, ArchitectureEdgeKind, ArchitectureGraph, ArchitectureMetadata,
|
|
16
|
-
ArchitectureNode, ArchitectureNodeKind, SourceRange,
|
|
16
|
+
ArchitectureNode, ArchitectureNodeKind, Severity, SourceRange,
|
|
17
17
|
};
|
|
18
18
|
pub use output::{
|
|
19
19
|
format_architecture_explain, format_architecture_scan, format_architecture_validation,
|
|
20
|
-
ArchitectureAgentFeedback, ArchitectureValidation, ArchitectureViolation,
|
|
21
|
-
|
|
20
|
+
ArchitectureAgentFeedback, ArchitectureValidation, ArchitectureViolation, ViolationSummary,
|
|
21
|
+
ARCHITECTURE_RULE_IDS,
|
|
22
22
|
};
|
|
23
23
|
pub use scan::{scan_architecture, ArchitectureScanOptions, ArchitectureScanReport};
|
|
24
24
|
|
|
@@ -4,8 +4,8 @@ use crate::models::Decision;
|
|
|
4
4
|
|
|
5
5
|
use super::classifier::{has_candidate, winning_intent};
|
|
6
6
|
use super::legacy_response::response_policy;
|
|
7
|
+
use super::model::ResolvedIntent;
|
|
7
8
|
use super::model::{CanonicalIntent, IntentKind};
|
|
8
|
-
use super::resolver::ResolvedIntent;
|
|
9
9
|
|
|
10
10
|
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
|
11
11
|
#[serde(rename_all = "camelCase")]
|
|
@@ -75,3 +75,30 @@ pub(crate) struct CanonicalIntent {
|
|
|
75
75
|
pub has_workflow_conflict: bool,
|
|
76
76
|
pub validation_errors: Vec<String>,
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
80
|
+
pub(crate) enum CompletedTaskReadiness {
|
|
81
|
+
Valid,
|
|
82
|
+
ValidAfterHarnessRefresh,
|
|
83
|
+
ValidWithUnrelatedDirty,
|
|
84
|
+
Invalid,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
88
|
+
pub(crate) enum DirtyDiffReadiness {
|
|
89
|
+
Unclassified,
|
|
90
|
+
HarnessRefreshOnly,
|
|
91
|
+
HarnessRefreshWithUnrelatedDirty,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
95
|
+
pub(crate) struct ResolvedIntent {
|
|
96
|
+
pub prompt_intent: IntentKind,
|
|
97
|
+
pub certainty: String,
|
|
98
|
+
pub policy_action: String,
|
|
99
|
+
pub allowed: bool,
|
|
100
|
+
pub summary: String,
|
|
101
|
+
pub next_action: String,
|
|
102
|
+
pub reason_codes: Vec<String>,
|
|
103
|
+
pub risk_codes: Vec<String>,
|
|
104
|
+
}
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
use crate::models::Decision;
|
|
2
2
|
|
|
3
3
|
use super::classifier::winning_intent;
|
|
4
|
-
use super::model::{
|
|
4
|
+
use super::model::{
|
|
5
|
+
CanonicalIntent, CompletedTaskReadiness, DirtyDiffReadiness, IntentKind, ResolvedIntent,
|
|
6
|
+
};
|
|
5
7
|
use super::resolver_policy::state_policy;
|
|
6
8
|
use super::resolver_shared::{ambiguous_conflict, ambiguous_empty, unsafe_policy, Policy};
|
|
7
9
|
|
|
8
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
9
|
-
pub(crate) enum CompletedTaskReadiness {
|
|
10
|
-
Valid,
|
|
11
|
-
ValidAfterHarnessRefresh,
|
|
12
|
-
ValidWithUnrelatedDirty,
|
|
13
|
-
Invalid,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
17
|
-
pub(crate) enum DirtyDiffReadiness {
|
|
18
|
-
Unclassified,
|
|
19
|
-
HarnessRefreshOnly,
|
|
20
|
-
HarnessRefreshWithUnrelatedDirty,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
24
|
-
pub(crate) struct ResolvedIntent {
|
|
25
|
-
pub prompt_intent: IntentKind,
|
|
26
|
-
pub certainty: String,
|
|
27
|
-
pub policy_action: String,
|
|
28
|
-
pub allowed: bool,
|
|
29
|
-
pub summary: String,
|
|
30
|
-
pub next_action: String,
|
|
31
|
-
pub reason_codes: Vec<String>,
|
|
32
|
-
pub risk_codes: Vec<String>,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
10
|
pub(crate) fn resolve_intent(
|
|
36
11
|
decision: &Decision,
|
|
37
12
|
canonical: &CanonicalIntent,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
use super::model::IntentKind;
|
|
2
|
-
use super::resolver::DirtyDiffReadiness;
|
|
1
|
+
use super::model::{DirtyDiffReadiness, IntentKind};
|
|
3
2
|
use super::resolver_catalog::{
|
|
4
3
|
POLICY_BASELINE_BLOCK, POLICY_BASELINE_CANCEL, POLICY_BASELINE_COMMIT_UPGRADE,
|
|
5
4
|
POLICY_BASELINE_NEW_REFRESH, POLICY_BASELINE_NEW_UPGRADE, POLICY_BASELINE_NO_COMMIT,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
use crate::models::Decision;
|
|
2
2
|
|
|
3
|
-
use super::model::IntentKind;
|
|
4
|
-
use super::resolver::{CompletedTaskReadiness, DirtyDiffReadiness};
|
|
3
|
+
use super::model::{CompletedTaskReadiness, DirtyDiffReadiness, IntentKind};
|
|
5
4
|
use super::resolver_active::active_policy;
|
|
6
5
|
use super::resolver_baseline::{baseline_policy, dirty_policy};
|
|
7
6
|
use super::resolver_catalog::{
|
|
@@ -24,7 +24,8 @@ use crate::task_state::{
|
|
|
24
24
|
use classifier::canonical_intent;
|
|
25
25
|
pub(crate) use envelope::prompt_envelope_json;
|
|
26
26
|
pub use legacy::{format_intent, IntentDecision, PromptEvidence};
|
|
27
|
-
use
|
|
27
|
+
use model::{CompletedTaskReadiness, DirtyDiffReadiness};
|
|
28
|
+
use resolver::resolve_intent;
|
|
28
29
|
|
|
29
30
|
pub fn evaluate_intent(
|
|
30
31
|
root: &Path,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
use super::
|
|
1
|
+
use super::adapter_support::{
|
|
2
|
+
quality_path_rule as path_rule, quality_test_file_limits as test_file_limits,
|
|
3
|
+
};
|
|
2
4
|
use super::types::{QualityLimitOverrides, QualityPathRule};
|
|
3
5
|
|
|
4
6
|
pub(super) fn swift_path_rules() -> Vec<QualityPathRule> {
|
|
@@ -2,6 +2,8 @@ use std::collections::HashSet;
|
|
|
2
2
|
|
|
3
3
|
use crate::models::NaomeError;
|
|
4
4
|
|
|
5
|
+
use super::types::{QualityLimitOverrides, QualityPathRule};
|
|
6
|
+
|
|
5
7
|
pub(crate) struct RepoSignals<'a> {
|
|
6
8
|
paths: &'a [String],
|
|
7
9
|
}
|
|
@@ -98,6 +100,36 @@ pub(crate) fn extend_unique(target: &mut Vec<String>, values: &[&str]) {
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
|
|
103
|
+
pub(crate) fn quality_test_file_limits(max_top_level_symbols: usize) -> QualityLimitOverrides {
|
|
104
|
+
QualityLimitOverrides {
|
|
105
|
+
max_file_lines: Some(650),
|
|
106
|
+
max_diff_added_lines: Some(220),
|
|
107
|
+
max_function_lines: Some(140),
|
|
108
|
+
max_top_level_symbols: Some(max_top_level_symbols),
|
|
109
|
+
duplicate_block_lines: Some(14),
|
|
110
|
+
near_duplicate_similarity: Some(0.96),
|
|
111
|
+
..QualityLimitOverrides::default()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
pub(crate) fn quality_path_rule(
|
|
116
|
+
id: &str,
|
|
117
|
+
paths: &[&str],
|
|
118
|
+
limits: QualityLimitOverrides,
|
|
119
|
+
disabled_checks: &[&str],
|
|
120
|
+
) -> QualityPathRule {
|
|
121
|
+
QualityPathRule {
|
|
122
|
+
id: id.to_string(),
|
|
123
|
+
paths: string_list(paths),
|
|
124
|
+
limits,
|
|
125
|
+
disabled_checks: string_list(disabled_checks),
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
fn string_list(values: &[&str]) -> Vec<String> {
|
|
130
|
+
values.iter().map(|value| (*value).to_string()).collect()
|
|
131
|
+
}
|
|
132
|
+
|
|
101
133
|
pub(crate) fn detects_rust_project(signals: &RepoSignals<'_>) -> bool {
|
|
102
134
|
signals.has_manifest("Cargo.toml") || signals.has_extension(&[".rs"])
|
|
103
135
|
}
|
|
@@ -5,10 +5,10 @@ use super::adapter_support::{
|
|
|
5
5
|
detected_ids, detects_generated_ios_project, detects_ios_app_structure_project,
|
|
6
6
|
detects_ios_resources_project, detects_javascript_typescript_project, detects_rust_project,
|
|
7
7
|
detects_swift_package_project, detects_swift_project, detects_swiftui_project,
|
|
8
|
-
detects_xcode_project, detects_xctest_project, extend_unique, find_adapter_by_id,
|
|
9
|
-
AdapterDescriptor, RepoSignals,
|
|
8
|
+
detects_xcode_project, detects_xctest_project, extend_unique, find_adapter_by_id,
|
|
9
|
+
quality_path_rule, quality_test_file_limits, validate_ids, AdapterDescriptor, RepoSignals,
|
|
10
10
|
};
|
|
11
|
-
use super::types::{
|
|
11
|
+
use super::types::{QualityPathRule, RepositoryQualityConfig};
|
|
12
12
|
|
|
13
13
|
const CONFIG_PATH: &str = ".naome/repository-quality.json";
|
|
14
14
|
|
|
@@ -163,32 +163,15 @@ fn javascript_typescript_test_paths() -> Vec<String> {
|
|
|
163
163
|
paths
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
max_file_lines: Some(650),
|
|
169
|
-
max_diff_added_lines: Some(220),
|
|
170
|
-
max_function_lines: Some(140),
|
|
171
|
-
max_top_level_symbols: Some(max_top_level_symbols),
|
|
172
|
-
duplicate_block_lines: Some(14),
|
|
173
|
-
near_duplicate_similarity: Some(0.96),
|
|
174
|
-
..QualityLimitOverrides::default()
|
|
175
|
-
}
|
|
166
|
+
fn test_file_limits(max_top_level_symbols: usize) -> super::types::QualityLimitOverrides {
|
|
167
|
+
quality_test_file_limits(max_top_level_symbols)
|
|
176
168
|
}
|
|
177
169
|
|
|
178
|
-
|
|
170
|
+
fn path_rule(
|
|
179
171
|
id: &str,
|
|
180
172
|
paths: &[&str],
|
|
181
|
-
limits: QualityLimitOverrides,
|
|
173
|
+
limits: super::types::QualityLimitOverrides,
|
|
182
174
|
disabled_checks: &[&str],
|
|
183
175
|
) -> QualityPathRule {
|
|
184
|
-
|
|
185
|
-
id: id.to_string(),
|
|
186
|
-
paths: string_list(paths),
|
|
187
|
-
limits,
|
|
188
|
-
disabled_checks: string_list(disabled_checks),
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
fn string_list(values: &[&str]) -> Vec<String> {
|
|
193
|
-
values.iter().map(|value| (*value).to_string()).collect()
|
|
176
|
+
quality_path_rule(id, paths, limits, disabled_checks)
|
|
194
177
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
use std::collections::HashSet;
|
|
2
|
+
|
|
3
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
4
|
+
pub struct FileAnalysis {
|
|
5
|
+
pub path: String,
|
|
6
|
+
pub line_count: usize,
|
|
7
|
+
pub added_lines: usize,
|
|
8
|
+
pub raw_lines: Vec<String>,
|
|
9
|
+
pub normalized_lines: Vec<NormalizedLine>,
|
|
10
|
+
pub symbols: Vec<SymbolAnalysis>,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
14
|
+
pub struct NormalizedLine {
|
|
15
|
+
pub line_number: usize,
|
|
16
|
+
pub value: String,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
20
|
+
pub struct SymbolAnalysis {
|
|
21
|
+
pub kind: String,
|
|
22
|
+
pub name: String,
|
|
23
|
+
pub start_line: usize,
|
|
24
|
+
pub end_line: usize,
|
|
25
|
+
pub indent: usize,
|
|
26
|
+
pub tokens: HashSet<String>,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
impl SymbolAnalysis {
|
|
30
|
+
pub fn line_count(&self) -> usize {
|
|
31
|
+
self.end_line.saturating_sub(self.start_line) + 1
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -2,7 +2,8 @@ use std::collections::{HashMap, HashSet};
|
|
|
2
2
|
|
|
3
3
|
use sha2::{Digest, Sha256};
|
|
4
4
|
|
|
5
|
-
use super::super::
|
|
5
|
+
use super::super::analysis_model::NormalizedLine;
|
|
6
|
+
use super::super::scanner::{stable_fingerprint, QualityContext};
|
|
6
7
|
use super::super::types::QualityViolation;
|
|
7
8
|
use super::{is_code_like_path, QualityCheck};
|
|
8
9
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use std::collections::HashSet;
|
|
2
2
|
|
|
3
|
-
use super::super::
|
|
3
|
+
use super::super::analysis_model::{FileAnalysis, SymbolAnalysis};
|
|
4
|
+
use super::super::scanner::QualityContext;
|
|
4
5
|
use super::super::types::QualityViolation;
|
|
5
6
|
use super::{is_code_like_path, violation, QualityCheck};
|
|
6
7
|
|
|
@@ -4,7 +4,7 @@ use std::collections::{HashMap, HashSet};
|
|
|
4
4
|
use std::fs;
|
|
5
5
|
use std::path::Path;
|
|
6
6
|
|
|
7
|
-
use
|
|
7
|
+
use crate::quality::analysis_model::{FileAnalysis, NormalizedLine, SymbolAnalysis};
|
|
8
8
|
use crate::quality::cache::{content_hash, QualityCache};
|
|
9
9
|
use normalize::{normalize_line, token_set};
|
|
10
10
|
|
|
@@ -11,6 +11,7 @@ use crate::{git, models::NaomeError, paths};
|
|
|
11
11
|
pub(crate) use repo_paths::collect_repo_paths;
|
|
12
12
|
use repo_paths::{added_lines_by_path, regular_repo_file_path, tracked_blob_hashes};
|
|
13
13
|
|
|
14
|
+
use super::analysis_model::FileAnalysis;
|
|
14
15
|
use super::cache::QualityCache;
|
|
15
16
|
use super::types::{
|
|
16
17
|
default_generated_paths, default_ignored_paths, QualityLimits, QualityMode,
|
|
@@ -55,38 +56,6 @@ impl QualityContext {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
59
|
-
pub struct FileAnalysis {
|
|
60
|
-
pub path: String,
|
|
61
|
-
pub line_count: usize,
|
|
62
|
-
pub added_lines: usize,
|
|
63
|
-
pub raw_lines: Vec<String>,
|
|
64
|
-
pub normalized_lines: Vec<NormalizedLine>,
|
|
65
|
-
pub symbols: Vec<SymbolAnalysis>,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
69
|
-
pub struct NormalizedLine {
|
|
70
|
-
pub line_number: usize,
|
|
71
|
-
pub value: String,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
|
75
|
-
pub struct SymbolAnalysis {
|
|
76
|
-
pub kind: String,
|
|
77
|
-
pub name: String,
|
|
78
|
-
pub start_line: usize,
|
|
79
|
-
pub end_line: usize,
|
|
80
|
-
pub indent: usize,
|
|
81
|
-
pub tokens: HashSet<String>,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
impl SymbolAnalysis {
|
|
85
|
-
pub fn line_count(&self) -> usize {
|
|
86
|
-
self.end_line.saturating_sub(self.start_line) + 1
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
59
|
pub fn scan_repository(
|
|
91
60
|
root: &Path,
|
|
92
61
|
mode: QualityMode,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
use std::collections::BTreeSet;
|
|
2
2
|
|
|
3
3
|
use super::model::ObjectCandidate;
|
|
4
|
-
use crate::quality::
|
|
4
|
+
use crate::quality::analysis_model::{FileAnalysis, SymbolAnalysis};
|
|
5
|
+
use crate::quality::scanner::stable_fingerprint;
|
|
5
6
|
|
|
6
7
|
pub(super) fn extract_object_candidates(file: &FileAnalysis) -> Vec<ObjectCandidate> {
|
|
7
8
|
let mut candidates = Vec::new();
|
|
@@ -4,7 +4,7 @@ use crate::quality::adapter_support::{
|
|
|
4
4
|
detects_swiftui_project, detects_xcode_project, detects_xctest_project,
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
use super::
|
|
7
|
+
use super::adapter_model::StructureAdapter;
|
|
8
8
|
|
|
9
9
|
pub(super) fn adapters() -> Vec<StructureAdapter> {
|
|
10
10
|
let mut adapters = Vec::new();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
use crate::quality::adapter_support::{AdapterDescriptor, RepoSignals};
|
|
2
|
+
|
|
3
|
+
#[derive(Clone, Copy)]
|
|
4
|
+
pub(super) struct StructureAdapter {
|
|
5
|
+
pub(super) id: &'static str,
|
|
6
|
+
pub(super) detect: fn(&RepoSignals<'_>) -> bool,
|
|
7
|
+
pub(super) source_roots: &'static [&'static str],
|
|
8
|
+
pub(super) test_roots: &'static [&'static str],
|
|
9
|
+
pub(super) generated_roots: &'static [&'static str],
|
|
10
|
+
pub(super) artifact_roots: &'static [&'static str],
|
|
11
|
+
pub(super) module_roots: &'static [&'static str],
|
|
12
|
+
pub(super) allowed_root_files: &'static [&'static str],
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
impl AdapterDescriptor for StructureAdapter {
|
|
16
|
+
fn id(&self) -> &'static str {
|
|
17
|
+
self.id
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fn detects(&self, signals: &RepoSignals<'_>) -> bool {
|
|
21
|
+
(self.detect)(signals)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -2,36 +2,15 @@ use crate::models::NaomeError;
|
|
|
2
2
|
|
|
3
3
|
use crate::quality::adapter_support::{
|
|
4
4
|
detected_ids, detects_javascript_typescript_project, detects_rust_project, extend_unique,
|
|
5
|
-
find_adapter_by_id, validate_ids,
|
|
5
|
+
find_adapter_by_id, validate_ids,
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
use super::adapter_ios;
|
|
9
|
+
use super::adapter_model::StructureAdapter;
|
|
9
10
|
use super::model::RepositoryStructureConfig;
|
|
10
11
|
|
|
11
12
|
const CONFIG_PATH: &str = ".naome/repository-structure.json";
|
|
12
13
|
|
|
13
|
-
#[derive(Clone, Copy)]
|
|
14
|
-
pub(super) struct StructureAdapter {
|
|
15
|
-
pub(super) id: &'static str,
|
|
16
|
-
pub(super) detect: fn(&RepoSignals<'_>) -> bool,
|
|
17
|
-
pub(super) source_roots: &'static [&'static str],
|
|
18
|
-
pub(super) test_roots: &'static [&'static str],
|
|
19
|
-
pub(super) generated_roots: &'static [&'static str],
|
|
20
|
-
pub(super) artifact_roots: &'static [&'static str],
|
|
21
|
-
pub(super) module_roots: &'static [&'static str],
|
|
22
|
-
pub(super) allowed_root_files: &'static [&'static str],
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
impl AdapterDescriptor for StructureAdapter {
|
|
26
|
-
fn id(&self) -> &'static str {
|
|
27
|
-
self.id
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
fn detects(&self, signals: &RepoSignals<'_>) -> bool {
|
|
31
|
-
(self.detect)(signals)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
14
|
pub fn detected_structure_adapter_ids(paths: &[String]) -> Vec<String> {
|
|
36
15
|
let registry = registry();
|
|
37
16
|
detected_ids(paths, ®istry)
|
|
@@ -8,6 +8,7 @@ use super::adapters::{
|
|
|
8
8
|
};
|
|
9
9
|
use crate::quality::config_support::validate_ready_schema;
|
|
10
10
|
|
|
11
|
+
use super::defaults::default_structure_config;
|
|
11
12
|
use super::model::RepositoryStructureConfig;
|
|
12
13
|
|
|
13
14
|
const CONFIG_RELATIVE_PATH: &str = ".naome/repository-structure.json";
|
|
@@ -68,7 +69,7 @@ pub fn write_default_structure_config_if_missing(
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
fn generated_structure_config(paths: &[String]) -> RepositoryStructureConfig {
|
|
71
|
-
let mut config =
|
|
72
|
+
let mut config = default_structure_config();
|
|
72
73
|
config.enabled_adapters = detected_structure_adapter_ids(paths);
|
|
73
74
|
config
|
|
74
75
|
}
|
|
@@ -24,11 +24,11 @@ pub fn default_structure_config() -> RepositoryStructureConfig {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
pub fn default_changed_policy() -> String {
|
|
27
|
-
|
|
27
|
+
super::model::default_changed_policy()
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
pub fn default_debt_policy() -> String {
|
|
31
|
-
|
|
31
|
+
super::model::default_debt_policy()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const DEFAULT_SOURCE_ROOTS: &[&str] = &[
|