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)]
|
#[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")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue