Skip to content

Clean up deprecated code and simplify validations #2573

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

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

ericproulx
Copy link
Contributor

Clean up deprecated code and simplify validations

This PR removes deprecated code and simplifies the validation system in Grape.

Changes

Removed Deprecated Methods

  • rack_response method: Removed from Grape::DSL::InsideRoute module
    • This method was deprecated in favor of using error! instead
    • Removed associated deprecation warning and tests

Removed Deprecated Exception Aliases

  • Grape::Exceptions::MissingGroupTypeError: Removed deprecated alias for MissingGroupType
  • Grape::Exceptions::UnsupportedGroupTypeError: Removed deprecated alias for UnsupportedGroupType
  • Updated specs to remove references to these deprecated classes

Removed Deprecated Base Class

  • Grape::Validations::Base: Removed deprecated base class
    • Users should use Grape::Validations::Validators::Base instead
    • Removed associated deprecation warning

Simplified Validation Logic

  • params_scope.rb: Simplified validation parameter handling
    • Removed deprecated excepts parameter from validation methods
    • Consolidated except_values handling logic
    • Cleaned up method signatures and reduced code complexity

Test Cleanup

  • deprecated_class_examples.rb: Removed shared spec file for deprecated classes
  • Updated all specs to remove references to deprecated classes and methods
  • Removed deprecation-related test cases

Impact

Breaking Changes

  • rack_response method: No longer available, use error! instead
  • Exception aliases: MissingGroupTypeError and UnsupportedGroupTypeError removed
  • Base class: Grape::Validations::Base removed

Code Quality Improvements

  • Reduced codebase complexity by removing deprecated code paths
  • Simplified validation parameter handling
  • Cleaner exception hierarchy
  • Reduced maintenance burden

Migration Guide

For Users of rack_response

Replace:

rack_response('message', 500, headers)

With:

error!('message', 500, headers)

For Users of Deprecated Exception Classes

Replace:

Grape::Exceptions::MissingGroupTypeError
Grape::Exceptions::UnsupportedGroupTypeError

With:

Grape::Exceptions::MissingGroupType
Grape::Exceptions::UnsupportedGroupType

For Custom Validators

Replace:

class MyValidator < Grape::Validations::Base

With:

class MyValidator < Grape::Validations::Validators::Base

Testing

  • All existing tests pass
  • Removed deprecated code paths and associated tests
  • No new functionality added, only cleanup

Related Issues

This cleanup addresses technical debt and removes deprecated code that was marked for removal in previous versions.

@ericproulx ericproulx force-pushed the cleanup-deprecated-code branch from ca3280e to d5adb08 Compare June 22, 2025 10:01
@ericproulx ericproulx marked this pull request as ready for review June 22, 2025 10:06
@ericproulx ericproulx force-pushed the cleanup-deprecated-code branch 2 times, most recently from fae8b49 to ed92eb6 Compare June 22, 2025 17:25
- Remove deprecated rack_response method from DSL
- Remove deprecated exception aliases (MissingGroupTypeError, UnsupportedGroupTypeError)
- Remove deprecated Grape::Validations::Base class
- Simplify params_scope.rb by removing deprecated excepts parameter
- Remove deprecated_class_examples.rb shared spec file
- Update specs to remove references to deprecated classes

Remove except_values test since already tested in except_values_spec.rb
@ericproulx ericproulx force-pushed the cleanup-deprecated-code branch from ed92eb6 to c8d7d15 Compare June 22, 2025 17:26
@ericproulx ericproulx requested a review from dblock June 22, 2025 17:26
@ericproulx
Copy link
Contributor Author

@dblock added an upgrading note

@dblock dblock merged commit f66492a into ruby-grape:master Jun 23, 2025
47 checks passed
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.

2 participants