Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Each Notice is associated with a severity: `INFO`, `WARNING`, `ERROR`.
| [`inconsistent_agency_lang`](#inconsistent_agency_lang) | Inconsistent language among agencies. |
| [`leading_or_trailing_whitespaces`](#leading_or_trailing_whitespaces) | The value in CSV file has leading or trailing whitespaces. |
| [`missing_feed_info_date`](#missing_feed_info_date) | `feed_end_date` should be provided if `feed_start_date` is provided. `feed_start_date` should be provided if `feed_end_date` is provided. |
| [`missing_recommended_file`](#missing_recommended_file) | A recommended file is missing. |
| [`missing_timepoint_column`](#missing_timepoint_column) | `timepoint` column is missing for a dataset. |
| [`missing_timepoint_value`](#missing_timepoint_value) | `stop_times.timepoint` value is missing for a record. |
| [`more_than_one_entity`](#more_than_one_entity) | More than one row in CSV. |
Expand Down Expand Up @@ -1696,6 +1697,24 @@ Even though `feed_info.start_date` and `feed_info.end_date` are optional, if one

<a name="MissingTimepointColumnNotice"/>

### missing_recommended_file

A recommended file is missing.

#### References
* [feed_info.txt bets practices](https://github.com/MobilityData/GTFS_Schedule_Best-Practices/blob/master/en/best-practices.md#feed_infotxt)
<details>

#### Notice fields description
| Field name | Description | Type |
|-------------- |-------------------------------- |-------- |
| `filename` | The name of the faulty file. | String |

#### Affected files
* [`feed_info.txt`](http://gtfs.org/reference/static#feed_infotxt)

</details>

### missing_timepoint_column

The `timepoint` column should be provided.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2020 Google LLC, Jarvus Innovations LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.mobilitydata.gtfsvalidator.notice;

/**
* A recommended file is missing.
*
* <p>Severity: {@code SeverityLevel.WARNING}
*/
public class MissingRecommendedFileNotice extends ValidationNotice {
private final String filename;

public MissingRecommendedFileNotice(String filename) {
super(SeverityLevel.WARNING);
this.filename = filename;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public void exportNotices() {
+ "\"message\":\"Index 0 out of bounds\"}]}]}");
}

@Test
public void exportRecommendedFileNotices() {
NoticeContainer container = new NoticeContainer();
container.addValidationNotice(new MissingRecommendedFileNotice("feed_info.txt"));

assertThat(new Gson().toJson(container.exportValidationNotices()))
.isEqualTo(
"{\"notices\":[{\"code\":\"missing_recommended_file\",\"severity\":\"WARNING\","
+ "\"totalNotices\":1,\"sampleNotices\":[{\"filename\":\"feed_info.txt"
+ "\"}]}]}");
}

@Test
public void exportInfinityInContext() {
NoticeContainer container = new NoticeContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import org.mobilitydata.gtfsvalidator.annotation.FieldType;
import org.mobilitydata.gtfsvalidator.annotation.FieldTypeEnum;
import org.mobilitydata.gtfsvalidator.annotation.GtfsTable;
import org.mobilitydata.gtfsvalidator.annotation.Recommended;
import org.mobilitydata.gtfsvalidator.annotation.Required;
import org.mobilitydata.gtfsvalidator.type.GtfsDate;

@GtfsTable(value = "feed_info.txt", singleRow = true)
@Recommended
public interface GtfsFeedInfoSchema extends GtfsEntity {
@Required
String feedPublisherName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.mobilitydata.gtfsvalidator.annotation.GtfsLoader;
import org.mobilitydata.gtfsvalidator.notice.CsvParsingFailedNotice;
import org.mobilitydata.gtfsvalidator.notice.EmptyFileNotice;
import org.mobilitydata.gtfsvalidator.notice.MissingRecommendedFileNotice;
import org.mobilitydata.gtfsvalidator.notice.MissingRequiredFileNotice;
import org.mobilitydata.gtfsvalidator.notice.NoticeContainer;
import org.mobilitydata.gtfsvalidator.parsing.CsvFile;
Expand Down Expand Up @@ -450,6 +451,11 @@ private MethodSpec generateLoadMissingFileMethod() {
classNames.tableContainerTypeName(),
classNames.tableContainerTypeName(),
TableStatus.class)
.beginControlFlow("if (isRecommended())")
.addStatement(
"noticeContainer.addValidationNotice(new $T(gtfsFilename()))",
MissingRecommendedFileNotice.class)
.endControlFlow()
.beginControlFlow("if (isRequired())")
.addStatement(
"noticeContainer.addValidationNotice(new $T(gtfsFilename()))",
Expand Down