feat: warn if no validators on build

This commit is contained in:
rvcas 2022-12-23 21:42:29 -05:00 committed by Lucas
parent 38a716d94e
commit cbaf629645
2 changed files with 14 additions and 2 deletions

View File

@ -393,7 +393,9 @@ impl Diagnostic for Error {
#[derive(thiserror::Error)] #[derive(thiserror::Error)]
pub enum Warning { 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 { Type {
path: PathBuf, path: PathBuf,
src: String, src: String,
@ -411,17 +413,21 @@ impl Diagnostic for Warning {
fn source_code(&self) -> Option<&dyn SourceCode> { fn source_code(&self) -> Option<&dyn SourceCode> {
match self { match self {
Warning::Type { named, .. } => Some(named), Warning::Type { named, .. } => Some(named),
Warning::NoValidators => None,
} }
} }
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>> { fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>> {
match self { match self {
Warning::Type { warning, .. } => warning.labels(), Warning::Type { warning, .. } => warning.labels(),
Warning::NoValidators => None,
} }
} }
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> { fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
match self { match self {
Warning::Type { .. } => Some(Box::new("aiken::check")), Warning::Type { .. } => Some(Box::new("aiken::check")),
Warning::NoValidators => Some(Box::new("aiken::check")),
} }
} }
} }

View File

@ -107,6 +107,8 @@ where
} }
pub fn docs(&mut self, destination: Option<PathBuf>) -> Result<(), Error> { pub fn docs(&mut self, destination: Option<PathBuf>) -> Result<(), Error> {
self.compile_deps()?;
self.event_listener self.event_listener
.handle_event(Event::BuildingDocumentation { .handle_event(Event::BuildingDocumentation {
root: self.root.clone(), root: self.root.clone(),
@ -399,7 +401,7 @@ where
Ok(()) 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 errors = Vec::new();
let mut validators = 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() { if errors.is_empty() {
Ok(validators) Ok(validators)
} else { } else {