From 22fa71ae71d9c93d2b62f510d2763ad29dc1f3f9 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 --- .github/workflows/test.yml | 2 +- readme.md | 2 +- src/validators/check_name.rs | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 72d977a..2ba9b8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: Run test suite -on: [push, pull_request] +on: push jobs: test: 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..51ca600 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,14 @@ 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 +29,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 +50,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 +65,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 +80,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 +95,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 +110,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); }