From db39fcae6d430996b90abfbfa4f2b098860d9dfa Mon Sep 17 00:00:00 2001 From: Antoine Augusti Date: Tue, 10 Sep 2024 10:37:57 +0200 Subject: [PATCH] CheckName: update severity level to error --- readme.md | 2 +- src/validators/check_name.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 66b83e3..ffae4c9 100644 --- a/readme.md +++ b/readme.md @@ -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. | diff --git a/src/validators/check_name.rs b/src/validators/check_name.rs index 11f9a7f..629433b 100644 --- a/src/validators/check_name.rs +++ b/src/validators/check_name.rs @@ -1,4 +1,5 @@ use crate::issues::{Issue, IssueType, Severity}; +use gtfs_structures::LocationType; pub fn validate(gtfs: >fs_structures::Gtfs) -> Vec { let route_issues = gtfs @@ -9,6 +10,9 @@ pub fn validate(gtfs: >fs_structures::Gtfs) -> Vec { 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 @@ -20,7 +24,7 @@ pub fn validate(gtfs: >fs_structures::Gtfs) -> Vec { .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) @@ -41,7 +45,7 @@ fn empty_route_name(r: >fs_structures::Route) -> bool { fn make_missing_name_issue( o: &T, ) -> Issue { - Issue::new_with_obj(Severity::Warning, IssueType::MissingName, o) + Issue::new_with_obj(Severity::Error, IssueType::MissingName, o) } #[test] @@ -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] @@ -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] @@ -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] @@ -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); }