Apply rubocop auto-corrections to lib/api/commits.rb
## Summary Apply rubocop style auto-corrections to `lib/api/commits.rb` as preparatory cleanup before implementing keyset pagination. ## Parent Issue This is part of #595504 (Epic: Refactor Commits API to use standard keyset pagination patterns) ## Background MR !229705 included rubocop auto-corrections mixed with feature changes. To keep commits focused and reviewable, we're separating the style cleanup into its own MR. ## Changes Required Apply the following rubocop corrections to `lib/api/commits.rb`: ### 1. Guard clause in `authorize_push_to_branch!` ```ruby # Before def authorize_push_to_branch!(branch) authenticate! unless user_access.can_push_to_branch?(branch) forbidden!("You are not allowed to push into this branch") end end # After def authorize_push_to_branch!(branch) authenticate! return if user_access.can_push_to_branch?(branch) forbidden!("You are not allowed to push into this branch") end ``` ### 2. Guard clause in `validate_actions_allow_empty!` ```ruby # Before - nested if with early return pattern if !attrs.key?(:actions) || (attrs[:actions].is_a?(Array) && attrs[:actions].empty?) # ... validation logic inside end # After - guard clause with return return unless !attrs.key?(:actions) || (attrs[:actions].is_a?(Array) && attrs[:actions].empty?) # ... validation logic at method level ``` ### 3. Line wrapping on merge_requests endpoint Fix line length on the `get ':id/repository/commits/:sha/merge_requests'` endpoint definition. ## Acceptance Criteria - [ ] Run `rubocop -a lib/api/commits.rb` and commit the changes - [ ] Ensure all existing tests pass - [ ] No functional changes - style only ## References - Parent epic: #595504 - Original MR with mixed changes: !229705
issue