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 22fa71a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Run test suite
on: [push, pull_request]
on: push

jobs:
test:
Expand Down
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
17 changes: 15 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,14 @@ 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 +29,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 +50,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 +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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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);
}

0 comments on commit 22fa71a

Please sign in to comment.