feat: complete rule evidence and frozen review fixtures
This commit is contained in:
1 parent
1f4e120a53
commit
344ef28870
27 files changed
+1992
-356
No files matched your search
+37
-31
@@ -3,10 +3,10 @@ use crate::{
|
||||
config::EffectiveConfig,
|
||||
diagnostics::Diagnostic,
|
||||
input::{MarkdownOrigin, SourceDocument},
|
||||
metrics::{measure_document, FunctionNarrative},
|
||||
metrics::{measure_module_function, FunctionNarrative},
|
||||
rules::{
|
||||
check_aligned, check_ast_document, check_documentation, check_entry_without_analysis,
|
||||
check_semantic_document,
|
||||
check_aligned, check_ast_document, check_entry_without_analysis,
|
||||
check_function_documentation, check_supplemental_function,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -18,41 +18,47 @@ pub struct DocumentAnalysis {
|
||||
}
|
||||
|
||||
pub fn analyze_document(document: &SourceDocument, config: &EffectiveConfig) -> DocumentAnalysis {
|
||||
let markdown = &document.markdown;
|
||||
let mut diagnostics = check_ast_document(document);
|
||||
let mut metrics = Vec::new();
|
||||
let mut alignment_issues = Vec::new();
|
||||
let module = document.module.as_ref()
|
||||
let module = document
|
||||
.module
|
||||
.as_ref()
|
||||
.filter(|_| document.markdown_origin == MarkdownOrigin::MarqdoInspect);
|
||||
let mut diagnostics = if let Some(module) = module {
|
||||
let mut diagnostics = Vec::new();
|
||||
if let Some(module) = module {
|
||||
for function in &module.functions {
|
||||
let tree = align_function(&document.markdown, function);
|
||||
if tree.complete {
|
||||
diagnostics.extend(check_aligned(&document.markdown, function, &tree));
|
||||
} else {
|
||||
alignment_issues.extend(tree.issues.iter().map(|issue| {
|
||||
format!("{}:{}", function.local_name, issue)
|
||||
}));
|
||||
let tree = align_function(markdown, function);
|
||||
if !tree.complete {
|
||||
alignment_issues.extend(
|
||||
tree.issues
|
||||
.iter()
|
||||
.map(|issue| format!("{}:{}", function.local_name, issue)),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
diagnostics.extend(check_aligned(markdown, function, &tree));
|
||||
diagnostics.extend(check_supplemental_function(
|
||||
markdown,
|
||||
function,
|
||||
&module.calls,
|
||||
&tree,
|
||||
));
|
||||
if let Some(narrative) =
|
||||
measure_module_function(markdown, function, &module.calls, config.narrative)
|
||||
{
|
||||
diagnostics.extend(check_function_documentation(
|
||||
markdown,
|
||||
&narrative,
|
||||
config.narrative,
|
||||
));
|
||||
metrics.push(narrative);
|
||||
}
|
||||
}
|
||||
diagnostics.extend(check_documentation(document, config.narrative));
|
||||
diagnostics.extend(check_semantic_document(document));
|
||||
diagnostics
|
||||
} else {
|
||||
let mut diagnostics = check_ast_document(document);
|
||||
diagnostics.extend(check_entry_without_analysis(document));
|
||||
diagnostics
|
||||
};
|
||||
diagnostics.sort_by(|left, right| {
|
||||
(left.span.start, left.span.end, &left.id).cmp(&(
|
||||
right.span.start,
|
||||
right.span.end,
|
||||
&right.id,
|
||||
))
|
||||
});
|
||||
let metrics = if module.is_some() {
|
||||
measure_document(document, config.narrative)
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
}
|
||||
diagnostics.sort_by(|left, right| (left.span, &left.id).cmp(&(right.span, &right.id)));
|
||||
DocumentAnalysis {
|
||||
diagnostics,
|
||||
metrics,
|
||||
|
||||
Reference in new issue
Block a user