Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add MixedCase validation (#881) #1340

Merged
merged 17 commits into from
Mar 8, 2023
Merged

Conversation

briandonahue
Copy link
Collaborator

@briandonahue briandonahue commented Feb 16, 2023

Summary:

Closes #881

Expected behavior:

Explain and/or show screenshots for how you expect the pull request to work in your testing (in case other devices exhibit different behavior).

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradle test to make sure you didn't break anything
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

@github-actions
Copy link
Contributor

✅ Rule acceptance tests passed.
New Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: 90f3ac6
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@github-actions
Copy link
Contributor

✅ Rule acceptance tests passed.
New Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: 9153611
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@github-actions
Copy link
Contributor

❌ Invalid acceptance test.
New Errors: 1350 out of 1391 datasets (~97%) are invalid due to code change, which is above the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: 6b1c96f
Download the full acceptance test report here (report will disappear after 90 days).
❌ Invalid acceptance test.

@github-actions
Copy link
Contributor

❌ Invalid acceptance test.
New Errors: 1350 out of 1391 datasets (~97%) are invalid due to code change, which is above the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: e71e102
Download the full acceptance test report here (report will disappear after 90 days).
❌ Invalid acceptance test.

@github-actions
Copy link
Contributor

This contribution does not follow the conventions set by the Google Java style guide. Please run the following command line at the root of the project to fix formatting errors: ./gradlew goJF.

@github-actions
Copy link
Contributor

This contribution does not follow the conventions set by the Google Java style guide. Please run the following command line at the root of the project to fix formatting errors: ./gradlew goJF.

@github-actions
Copy link
Contributor

✅ Rule acceptance tests passed.
New Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: f5c7f78
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@@ -34,6 +29,7 @@ public interface GtfsAgencySchema extends GtfsEntity {
String agencyId();

@Required
@MixedCase
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this annotation is intended for more than this field, but it's going to be interesting to see how this actually validates for agency name. For example, if the agency name is "SFMTA" or "MARTA" (aka an acronym) it won't actually be mixed-case.

public interface MixedCaseSchema {
@Required
@MixedCase
String mixedCase();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would actually name this field something different. Like "someField". I think having the field named "mixedCase" causes just a bit of confusion in the unit-test about when "mixedCase" is being used as field name or in some other context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also found it a little confusing that "MixedCase" is both used as the annotation and the entity class names in the tests below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdferris-v2 I modeled the CurrencyAmount example, so it has the same issue. I renamed it to MixedCaseTestSchema, though not sure it's a major improvement in readability. Let me know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, it's true. Maybe it was less noticeable in that test because I inlined all the file and field names in the test, as opposed to referencing CurrencyAmount.FILENAME, etc? Sorry for the conflicting advice.

@github-actions
Copy link
Contributor

✅ Rule acceptance tests passed.
New Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: 6e97f3c
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@briandonahue briandonahue marked this pull request as ready for review February 21, 2023 16:05
@github-actions
Copy link
Contributor

✅ Rule acceptance tests passed.
New Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1391 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1391 sources (~0 %) are corrupted.
Commit: 57789a2
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@isabelle-dr
Copy link
Contributor

We generally name the notices with words that describe the problem (equal_shape_distance_diff_coordinates, invalid_currency, missing_required_file).
I wonder if we could find another name for this one that would follow the same pattern. Maybe non_mixed_case_field?

@briandonahue briandonahue changed the title Fix 881: Add MixedCase validation feat: Add MixedCase validation (#881) Mar 6, 2023
@briandonahue
Copy link
Collaborator Author

I wonder if we could find another name for this one that would follow the same pattern. Maybe non_mixed_case_field?

@isabelle-dr How about mixed_case_required or mixed_case_recommended since it's a warning / best practice?

@isabelle-dr
Copy link
Contributor

I thinkmixed_case_recommended_field would be good :)

@briandonahue
Copy link
Collaborator Author

I thinkmixed_case_recommended_field would be good :)

@isabelle-dr done!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

✅ Rule acceptance tests passed.
New Errors: 0 out of 1419 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1419 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1419 sources (~0 %) are corrupted.
Commit: d65ac75
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

@isabelle-dr
Copy link
Contributor

@briandonahue one last comment before we merge, based on Brian's comment here and after reading the Best Practice.
I think we need to explain why this is recommended in a little mode in detail.

Can we replace the long description of this notice with the following:

This field contains customer-facing text and should use Mixed Case (upper and lower case letters) to ensure good readability when displayed to riders. Avoid the use of abbreviations throughout the feed (e.g. St. for Street) unless a location is called by its abbreviated name (e.g. “JFK Airport”). Abbreviations may be problematic for accessibility by screen reader software and voice user interfaces.

Lastly, can you remove the extra "." character in the short description (in the table)?

After this, we are good to go!

@briandonahue
Copy link
Collaborator Author

@isabelle-dr updated!

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

✅ Rule acceptance tests passed.
New Errors: 0 out of 1419 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
Dropped Errors: 0 out of 1419 datasets (~0%) are invalid due to code change, which is less than the provided threshold of 1%.
0 out of 1419 sources (~0 %) are corrupted.
Commit: efa3726
Download the full acceptance test report here (report will disappear after 90 days).
✅ Rule acceptance tests passed.

Copy link
Contributor

@isabelle-dr isabelle-dr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

RULES.md Outdated Show resolved Hide resolved
| `filename` | Name of the faulty file. | String |
| `fieldName` | Name of the faulty field. | String |

#### Affected files & fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for specifying the fields here

@isabelle-dr
Copy link
Contributor

It looks like we have a problem with test pack doc 🤔

@bdferris-v2
Copy link
Collaborator

@isabelle-dr it was a transient failure. I re-ran the failing test and it's now run cleanly.

@isabelle-dr
Copy link
Contributor

Ok, merging now :)

@isabelle-dr isabelle-dr merged commit 345bb4c into master Mar 8, 2023
@isabelle-dr isabelle-dr deleted the issue/881/mixed-case branch March 8, 2023 22:01
ryon pushed a commit to JarvusInnovations/gtfs-validator that referenced this pull request Apr 1, 2023
* Add MixedCase annotation

* Add to column descriptor

* Add validator generator

* Remove 'Required' for warning notice

* Added test, column name is wrong...

* set as warning

* Add MixedCase annotation to all necessary fields

* convert field name to snake case

* Use field name converter

* readability suggestions

* Rename MixedCase in tests to MixedCaseTest

* Add rule definition

* Rename notice to be clearer

* Change notice name

* Update long description, correct punctuation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Best Practice: stop names should be in mixed case (WARNING)
3 participants