From 368e9a0862dd7d58b009956e8f1ac51d2a549cda Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:26:40 -0800 Subject: [PATCH] Rubocop: Style/CaseIndentation enabled --- .rubocop.yml | 2 +- app/finders/notes_finder.rb | 25 +++++++++++++------------ lib/api/api_guard.rb | 7 ++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 319efe7e0dc..923ea00a106 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -96,7 +96,7 @@ Style/CaseEquality: Style/CaseIndentation: Description: 'Indentation of when in a case/when/[else/]end.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-when-to-case' - Enabled: false + Enabled: true Style/CharacterLiteral: Description: 'Checks for uses of character literals.' diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index bef82d7f0fd..6fe15b41060 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -7,18 +7,19 @@ class NotesFinder # Default to 0 to remain compatible with old clients last_fetched_at = Time.at(params.fetch(:last_fetched_at, 0).to_i) - notes = case target_type - when "commit" - project.notes.for_commit_id(target_id).not_inline.fresh - when "issue" - project.issues.find(target_id).notes.inc_author.fresh - when "merge_request" - project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh - when "snippet", "project_snippet" - project.snippets.find(target_id).notes.fresh - else - raise 'invalid target_type' - end + notes = + case target_type + when "commit" + project.notes.for_commit_id(target_id).not_inline.fresh + when "issue" + project.issues.find(target_id).notes.inc_author.fresh + when "merge_request" + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh + when "snippet", "project_snippet" + project.snippets.find(target_id).notes.fresh + else + raise 'invalid target_type' + end # Use overlapping intervals to avoid worrying about race conditions notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP) diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index cb20bf0720d..b9994fcefda 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -47,16 +47,12 @@ module APIGuard case validate_access_token(access_token, scopes) when Oauth2::AccessTokenValidationService::INSUFFICIENT_SCOPE raise InsufficientScopeError.new(scopes) - when Oauth2::AccessTokenValidationService::EXPIRED raise ExpiredError - when Oauth2::AccessTokenValidationService::REVOKED raise RevokedError - when Oauth2::AccessTokenValidationService::VALID @current_user = User.find(access_token.resource_owner_id) - end end end @@ -121,7 +117,8 @@ module APIGuard def oauth2_bearer_token_error_handler Proc.new do |e| - response = case e + response = + case e when MissingTokenError Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new