Skip to content

Commit

Permalink
CheckName: update severity level to error
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed Sep 10, 2024
1 parent e3cd571 commit db39fca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Here is a human friendly list of them :
| | | |
| NegativeTravelTime | Warning | The travel duration between two stops is negative. |
| NegativeStopDuration | Warning | The `departure_time` at a stop is earlier than its `arrival_time`. |
| MissingName | Warning | An agency, a route or a stop has its name missing. |
| MissingName | Error | An agency, a route or a stop has its name missing. |
| MissingCoordinates | Warning | A shape point or a stop is missing its coordinate(s). |
| NullDuration | Warning | The travel duration between two stops is null. |
| MissingLanguage | Warning | The publisher language code is missing. |
Expand Down
12 changes: 10 additions & 2 deletions src/validators/check_name.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::issues::{Issue, IssueType, Severity};
use gtfs_structures::LocationType;

pub fn validate(gtfs: &gtfs_structures::Gtfs) -> Vec<Issue> {
let route_issues = gtfs
Expand All @@ -9,6 +10,9 @@ pub fn validate(gtfs: &gtfs_structures::Gtfs) -> Vec<Issue> {
let stop_issues = gtfs
.stops
.values()
.filter(|&stop|
[LocationType::StopPoint, LocationType::StopArea, LocationType::StationEntrance].contains(stop.location_type)
)
.filter(empty_name)
.map(make_missing_name_issue);
let agency_issues = gtfs
Expand All @@ -20,7 +24,7 @@ pub fn validate(gtfs: &gtfs_structures::Gtfs) -> Vec<Issue> {
.feed_info
.iter()
.filter(empty_name)
.map(|_feed_info| Issue::new(Severity::Warning, IssueType::MissingName, ""));
.map(|_feed_info| Issue::new(Severity::Error, IssueType::MissingName, ""));
route_issues
.chain(stop_issues)
.chain(agency_issues)
Expand All @@ -41,7 +45,7 @@ fn empty_route_name(r: &gtfs_structures::Route) -> bool {
fn make_missing_name_issue<T: gtfs_structures::Id + gtfs_structures::Type + std::fmt::Display>(
o: &T,
) -> Issue {
Issue::new_with_obj(Severity::Warning, IssueType::MissingName, o)
Issue::new_with_obj(Severity::Error, IssueType::MissingName, o)
}

#[test]
Expand All @@ -56,6 +60,7 @@ fn test_routes() {
assert_eq!(1, route_name_issues.len());
assert_eq!("35", route_name_issues[0].object_id);
assert_eq!(IssueType::MissingName, route_name_issues[0].issue_type);
assert_eq!(Severity::Error, route_name_issues[0].severity);
}

#[test]
Expand All @@ -70,6 +75,7 @@ fn test_stops() {
assert_eq!(1, stop_name_issues.len());
assert_eq!("close1", stop_name_issues[0].object_id);
assert_eq!(IssueType::MissingName, stop_name_issues[0].issue_type);
assert_eq!(Severity::Error, stop_name_issues[0].severity);
}

#[test]
Expand All @@ -84,6 +90,7 @@ fn test_agencies() {
assert_eq!(1, agency_name_issues.len());
assert_eq!("1", agency_name_issues[0].object_id);
assert_eq!(IssueType::MissingName, agency_name_issues[0].issue_type);
assert_eq!(Severity::Error, agency_name_issues[0].severity);
}

#[test]
Expand All @@ -98,4 +105,5 @@ fn test_feed_info() {
assert_eq!(1, publisher_name_issues.len());
assert_eq!("", publisher_name_issues[0].object_id);
assert_eq!(IssueType::MissingName, publisher_name_issues[0].issue_type);
assert_eq!(Severity::Error, publisher_name_issues[0].severity);
}

0 comments on commit db39fca

Please sign in to comment.