feat: warn if no validators on build
This commit is contained in:
parent
38a716d94e
commit
cbaf629645
|
@ -393,7 +393,9 @@ impl Diagnostic for Error {
|
|||
|
||||
#[derive(thiserror::Error)]
|
||||
pub enum Warning {
|
||||
#[error("Checking")]
|
||||
#[error("You do not have any validators to build!")]
|
||||
NoValidators,
|
||||
#[error("While trying to make sense of your code...")]
|
||||
Type {
|
||||
path: PathBuf,
|
||||
src: String,
|
||||
|
@ -411,17 +413,21 @@ impl Diagnostic for Warning {
|
|||
fn source_code(&self) -> Option<&dyn SourceCode> {
|
||||
match self {
|
||||
Warning::Type { named, .. } => Some(named),
|
||||
Warning::NoValidators => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>> {
|
||||
match self {
|
||||
Warning::Type { warning, .. } => warning.labels(),
|
||||
Warning::NoValidators => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||
match self {
|
||||
Warning::Type { .. } => Some(Box::new("aiken::check")),
|
||||
Warning::NoValidators => Some(Box::new("aiken::check")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,8 @@ where
|
|||
}
|
||||
|
||||
pub fn docs(&mut self, destination: Option<PathBuf>) -> Result<(), Error> {
|
||||
self.compile_deps()?;
|
||||
|
||||
self.event_listener
|
||||
.handle_event(Event::BuildingDocumentation {
|
||||
root: self.root.clone(),
|
||||
|
@ -399,7 +401,7 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_validators(&self) -> Result<Vec<(PathBuf, String, TypedFunction)>, Error> {
|
||||
fn validate_validators(&mut self) -> Result<Vec<(PathBuf, String, TypedFunction)>, Error> {
|
||||
let mut errors = Vec::new();
|
||||
let mut validators = Vec::new();
|
||||
|
||||
|
@ -462,6 +464,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if validators.is_empty() {
|
||||
self.warnings.push(Warning::NoValidators);
|
||||
}
|
||||
|
||||
if errors.is_empty() {
|
||||
Ok(validators)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue