Skip to content

Commit

Permalink
feat: Add a few missing "Affected files" references (#1427)
Browse files Browse the repository at this point in the history
* Add a few missing "Affected files" references that were missed in the first parsing pass of RULES.md.

* Bug fixes.

* Add Best Practices Dataset Publishing section link.

* Java formatting.

---------

Co-authored-by: David Gamez <1192523+davidgamez@users.noreply.github.com>
  • Loading branch information
bdferris-v2 and davidgamez authored May 15, 2023
1 parent dc6a598 commit 1c96c4d
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.mobilitydata.gtfsvalidator.notice;

import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.DATASET_FILES;
import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.FILED_TYPES;
import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.FILE_REQUIREMENTS;
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR;
Expand All @@ -30,7 +31,7 @@
*/
@GtfsValidationNotice(
severity = ERROR,
sections = @SectionRefs({FILE_REQUIREMENTS, FILED_TYPES}),
sections = @SectionRefs({FILE_REQUIREMENTS, FILED_TYPES, DATASET_FILES}),
urls = {
@UrlRef(
label = "Original Python validator implementation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void validate(NoticeContainer noticeContainer) {
*/
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsAgencySchema.class),
urls = {
@UrlRef(
label = "Original Python validator implementation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
*/
package org.mobilitydata.gtfsvalidator.validator;

import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.BEST_PRACTICES_DATASET_PUBLISHING;
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.WARNING;

import java.time.LocalDate;
import javax.inject.Inject;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.UrlRef;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.FileRefs;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRefs;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidator;
import org.mobilitydata.gtfsvalidator.input.CurrentDateTime;
import org.mobilitydata.gtfsvalidator.notice.NoticeContainer;
import org.mobilitydata.gtfsvalidator.notice.SeverityLevel;
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
import org.mobilitydata.gtfsvalidator.table.GtfsFeedInfo;
import org.mobilitydata.gtfsvalidator.table.GtfsFeedInfoSchema;
import org.mobilitydata.gtfsvalidator.type.GtfsDate;

/**
Expand Down Expand Up @@ -82,7 +85,10 @@ public void validate(GtfsFeedInfo entity, NoticeContainer noticeContainer) {
* The dataset expiration date defined in `feed_info.txt` is in seven days or less. At any time,
* the published GTFS dataset should be valid for at least the next 7 days.
*/
@GtfsValidationNotice(severity = WARNING)
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsFeedInfoSchema.class),
sections = @SectionRefs(BEST_PRACTICES_DATASET_PUBLISHING))
static class FeedExpirationDate7DaysNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down Expand Up @@ -116,11 +122,8 @@ static class FeedExpirationDate7DaysNotice extends ValidationNotice {
*/
@GtfsValidationNotice(
severity = WARNING,
urls = {
@UrlRef(
label = "General Publishing & General Practices",
url = "https://gtfs.org/best-practices/#dataset-publishing--general-practices")
})
files = @FileRefs(GtfsFeedInfoSchema.class),
sections = @SectionRefs(BEST_PRACTICES_DATASET_PUBLISHING))
static class FeedExpirationDate30DaysNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public void validate(GtfsFeedInfo feedInfo, NoticeContainer noticeContainer) {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING, bestPractices = @FileRefs(GtfsFeedInfoSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsFeedInfoSchema.class),
bestPractices = @FileRefs(GtfsFeedInfoSchema.class))
static class MissingFeedInfoDateNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ static class StopWithoutStopTimeNotice extends ValidationNotice {
/**
* Describes a location in {@code stops.txt} that is not a stop but has a stop time associated.
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsStopTimeSchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsStopTimeSchema.class, GtfsStopSchema.class}))
static class LocationWithUnexpectedStopTimeNotice extends ValidationNotice {

/** The row number of the faulty record from `stops.txt`. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void validate(GtfsStop location, NoticeContainer noticeContainer) {
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
@GtfsValidationNotice(severity = ERROR)
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsStopSchema.class))
static class StationWithParentStationNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
import org.mobilitydata.gtfsvalidator.table.GtfsStopSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeSchema;

/**
* Validates `location_type` of the referenced `parent_station`.
Expand Down Expand Up @@ -93,7 +94,9 @@ public void validate(NoticeContainer noticeContainer) {
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsStopSchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsStopSchema.class, GtfsStopTimeSchema.class}))
static class WrongParentLocationTypeNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.mobilitydata.gtfsvalidator.table.GtfsPathwaySchema;
import org.mobilitydata.gtfsvalidator.table.GtfsPathwayTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
import org.mobilitydata.gtfsvalidator.table.GtfsStopSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTableContainer;

/**
Expand Down Expand Up @@ -78,7 +79,9 @@ public void validate(NoticeContainer noticeContainer) {
/**
* Describes a dangling generic node, i.e. that has only one incident location in a pathway graph.
*/
@GtfsValidationNotice(severity = WARNING, files = @FileRefs(GtfsPathwaySchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs({GtfsPathwaySchema.class, GtfsStopSchema.class}))
static class PathwayDanglingGenericNodeNotice extends ValidationNotice {

/** Row number of the dangling generic node. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.mobilitydata.gtfsvalidator.table.GtfsPathwaySchema;
import org.mobilitydata.gtfsvalidator.table.GtfsPathwayTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
import org.mobilitydata.gtfsvalidator.table.GtfsStopSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTableContainer;
import org.mobilitydata.gtfsvalidator.util.StopUtil;

Expand Down Expand Up @@ -165,7 +166,9 @@ enum SearchDirection {
* Describes a location that is not reachable at least in one direction: from the entrances or to
* the exits.
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsPathwaySchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsPathwaySchema.class, GtfsStopSchema.class}))
static class PathwayUnreachableLocationNotice extends ValidationNotice {

/** Row number of the unreachable location. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ static class RouteBothShortAndLongNameMissingNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING, bestPractices = @FileRefs(GtfsRouteSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsRouteSchema.class),
bestPractices = @FileRefs(GtfsRouteSchema.class))
static class RouteLongNameContainsShortNameNotice extends ValidationNotice {

/** The id of the faulty record. */
Expand Down Expand Up @@ -151,7 +154,10 @@ static class RouteLongNameContainsShortNameNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING, bestPractices = @FileRefs(GtfsRouteSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsRouteSchema.class),
bestPractices = @FileRefs(GtfsRouteSchema.class))
static class RouteShortNameTooLongNotice extends ValidationNotice {

/** The id of the faulty record. */
Expand All @@ -177,7 +183,7 @@ static class RouteShortNameTooLongNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING)
@GtfsValidationNotice(severity = WARNING, files = @FileRefs(GtfsRouteSchema.class))
static class SameNameAndDescriptionForRouteNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.mobilitydata.gtfsvalidator.table.GtfsShape;
import org.mobilitydata.gtfsvalidator.table.GtfsShapeSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsShapeTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsStopSchema;

/**
* Validates that the shape_dist_traveled along a shape in "shapes.txt" is increasing.
Expand Down Expand Up @@ -142,7 +143,9 @@ static class DecreasingShapeDistanceNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING, files = @FileRefs(GtfsShapeSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs({GtfsShapeSchema.class, GtfsStopSchema.class}))
static class EqualShapeDistanceSameCoordinatesNotice extends ValidationNotice {

/** The id of the faulty shape. */
Expand Down Expand Up @@ -190,7 +193,9 @@ static class EqualShapeDistanceSameCoordinatesNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsShapeSchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsShapeSchema.class, GtfsStopSchema.class}))
static class EqualShapeDistanceDiffCoordinatesNotice extends ValidationNotice {

/** The id of the faulty shape. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ static class StopHasTooManyMatchesForShapeNotice extends ValidationNotice {
*/
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs({GtfsTripSchema.class, GtfsStopTimeSchema.class, GtfsStopSchema.class}))
files =
@FileRefs({
GtfsTripSchema.class,
GtfsStopTimeSchema.class,
GtfsStopSchema.class,
GtfsStopTimeSchema.class
}))
static class StopTooFarFromShapeUsingUserDistanceNotice extends ValidationNotice {

/** The row number of the faulty record from `trips.txt`. */
Expand Down Expand Up @@ -348,7 +354,10 @@ static class StopTooFarFromShapeUsingUserDistanceNotice extends ValidationNotice
*
* <p>This potentially indicates a problem with the location of the stop or the path of the shape.
*/
@GtfsValidationNotice(severity = WARNING, bestPractices = @FileRefs(GtfsShapeSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs({GtfsStopTimeSchema.class, GtfsStopSchema.class, GtfsTripSchema.class}),
bestPractices = @FileRefs(GtfsShapeSchema.class))
static class StopTooFarFromShapeNotice extends ValidationNotice {

/** The row number of the faulty record from `trips.txt`. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
import java.util.Set;
import javax.inject.Inject;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.FileRefs;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.UrlRef;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidator;
import org.mobilitydata.gtfsvalidator.notice.NoticeContainer;
import org.mobilitydata.gtfsvalidator.notice.SeverityLevel;
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
import org.mobilitydata.gtfsvalidator.table.GtfsShape;
import org.mobilitydata.gtfsvalidator.table.GtfsShapeSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsShapeTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsTripSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsTripTableContainer;

/**
Expand Down Expand Up @@ -65,7 +69,14 @@ public void validate(NoticeContainer noticeContainer) {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING)
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs({GtfsShapeSchema.class, GtfsTripSchema.class}),
urls = {
@UrlRef(
label = "Original Python validator implementation",
url = "https://github.com/google/transitfeed")
})
static class UnusedShapeNotice extends ValidationNotice {

/** The faulty record's id. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static class MissingStopNameNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING)
@GtfsValidationNotice(severity = WARNING, files = @FileRefs(GtfsStopSchema.class))
static class SameNameAndDescriptionForStopNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@
import java.util.Optional;
import javax.inject.Inject;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.FileRefs;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.UrlRef;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidator;
import org.mobilitydata.gtfsvalidator.notice.NoticeContainer;
import org.mobilitydata.gtfsvalidator.notice.SeverityLevel;
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
import org.mobilitydata.gtfsvalidator.table.GtfsRoute;
import org.mobilitydata.gtfsvalidator.table.GtfsRouteSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsRouteTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsRouteType;
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
import org.mobilitydata.gtfsvalidator.table.GtfsStopSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTime;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsTrip;
import org.mobilitydata.gtfsvalidator.table.GtfsTripSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsTripTableContainer;
import org.mobilitydata.gtfsvalidator.type.GtfsTime;
import org.mobilitydata.gtfsvalidator.util.S2Earth;
Expand Down Expand Up @@ -334,6 +339,13 @@ private static double getMaxVehicleSpeedKph(GtfsRouteType routeType) {
/** Describes a trip where the transit vehicle moves too fast between two consecutive stops. */
@GtfsValidationNotice(
severity = WARNING,
files =
@FileRefs({
GtfsRouteSchema.class,
GtfsStopSchema.class,
GtfsStopTimeSchema.class,
GtfsTripSchema.class
}),
urls = {
@UrlRef(
label = "Original Python validator implementation",
Expand Down Expand Up @@ -421,6 +433,13 @@ static class FastTravelBetweenConsecutiveStopsNotice extends ValidationNotice {
*/
@GtfsValidationNotice(
severity = WARNING,
files =
@FileRefs({
GtfsRouteSchema.class,
GtfsStopSchema.class,
GtfsStopTimeSchema.class,
GtfsTripSchema.class
}),
urls = {
@UrlRef(
label = "Original Python validator implementation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.mobilitydata.gtfsvalidator.notice.SeverityLevel;
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
import org.mobilitydata.gtfsvalidator.table.GtfsFareRule;
import org.mobilitydata.gtfsvalidator.table.GtfsFareRuleSchema;
import org.mobilitydata.gtfsvalidator.table.GtfsFareRuleTableContainer;
import org.mobilitydata.gtfsvalidator.table.GtfsLocationType;
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
Expand Down Expand Up @@ -98,7 +99,9 @@ private static boolean hasFareZoneStructure(GtfsFareRuleTableContainer fareRuleT
*
* <p>Severity: {@code SeverityLevel.WARNING} - Will be upgraded to {@code SeverityLevel.ERROR}
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsStopSchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsStopSchema.class, GtfsFareRuleSchema.class}))
static class StopWithoutZoneIdNotice extends ValidationNotice {

/** The faulty record's id. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ private boolean isTimepoint(GtfsStopTime stopTime) {
*
* <p>Severity: {@code SeverityLevel.ERROR}
*/
@GtfsValidationNotice(severity = ERROR, files = @FileRefs(GtfsStopTimeSchema.class))
@GtfsValidationNotice(
severity = ERROR,
files = @FileRefs({GtfsStopTimeSchema.class, GtfsStopTimeSchema.class}))
static class StopTimeTimepointWithoutTimesNotice extends ValidationNotice {

/** The row number of the faulty record. */
Expand Down Expand Up @@ -144,7 +146,10 @@ static class MissingTimepointValueNotice extends ValidationNotice {
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
@GtfsValidationNotice(severity = WARNING, bestPractices = @FileRefs(GtfsStopTimeSchema.class))
@GtfsValidationNotice(
severity = WARNING,
files = @FileRefs(GtfsStopTimeSchema.class),
bestPractices = @FileRefs(GtfsStopTimeSchema.class))
static class MissingTimepointColumnNotice extends ValidationNotice {

/** The name of the affected file. */
Expand Down
Loading

0 comments on commit 1c96c4d

Please sign in to comment.