casa icon indicating copy to clipboard operation
casa copied to clipboard

Standard.rb linting -> Rubocop and relevant plugins

Open thejonroberts opened this issue 1 year ago • 1 comments

What github issue is this PR for, if any?

No Issue.

What changed, and why?

This project welcomes and encourages new contributors who may not have a lot of experience with idiomatic ruby or common patterns to avoid in rails/rspec/capybara, etc... So having good linting in place is important -- both to maintain code quality and to give newer devs a tool to learn about common patterns & good practices.

It also makes review easier because there are fewer style nits & common gotchas to get hung up on. Maintainers can focus on more important things! And, to be honest, I love linters because I don't want to have to think about all these things!

It will also create a nice set of TODOs for people that want to start contributing! An Epic issue similar the the xit/skipped specs epic could be created to fix the todos file by file.

This rubocop setup is based on this evil martians article on adding standard/rubocop to a legacy project.

  • Move from standardrb to rubocop so that we can add rubocop-* extensions for various tooling:
    • rails, rspec, rspec_rails, factory_bot, capybara
  • Configure the rules in .rubocop.yml
    • Inherit from the standard/standard-rails rules and try to not fuss with defaults too much.
    • Fix some of the more important/performance rules & make sure they aren't ignored in todo.
  • Generate TODO file so that extreme change to codebase is avoided & CI can incorporate immediately.
    • Comments in rubocop.yml on how to find todo issues to fix.
  • Replace standard for rubocop in bin/lint, GitHub CI lint workflow, & git hooks.
  • Remove current rubocop:disable comments as any offenses will be in the todo file.

Things to consider:

  • I tried to minimize the amount of configuration. Generally, I agree with the Standard.rb approach, less config the better. However, I also have some strong opinions! Standard.rb/standard-rails' rulesets are also decided by working ruby/rails devs who know their way around, and don't necessarily line up with the needs of CASA or the current codebase.
  • I added a few of those opinions in the CUSTOMIZED RULES section of rubocop.yml config. I think those gotchas are important for people with less rails experience. For example, default_scope is both tempting to use AND causes some tricky issues for the uninitiated. It is difficult to figure out when an .unscoped is needed because of a default scope. I have personally run into confusion around it many, many times!
  • Most rule customizations, particularly for rspec plugin are to avoid giving an insane amount of violations with the default config... Could move those to todos, but they seem pretty restrictive to me! I don't mind the higher max numbers.
  • The RSpec/LetSetup rule: I think this encourages good practice, but the let! pattern has been common in every project I personally have worked on... Therefore I left it enabled but with a detailed description. I think disabling it would be okay, but encouraging good practice won out in my opinion. I added a lengthy details example to better explain fix to inexperienced devs.
  • Similarly, factory_bot rules discourage some patterns that are very common, like associations in after(:create) blocks. I think this is a good thing -- factory cascades can lead to so much extra database time in specs, and become harder to fix the more complicated things get. The rubocop rules facilitate more use of build_stubbed etc... So I left it enabled, and current violations are in the todo.
  • We could add the --ignore-disable-comments flag to the workflows to be super strict, but I think it's probably better to allow those rather than be tempted to tweak configs over and over. If a rule is slowing down a feature too much, just rubocop:todo it and let someone else fix it later.
  • Open to ideas on all this!
  • This could be gem-ified for other CASA projects?

How is this tested? (please write tests!) 💖💪

Current specs

thejonroberts avatar Oct 23 '24 18:10 thejonroberts

Offense count by file

BYPASS_RUBOCOP_TODO=1 bundle exec rubocop --format worst

BYPASS_RUBOCOP_TODO=1 bundle exec rubocop --format worst

115   spec/models/volunteer_spec.rb
100   spec/system/casa_cases/edit_spec.rb
81    spec/policies/case_contact_policy_spec.rb
72    spec/policies/casa_case_policy_spec.rb
65    spec/requests/users_spec.rb
55    spec/models/casa_case_spec.rb
54    spec/models/case_contact_report_spec.rb
50    spec/system/casa_cases/show_spec.rb
48    spec/system/supervisors/index_spec.rb
46    spec/views/layouts/sidebar.html.erb_spec.rb
45    spec/system/volunteers/edit_spec.rb
42    spec/decorators/user_decorator_spec.rb
41    spec/models/case_contact_spec.rb
39    spec/policies/supervisor_policy_spec.rb
39    spec/system/case_court_reports/index_spec.rb
38    spec/system/supervisors/edit_spec.rb
33    spec/views/volunteers/edit.html.erb_spec.rb
32    spec/policies/additional_expense_policy_spec.rb
32    spec/policies/contact_topic_answer_policy_spec.rb
30    spec/policies/user_policy_spec.rb
30    spec/requests/casa_admins_spec.rb
30    spec/system/notifications/index_spec.rb
30    spec/views/supervisor_mailer/weekly_digest.html.erb_spec.rb
29    spec/config/initializers/rack_attack_spec.rb
29    spec/datatables/volunteer_datatable_spec.rb
27    spec/system/users/edit_spec.rb
25    spec/components/modal/group_component_spec.rb
25    spec/policies/case_assignment_policy_spec.rb
23    spec/policies/application_policy_spec.rb
23    spec/requests/court_dates_spec.rb
22    spec/lib/tasks/no_contact_made_reminder_spec.rb
21    spec/callbacks/case_contact_metadata_callback_spec.rb
21    spec/system/casa_cases/additional_index_spec.rb
21    spec/system/imports/index_spec.rb
20    spec/helpers/case_contacts_helper_spec.rb
20    spec/models/case_court_report_spec.rb
19    spec/mailers/supervisor_mailer_spec.rb
19    spec/models/emancipation_option_spec.rb
19    spec/policies/volunteer_policy_spec.rb
19    spec/system/volunteers/index_spec.rb
18    db/seeds/db_populator.rb
18    spec/models/casa_org_spec.rb
18    spec/models/contact_topic_spec.rb
18    spec/requests/emancipations_request_spec.rb
17    spec/models/user_spec.rb
17    spec/policies/casa_admin_policy_spec.rb
17    spec/requests/all_casa_admins/casa_admins_spec.rb
17    spec/requests/casa_cases_spec.rb
17    spec/services/volunteer_birthday_reminder_service_spec.rb
16    spec/lib/tasks/case_contact_types_reminder_spec.rb
16    spec/system/case_contacts/followups/resolve_spec.rb
16    spec/system/court_dates/edit_spec.rb
16    spec/system/reports/export_data_spec.rb
15    spec/controllers/application_controller_spec.rb
15    spec/models/case_court_report_context_spec.rb
15    spec/models/court_date_spec.rb
15    spec/requests/case_court_reports_spec.rb
15    spec/requests/fund_requests_spec.rb
14    spec/components/modal/open_button_component_spec.rb
14    spec/services/emancipation_checklist_reminder_service_spec.rb
14    spec/system/casa_cases/new_spec.rb
14    spec/views/case_contacts/case_contact.html.erb_spec.rb
13    spec/controllers/concerns/organizational_spec.rb
13    spec/lib/importers/supervisor_importer_spec.rb
13    spec/models/contact_type_spec.rb
13    spec/requests/contact_type_groups_spec.rb
13    spec/requests/contact_types_spec.rb
13    spec/requests/judges_spec.rb
13    spec/requests/volunteers_spec.rb
13    spec/system/casa_org/edit_spec.rb
13    spec/system/reports/index_spec.rb
12    spec/components/modal/open_link_component_spec.rb
12    spec/decorators/casa_case_decorator_spec.rb
12    spec/mailers/previews/volunteer_mailer_preview_spec.rb
12    spec/models/case_assignment_spec.rb
12    spec/policies/other_duty_policy_spec.rb
12    spec/requests/all_casa_admins_spec.rb
11    spec/components/sidebar/group_component_spec.rb
11    spec/datatables/reimbursement_datatable_spec.rb
11    spec/models/learning_hour_spec.rb
11    spec/requests/case_contact_reports_spec.rb
11    spec/services/case_contacts_contact_dates_spec.rb
11    spec/system/all_casa_admins/all_casa_admin_spec.rb
11    spec/system/other_duties/new_spec.rb
11    spec/views/checklist_items/new.html.erb_spec.rb
11    spec/views/supervisors/edit.html.erb_spec.rb
10    spec/components/modal/header_component_spec.rb
10    spec/mailers/previews/supervisor_mailer_preview_spec.rb
10    spec/models/emancipation_category_spec.rb
10    spec/policies/dashboard_policy_spec.rb
10    spec/requests/checklist_items_spec.rb
10    spec/requests/notifications_spec.rb
10    spec/system/case_contacts/drafts_spec.rb
10    spec/system/sessions/new_spec.rb
10    spec/views/all_casa_admins/casa_orgs/new.html.erb_spec.rb
10    spec/views/all_casa_admins/patch_notes/index.html.erb_spec.rb
10    spec/views/layouts/header.html.erb_spec.rb
9     spec/components/modal/body_component_spec.rb
9     spec/controllers/concerns/accessible_spec.rb
9     spec/controllers/emancipations_controller_spec.rb
9     spec/factories/notifications.rb
9     spec/services/court_report_due_sms_reminder_service_spec.rb
9     spec/services/no_contact_made_sms_reminder_service_spec.rb
9     spec/services/sms_reminder_service_spec.rb
9     spec/system/casa_admins/edit_spec.rb
9     spec/system/case_groups/case_groups_spec.rb
9     spec/system/reimbursements/reimbursements_spec.rb
9     spec/views/banners/new.html.erb_spec.rb
9     spec/views/checklist_items/edit.html.erb_spec.rb
8     spec/components/dropdown_menu_component_spec.rb
8     spec/helpers/application_helper_spec.rb
8     spec/lib/importers/case_importer_spec.rb
8     spec/lib/importers/volunteer_importer_spec.rb
8     spec/mailers/previews/casa_admin_mailer_preview_spec.rb
8     spec/requests/imports_spec.rb
8     spec/requests/learning_hours_spec.rb
8     spec/requests/supervisors_spec.rb
8     spec/system/case_contacts/followups/create_spec.rb
8     spec/system/dashboard/show_spec.rb
8     spec/views/casa_admins/edit.html.erb_spec.rb
8     spec/views/casa_orgs/edit.html.erb_spec.rb
8     spec/views/hearing_types/edit.html.erb_spec.rb
8     spec/views/judges/new.html.erb_spec.rb
7     spec/models/contact_type_group_spec.rb
7     spec/models/followup_spec.rb
7     spec/models/health_spec.rb
7     spec/models/mileage_rate_spec.rb
7     spec/policies/notification_policy_spec.rb
7     spec/requests/casa_org_spec.rb
7     spec/requests/case_assignments_spec.rb
7     spec/requests/reimbursements_spec.rb
7     spec/requests/supervisor_volunteers_spec.rb
7     spec/system/all_casa_admins/patch_notes/index_spec.rb
7     spec/system/court_dates/view_spec.rb
7     spec/system/learning_hours/index_spec.rb
7     spec/views/casa_cases/new.html.erb_spec.rb
7     spec/views/casa_cases/show.html.erb_spec.rb
7     spec/views/templates/email_templates_spec.rb
7     spec/views/volunteers/index.html.erb_spec.rb
6     app/decorators/casa_case_decorator.rb
6     spec/components/sidebar/link_component_spec.rb
6     spec/datatables/supervisor_datatable_spec.rb
6     spec/mailers/previews/devise_mailer_preview_spec.rb
6     spec/models/casa_admin_spec.rb
6     spec/models/hearing_type_spec.rb
6     spec/models/other_duty_spec.rb
6     spec/policies/contact_topic_policy_spec.rb
6     spec/policies/supervisor_volunteer_policy_spec.rb
6     spec/requests/case_contacts/followups_spec.rb
6     spec/requests/case_contacts/form_spec.rb
6     spec/requests/contact_topics_spec.rb
6     spec/requests/dashboard_spec.rb
6     spec/requests/languages_spec.rb
6     spec/system/banners/new_spec.rb
6     spec/system/casa_cases/show_more_spec.rb
6     spec/system/court_dates/new_spec.rb
6     spec/system/volunteers/new_spec.rb
6     spec/views/casa_cases/edit.html.erb_spec.rb
6     spec/views/case_court_reports/index.html.erb_spec.rb
6     spec/views/hearing_types/new.html.erb_spec.rb
5     app/models/casa_case.rb
5     app/models/casa_org.rb
5     spec/components/modal/footer_component_spec.rb
5     spec/lib/importers/file_importer_spec.rb
5     spec/lib/tasks/supervisor_weekly_digest_spec.rb
5     spec/mailers/volunteer_mailer_spec.rb
5     spec/models/learning_hour_type_spec.rb
5     spec/models/supervisor_spec.rb
5     spec/models/supervisor_volunteer_spec.rb
5     spec/policies/hearing_type_policy_spec.rb
5     spec/rails_helper.rb
5     spec/requests/banners_spec.rb
5     spec/requests/contact_topic_answers_spec.rb
5     spec/requests/mileage_rates_spec.rb
5     spec/requests/users/passwords_spec.rb
5     spec/system/banners/dismiss_spec.rb
5     spec/system/casa_admins/new_spec.rb
5     spec/system/components/truncated_text_component_spec.rb
5     spec/system/deep_link/deep_link_spec.rb
5     spec/system/placements/destroy_spec.rb
5     spec/system/placements/edit_spec.rb
5     spec/system/placements/new_spec.rb
5     spec/views/court_dates/edit.html.erb_spec.rb
4     app/models/user.rb
4     config/application.rb
4     lib/tasks/test_checker.rake
4     spec/components/badge_component_spec.rb
4     spec/controllers/concerns/users/time_zone_spec.rb
4     spec/factories/login_activities.rb
4     spec/helpers/banner_helper_spec.rb
4     spec/helpers/emancipations_helper_spec.rb
4     spec/helpers/notifications_helper_spec.rb
4     spec/lib/tasks/data_post_processors/contact_topic_populator_spec.rb
4     spec/mailers/learning_hours_mailer_spec.rb
4     spec/models/all_casa_admins/casa_org_metrics_spec.rb
4     spec/models/case_group_spec.rb
4     spec/models/checklist_item_spec.rb
4     spec/policies/casa_org_policy_spec.rb
4     spec/policies/case_court_report_policy_spec.rb
4     spec/policies/checklist_item_policy_spec.rb
4     spec/policies/reimbursement_policy_spec.rb
4     spec/requests/additional_expenses_spec.rb
4     spec/requests/all_casa_admins/casa_orgs_spec.rb
4     spec/requests/emancipation_checklists_spec.rb
4     spec/requests/health_spec.rb
4     spec/requests/reports_spec.rb
4     spec/services/casa_case_change_service_spec.rb
4     spec/services/followup_service_spec.rb
4     spec/services/twilio_service_spec.rb
4     spec/support/capybara.rb
4     spec/system/casa_cases/emancipation/show_spec.rb
4     spec/system/case_contacts/index_spec.rb
4     spec/system/checklist_items/destroy_spec.rb
4     spec/system/emancipations/show_spec.rb
4     spec/views/all_casa_admins/casa_orgs/show.html.erb_spec.rb
4     spec/views/casa_cases/index.html.erb_spec.rb
4     spec/views/court_dates/new.html.erb_spec.rb
4     spec/views/notifications/index.html.erb_spec.rb
4     spec/views/placements/edit.html.erb_spec.rb
4     spec/views/placements/index.html.erb_spec.rb
4     spec/views/placements/new.html.erb_spec.rb
4     spec/views/reimbursements/index.html.erb_spec.rb
3     app/mailers/learning_hours_mailer.rb
3     app/models/concerns/CasaCase/validations.rb
3     db/seeds.rb
3     spec/components/truncated_text_component_spec.rb
3     spec/helpers/phone_number_helper_spec.rb
3     spec/helpers/sidebar_helper_spec.rb
3     spec/helpers/ui_helper_spec.rb
3     spec/mailers/casa_admin_mailer_spec.rb
3     spec/models/additional_expense_spec.rb
3     spec/models/contact_topic_answer_spec.rb
3     spec/models/learning_hour_topic_spec.rb
3     spec/models/missing_data_report_spec.rb
3     spec/models/placement_spec.rb
3     spec/notifications/reimbursement_complete_notifier_spec.rb
3     spec/policies/bulk_court_date_policy_spec.rb
3     spec/policies/contact_type_group_policy_spec.rb
3     spec/policies/contact_type_policy_spec.rb
3     spec/policies/followup_policy_spec.rb
3     spec/policies/import_policy_spec.rb
3     spec/policies/judge_policy_spec.rb
3     spec/policies/language_policy_spec.rb
3     spec/policies/learning_hour_policy_spec.rb
3     spec/requests/all_casa_admins/patch_notes_spec.rb
3     spec/requests/api/v1/base_spec.rb
3     spec/requests/missing_data_reports_spec.rb
3     spec/requests/preference_sets_spec.rb
3     spec/services/additional_expense_params_service_spec.rb
3     spec/services/backfill_followupable_service_spec.rb
3     spec/services/deployment/backfill_case_contact_started_metadata_service_spec.rb
3     spec/services/preference_set_table_state_service_spec.rb
3     spec/system/all_casa_admins/sessions/new_spec.rb
3     spec/system/application/timeout_warning_spec.rb
3     spec/system/bulk_court_dates/new_spec.rb
3     spec/system/devise/passwords/new_spec.rb
3     spec/system/learning_hours/edit_spec.rb
3     spec/system/learning_hours/new_spec.rb
3     spec/system/learning_hours/volunteers/show_spec.rb
3     spec/system/mileage_rates/mileage_rates_spec.rb
3     spec/system/placements/index_spec.rb
3     spec/system/sessions/login_spec.rb
3     spec/system/static/index_spec.rb
3     spec/system/supervisors/new_spec.rb
3     spec/views/court_dates/show.html.erb_spec.rb
3     spec/views/supervisors/index.html.erb_spec.rb
3     spec/views/supervisors/new.html.erb_spec.rb
3     spec/views/volunteers/new.html.erb_spec.rb
2     app/controllers/casa_cases_controller.rb
2     app/decorators/case_assignment_decorator.rb
2     app/models/banner.rb
2     app/models/case_assignment.rb
2     app/models/case_group.rb
2     app/models/hearing_type.rb
2     app/models/judge.rb
2     app/models/learning_hour_type.rb
2     app/services/casa_case_change_service.rb
2     app/services/fdf_inputs_service.rb
2     app/validators/user_validator.rb
2     spec/components/notification_component_spec.rb
2     spec/decorators/case_contact_decorator_spec.rb
2     spec/decorators/contact_type_decorator_spec.rb
2     spec/factories/casa_case_emancipation_categories.rb
2     spec/factories/casa_cases_emancipation_options.rb
2     spec/factories/case_court_report_context.rb
2     spec/factories/case_group_memberships.rb
2     spec/factories/notes.rb
2     spec/factories/patch_notes.rb
2     spec/factories/sent_emails.rb
2     spec/factories/supervisor_volunteer.rb
2     spec/helpers/followup_helper_spec.rb
2     spec/lib/tasks/data_post_processors/contact_type_populator_spec.rb
2     spec/mailers/fund_request_mailer_spec.rb
2     spec/models/address_spec.rb
2     spec/models/language_spec.rb
2     spec/models/mileage_report_spec.rb
2     spec/models/patch_note_group_spec.rb
2     spec/models/patch_note_spec.rb
2     spec/models/patch_note_type_spec.rb
2     spec/models/placement_type_spec.rb
2     spec/models/preference_set_spec.rb
2     spec/models/user_reminder_time.rb
2     spec/presenters/case_contact_presenter_spec.rb
2     spec/requests/all_casa_admins/sessions_spec.rb
2     spec/requests/api/v1/users/sessions_spec.rb
2     spec/requests/bulk_court_dates_spec.rb
2     spec/requests/case_groups_spec.rb
2     spec/requests/hearing_types_spec.rb
2     spec/requests/other_duties_spec.rb
2     spec/services/short_url_service_spec.rb
2     spec/support/shared_examples/shows_court_dates_links.rb
2     spec/system/case_contacts/contact_topic_answers_spec.rb
2     spec/system/case_contacts/new_spec.rb
2     spec/system/checklist_items/edit_spec.rb
2     spec/system/checklist_items/new_spec.rb
2     spec/system/contact_types/edit_spec.rb
2     spec/system/contact_types/new_spec.rb
2     spec/system/languages/languages_spec.rb
2     spec/system/sessions/destroy_spec.rb
2     spec/system/volunteers/notes/edit_spec.rb
2     spec/views/case_contacts/index.html.erb_spec.rb
1     app/controllers/all_casa_admins/sessions_controller.rb
1     app/controllers/api/v1/base_controller.rb
1     app/controllers/case_contacts/form_controller.rb
1     app/controllers/case_contacts_controller.rb
1     app/controllers/checklist_items_controller.rb
1     app/controllers/court_dates_controller.rb
1     app/controllers/placements_controller.rb
1     app/controllers/reimbursements_controller.rb
1     app/controllers/users/sessions_controller.rb
1     app/datatables/volunteer_datatable.rb
1     app/helpers/banner_helper.rb
1     app/helpers/phone_number_helper.rb
1     app/mailers/fund_request_mailer.rb
1     app/mailers/supervisor_mailer.rb
1     app/models/casa_admin.rb
1     app/models/casa_case_contact_type.rb
1     app/models/casa_case_emancipation_category.rb
1     app/models/case_contact_contact_type.rb
1     app/models/case_court_report_context.rb
1     app/models/contact_topic.rb
1     app/models/contact_type.rb
1     app/models/contact_type_group.rb
1     app/models/health.rb
1     app/models/language.rb
1     app/models/learning_hour.rb
1     app/models/learning_hour_topic.rb
1     app/models/mileage_rate.rb
1     app/models/note.rb
1     app/models/other_duty.rb
1     app/models/supervisor.rb
1     app/models/supervisor_volunteer.rb
1     app/models/volunteer.rb
1     lib/mailers/debug_preview_mailer.rb
1     lib/mailers/previews/devise_mailer_preview.rb
1     lib/mailers/previews/fund_request_mailer_preview.rb
1     lib/mailers/previews/volunteer_mailer_preview.rb
1     lib/tasks/case_contact_types_reminder.rb
1     lib/tasks/deployment/20240604121427_migrate_notifications.rake
1     lib/tasks/deployment/99991023145114_store_deploy_time.rake
1     lib/tasks/no_contact_made_reminder.rb
1     lib/tasks/supervisor_weekly_digest.rb
1     spec/components/form/hour_minute_duration_component_spec.rb
1     spec/decorators/android_app_association_decorator_spec.rb
1     spec/decorators/case_contacts/form_decorator_spec.rb
1     spec/decorators/patch_note_decorator_spec.rb
1     spec/decorators/placement_decorator_spec.rb
1     spec/factories/addresses.rb
1     spec/factories/banners.rb
1     spec/factories/casa_cases.rb
1     spec/factories/casa_orgs.rb
1     spec/factories/case_assignments.rb
1     spec/factories/case_contacts.rb
1     spec/factories/checklist_items.rb
1     spec/factories/court_dates.rb
1     spec/factories/emancipation_options.rb
1     spec/factories/followups.rb
1     spec/factories/healths.rb
1     spec/factories/placements.rb
1     spec/factories/users.rb
1     spec/factories/volunteers.rb
1     spec/helpers/contact_types_helper_spec.rb
1     spec/helpers/court_orders_helper_spec.rb
1     spec/helpers/learning_hours_helper_spec.rb
1     spec/helpers/mileage_rates_helper_spec.rb
1     spec/helpers/preference_sets_helper_spec.rb
1     spec/helpers/volunteer_helper_spec.rb
1     spec/mailers/user_mailer_spec.rb
1     spec/models/all_casa_admin_spec.rb
1     spec/models/banner_spec.rb
1     spec/models/casa_case_contact_type_spec.rb
1     spec/models/casa_case_emancipation_category_spec.rb
1     spec/models/casa_cases_emancipation_option_spec.rb
1     spec/models/case_contact_contact_type_spec.rb
1     spec/models/case_court_order_spec.rb
1     spec/models/case_group_membership_spec.rb
1     spec/models/judge_spec.rb
1     spec/models/learning_hours_report_spec.rb
1     spec/models/login_activity_spec.rb
1     spec/models/note_spec.rb
1     spec/models/sent_email_spec.rb
1     spec/models/sms_notification_event_spec.rb
1     spec/models/user_language_spec.rb
1     spec/models/user_sms_notification_event_spec.rb
1     spec/notifications/emancipation_checklist_reminder_notifier_spec.rb
1     spec/notifications/volunteer_birthday_notifier_spec.rb
1     spec/policies/casa_case_policy/scope_spec.rb
1     spec/policies/case_group_policy_spec.rb
1     spec/policies/placement_policy_spec.rb
1     spec/requests/all_casa_admins/dashboard_spec.rb
1     spec/requests/android_app_associations_spec.rb
1     spec/requests/case_contacts_spec.rb
1     spec/requests/case_court_orders_spec.rb
1     spec/requests/error_spec.rb
1     spec/requests/learning_hours_reports_spec.rb
1     spec/requests/notes_spec.rb
1     spec/requests/placement_reports_spec.rb
1     spec/requests/static_spec.rb
1     spec/routing/all_casa_admins/patch_notes_routing_spec.rb
1     spec/services/mileage_export_csv_service_spec.rb
1     spec/services/placement_export_csv_service_spec.rb
1     spec/support/rack_attack.rb
1     spec/system/casa_admins/index_spec.rb
1     spec/system/casa_cases/fund_requests/new_spec.rb
1     spec/system/casa_cases/index_spec.rb
1     spec/system/case_contacts/additional_expenses_spec.rb
1     spec/system/case_contacts/edit_spec.rb
1     spec/system/hearing_types/new_spec.rb
1     spec/system/judges/new_spec.rb
1     spec/values/case_contact_parameters_spec.rb
1     spec/views/bulk_court_date/new.html.erb_spec.rb
1     spec/views/casa_admins/admins_table.html.erb_spec.rb
1     spec/views/devise/passwords/new.html.erb_spec.rb
1     spec/views/emancipations/show.html.erb_spec.rb
1     spec/views/layouts/application.html.erb_spec.rb
1     spec/views/layouts/footer.html.erb_spec.rb
1     spec/views/mileage_rates/index.html.erb_spec.rb
1     spec/views/other_duties/edit.html.erb_spec.rb
1     spec/views/other_duties/new.html.erb_spec.rb
--
3370  Total in 439 files
Offense count by rule

BYPASS_RUBOCOP_TODO=1 bundle exec rubocop --format offenses

350   RSpec/ImplicitSubject [Safe Correctable]
334   RSpec/ContextWording
250   RSpecRails/InferredSpecType [Unsafe Correctable]
216   Capybara/NegationMatcher [Safe Correctable]
181   RSpec/DescribedClass [Unsafe Correctable]
156   RSpec/IndexedLet
145   RSpec/LetSetup
142   RSpec/MetadataStyle [Safe Correctable]
124   RSpec/ExampleWording [Safe Correctable]
110   Capybara/RSpec/HaveSelector [Safe Correctable]
95    Rails/SaveBang [Unsafe Correctable]
89    RSpec/ReceiveMessages [Unsafe Correctable]
71    Rails/Date [Unsafe Correctable]
69    RSpec/InstanceVariable
63    RSpec/BeEq [Unsafe Correctable]
56    Rails/FilePath [Safe Correctable]
55    RSpec/EmptyLineAfterFinalLet [Safe Correctable]
53    RSpec/AnyInstance
50    Capybara/ClickLinkOrButtonStyle
39    Rails/TimeZone [Unsafe Correctable]
38    Rails/RedundantTravelBack [Safe Correctable]
34    RSpec/EmptyLineAfterHook [Safe Correctable]
34    RSpec/MessageSpies
30    RSpec/HookArgument [Safe Correctable]
26    RSpec/VerifiedDoubles
25    Capybara/SpecificFinders [Safe Correctable]
24    Capybara/SpecificMatcher
24    RSpec/PredicateMatcher [Unsafe Correctable]
24    RSpec/RepeatedDescription
23    RSpec/SortMetadata [Safe Correctable]
20    RSpec/ChangeByZero [Safe Correctable]
20    RSpec/EmptyLineAfterExample [Safe Correctable]
19    RSpec/MultipleMemoizedHelpers
18    FactoryBot/AssociationStyle [Unsafe Correctable]
16    Rails/Pluck [Unsafe Correctable]
15    RSpec/EmptyLineAfterSubject [Safe Correctable]
15    RSpec/MatchArray [Safe Correctable]
14    Capybara/CurrentPathExpectation [Safe Correctable]
14    RSpec/ImplicitExpect [Safe Correctable]
14    Rails/UniqueValidationWithoutIndex
13    FactoryBot/FactoryAssociationWithStrategy
13    RSpec/EmptyLineAfterExampleGroup [Safe Correctable]
13    RSpec/MessageChain
11    RSpec/NoExpectationExample
11    RSpecRails/HaveHttpStatus [Unsafe Correctable]
10    Capybara/VisibilityMatcher
10    RSpec/ContextMethod [Safe Correctable]
10    RSpec/NestedGroups
10    RSpec/SpecFilePathFormat
9     RSpec/ExampleLength
9     RSpec/StubbedMock
9     Rails/RootPathnameMethods [Unsafe Correctable]
8     RSpec/EmptyExampleGroup [Unsafe Correctable]
8     RSpec/RepeatedExampleGroupDescription
8     Rails/DurationArithmetic [Safe Correctable]
7     RSpec/ExcessiveDocstringSpacing [Safe Correctable]
7     RSpec/ExpectChange [Unsafe Correctable]
6     RSpec/RepeatedExample
6     RSpec/ScatteredLet [Safe Correctable]
6     RSpec/VoidExpect
5     Layout/ExtraSpacing [Safe Correctable]
5     RSpec/ExpectInHook
5     Rails/LexicallyScopedActionFilter
5     Rails/Validation [Safe Correctable]
4     FactoryBot/CreateList [Unsafe Correctable]
4     RSpecRails/NegationBeValid [Unsafe Correctable]
4     Rails/Blank [Unsafe Correctable]
4     Rails/DefaultScope
3     RSpec/BeEmpty [Safe Correctable]
3     RSpec/BeNil [Safe Correctable]
3     RSpec/MultipleExpectations
3     Rails/ActiveRecordCallbacksOrder [Safe Correctable]
3     Rails/RedundantForeignKey [Safe Correctable]
2     RSpec/BeforeAfterAll
2     RSpec/DescribeClass
2     RSpec/HooksBeforeExamples [Safe Correctable]
2     RSpec/ItBehavesLike [Safe Correctable]
2     RSpec/LetBeforeExamples [Safe Correctable]
2     RSpec/RepeatedExampleGroupBody
2     RSpec/SubjectDeclaration
2     Rails/ActiveRecordAliases [Unsafe Correctable]
2     Rails/IgnoredColumnsAssignment [Unsafe Correctable]
2     Rails/Presence [Safe Correctable]
1     Capybara/SpecificActions
1     FactoryBot/FactoryClassName [Safe Correctable]
1     FactoryBot/RedundantFactoryOption [Safe Correctable]
1     Performance/Count [Unsafe Correctable]
1     RSpec/BeEql [Unsafe Correctable]
1     RSpec/ContainExactly [Safe Correctable]
1     RSpec/ExpectInLet
1     RSpec/MissingExampleGroupArgument
1     RSpec/MissingExpectationTargetMethod
1     RSpec/MultipleDescribes
1     RSpec/SpecFilePathSuffix
1     RSpec/SubjectStub
1     RSpecRails/MinitestAssertions [Safe Correctable]
1     Rails/ApplicationMailer [Unsafe Correctable]
1     Rails/ApplicationRecord [Unsafe Correctable]
1     Rails/CompactBlank [Unsafe Correctable]
1     Rails/PluckInWhere [Unsafe Correctable]
1     Rails/RedundantPresenceValidationOnBelongsTo [Unsafe Correctable]
1     Rails/RootPublicPath [Safe Correctable]
1     Rails/WhereEquals [Unsafe Correctable]
--
3370  Total in 439 files

thejonroberts avatar Oct 23 '24 20:10 thejonroberts

Seems like a good reason... a big change tho.

compwron avatar Nov 15 '24 14:11 compwron

Probably yes but I or someone will get back to you

compwron avatar Nov 15 '24 15:11 compwron

I do agree that default_scope is bad because it is a footgun

compwron avatar Dec 05 '24 00:12 compwron

We use standardrb so we don't need to configure it. This seems worse.

@compwron Zero config is nice, but there are a few tradeoffs, imo... standard-rails disables the default_scope rule, for example - one of my gripes with it. It is definitely a foot gun! Also can't configure todo overrides as I have here... but I can probably just include those fixes.

I'll make a separate PR using standard with the plugins rolled up into it instead, and we can compare the approaches. Defaults will be used for all the rubocop plugins. There will be more violations, but it can also generate a todo file.

(I may try rubocop-rails rather than standard-rails, and see if it leaves the default scope rule enabled...)

thejonroberts avatar Dec 05 '24 01:12 thejonroberts

Dropping in favor of #6120 as standard can inherit some rubocop config, and therefore avoids changes to CI setup etc...

thejonroberts avatar Dec 05 '24 21:12 thejonroberts