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

"Predicate function names should not start with 'is', and should end in a question mark." #3822

Closed
thbar opened this issue Mar 19, 2024 · 3 comments
Assignees
Labels
dette technique Entretien & maintenance générale, nécessaire pour que le code reste de bonne qualité

Comments

@thbar
Copy link
Contributor

thbar commented Mar 19, 2024

Co-découvert par @vdegove (dans #3815) et moi (dans #2074).

Credo dans ses dernières versions apporte des changements sur le check Credo.Check.Readability.PredicateFunctionNames, ce qui fait que quand on met à jour Credo (à 1.7.5 depuis 1.7.1) on obtient 82 nouvelles issues à traiter.

Ce souci est décrit très bien ici : https://hexdocs.pm/credo/Credo.Check.Readability.PredicateFunctionNames.html#module-explanation.

Le warning est tout à fait "legit" car en Elixir, la convention est établie sur le fait que is est réservé aux clauses de "guard" et pas pour les méthodes "usuelles" (voir https://hexdocs.pm/elixir/1.16.2/naming-conventions.html#is_-prefix-is_foo).

  Code Readability                                                                                                                                                                   
┃ 
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/datagouvfr/lib/datagouvfr/client/datasets.ex:171:8 #(Datagouvfr.Client.Datasets.is_user_in_followers?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/validators/gtfs_transport_validator.ex:260:7 #(Transport.Validators.GTFSTransport.is_gtfs_outdated)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/validators/gtfs_transport_validator.ex:248:7 #(Transport.Validators.GTFSTransport.is_gtfs_outdated)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/validators/gtfs_transport_validator.ex:165:7 #(Transport.Validators.GTFSTransport.is_mine?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/validators/gtfs_transport_validator.ex:164:7 #(Transport.Validators.GTFSTransport.is_mine?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/views/dataset_view.ex:347:7 #(TransportWeb.DatasetView.is_real_time_public_transit?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/views/dataset_view.ex:343:7 #(TransportWeb.DatasetView.is_real_time_public_transit?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/session.ex:52:7 #(TransportWeb.Session.is_producer?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/session.ex:48:7 #(TransportWeb.Session.is_producer?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/session.ex:44:7 #(TransportWeb.Session.is_admin?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/session.ex:40:7 #(TransportWeb.Session.is_admin?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/session.ex:36:7 #(TransportWeb.Session.is_admin?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/live/on_demand_validation_live.ex:53:8 #(TransportWeb.Live.OnDemandValidationLive.is_final_state?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport_web/controllers/validation_controller.ex:194:7 #(TransportWeb.ValidationController.is_valid_type?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:821:8 #(Transport.ImportData.is_gbfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:819:8 #(Transport.ImportData.is_geojson?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:818:8 #(Transport.ImportData.is_geojson?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:712:7 #(Transport.ImportData.is_netex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:701:7 #(Transport.ImportData.is_netex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:677:7 #(Transport.ImportData.is_zip?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:676:7 #(Transport.ImportData.is_zip?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:675:7 #(Transport.ImportData.is_zip?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:674:7 #(Transport.ImportData.is_zip?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:641:7 #(Transport.ImportData.is_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:639:7 #(Transport.ImportData.is_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:638:7 #(Transport.ImportData.is_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:637:7 #(Transport.ImportData.is_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:636:7 #(Transport.ImportData.is_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:616:7 #(Transport.ImportData.is_siri_lite?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:603:7 #(Transport.ImportData.is_siri?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:591:7 #(Transport.ImportData.is_siri?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:570:7 #(Transport.ImportData.is_documentation_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:568:7 #(Transport.ImportData.is_documentation_format?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:556:7 #(Transport.ImportData.is_documentation?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:555:7 #(Transport.ImportData.is_documentation?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:538:7 #(Transport.ImportData.is_gtfs_rt?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:526:7 #(Transport.ImportData.is_gtfs_rt?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:501:7 #(Transport.ImportData.is_gtfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:457:7 #(Transport.ImportData.is_ods_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/import_data.ex:451:7 #(Transport.ImportData.is_ods_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/gtfs_rt.ex:158:7 #(Transport.GTFSRT.is_current?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/gtfs_rt.ex:148:7 #(Transport.GTFSRT.is_current?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/gtfs_rt.ex:131:7 #(Transport.GTFSRT.is_active?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/transport/gtfs_rt.ex:129:7 #(Transport.GTFSRT.is_active?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/resource_history_job.ex:234:8 #(Transport.Jobs.ResourceHistoryJob.is_zip?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/resource_history_job.ex:208:7 #(Transport.Jobs.ResourceHistoryJob.is_same_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/resource_history_job.ex:204:7 #(Transport.Jobs.ResourceHistoryJob.is_same_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/resource_history_job.ex:200:7 #(Transport.Jobs.ResourceHistoryJob.is_same_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/dedupe_history_job.ex:62:7 #(Transport.Jobs.DedupeHistoryJob.is_same?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/dedupe_history_job.ex:58:7 #(Transport.Jobs.DedupeHistoryJob.is_same?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/conversions/gtfs_generic_converter.ex:65:8 #(Transport.Jobs.GTFSGenericConverter.is_resource_gtfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/conversions/gtfs_generic_converter.ex:63:8 #(Transport.Jobs.GTFSGenericConverter.is_resource_gtfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/jobs/consolidate_lez_job.ex:111:7 #(Transport.Jobs.ConsolidateLEZsJob.is_voie?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource_history.ex:84:7 #(DB.ResourceHistory.is_gtfs_flex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource_history.ex:79:7 #(DB.ResourceHistory.is_gtfs_flex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:319:8 #(DB.Resource.is_link_to_folder?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:156:7 #(DB.Resource.is_real_time?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:153:7 #(DB.Resource.is_community_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:152:7 #(DB.Resource.is_community_resource?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:149:7 #(DB.Resource.is_documentation?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:148:7 #(DB.Resource.is_documentation?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:145:7 #(DB.Resource.is_siri_lite?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:144:7 #(DB.Resource.is_siri_lite?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:141:7 #(DB.Resource.is_siri?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:140:7 #(DB.Resource.is_siri?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:137:7 #(DB.Resource.is_gtfs_rt?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:136:7 #(DB.Resource.is_gtfs_rt?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:135:7 #(DB.Resource.is_gtfs_rt?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:132:7 #(DB.Resource.is_netex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:131:7 #(DB.Resource.is_netex?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:128:7 #(DB.Resource.is_gbfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:127:7 #(DB.Resource.is_gbfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:124:7 #(DB.Resource.is_gtfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/resource.ex:123:7 #(DB.Resource.is_gtfs?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/dataset.ex:107:7 #(DB.Dataset.is_active?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/dataset.ex:104:7 #(DB.Dataset.is_archived?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/dataset.ex:103:7 #(DB.Dataset.is_archived?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/contact.ex:99:7 #(DB.Contact.is_mailing_list?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/transport/lib/db/contact.ex:91:7 #(DB.Contact.is_human?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/shared/lib/schemas.ex:26:7 #(Transport.Shared.Schemas.Wrapper.is_jsonschema?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/shared/lib/schemas.ex:22:7 #(Transport.Shared.Schemas.Wrapper.is_tableschema?)
┃ [R] ↗ Predicate function names should not start with 'is', and should end in a question mark.
┃       apps/shared/lib/schemas.ex:13:7 #(Transport.Shared.Schemas.Wrapper.is_known_schema?)
@thbar thbar added the dette technique Entretien & maintenance générale, nécessaire pour que le code reste de bonne qualité label Mar 19, 2024
@thbar thbar self-assigned this Mar 19, 2024
@vdegove
Copy link
Contributor

vdegove commented Mar 19, 2024

Je me suis rendu compte que le fichier de configuration de Credo datait un peu, et que le format avait changé. Ça vaut peut-être le coup de le re-générer de zéro (je l’ai fait, j’ai eu une platrée de warnings).

@thbar
Copy link
Contributor Author

thbar commented Mar 19, 2024

Je me suis rendu compte que le fichier de configuration de Credo datait un peu, et que le format avait changé. Ça vaut peut-être le coup de le re-générer de zéro (je l’ai fait, j’ai eu une platrée de warnings).

Je ne vais pas me lancer là dedans tout de suite pour rester "focus", mais c'est une bonne remarque et oui on pourra tenter ça ! (mais peut-être pas dans une PR d'upgrade majeure à côté, ça risque de faire beaucoup de "bruit" et qu'on rate quelque chose de plus important).

@thbar
Copy link
Contributor Author

thbar commented Mar 19, 2024

J'ai un script pour faire la migration en m'appuyant sur Credo, presque finalisé.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dette technique Entretien & maintenance générale, nécessaire pour que le code reste de bonne qualité
Projects
None yet
Development

No branches or pull requests

2 participants