Skip to content

Commit

Permalink
rubocop -a
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Mar 27, 2019
1 parent cc37b86 commit 625dcd9
Show file tree
Hide file tree
Showing 52 changed files with 95 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

appraise "rails-5-0" do
gem "rails", "~> 5.0.0"
gem "sqlite3", "~> 1.3", "< 1.4", platform: %i[ruby mswin mingw x64_mingw]
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "rails/all"
Expand Down
2 changes: 2 additions & 0 deletions doorkeeper.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.push File.expand_path("lib", __dir__)

require "doorkeeper/version"
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/models/access_token_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def find_or_create_for(application, resource_owner_id, scopes, expires_in, use_r
if Doorkeeper.configuration.reuse_access_token
access_token = matching_token_for(application, resource_owner_id, scopes)

return access_token if access_token && access_token.reusable?
return access_token if access_token&.reusable?
end

create!(
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/models/concerns/revocable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def revoked?
def revoke_previous_refresh_token!
return unless refresh_token_revoked_on_use?

old_refresh_token.revoke if old_refresh_token
old_refresh_token&.revoke
update_attribute :previous_refresh_token, ""
end

Expand Down
10 changes: 5 additions & 5 deletions lib/doorkeeper/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
module Doorkeeper
module OAuth
GRANT_TYPES = [
AUTHORIZATION_CODE = "authorization_code".freeze,
IMPLICIT = "implicit".freeze,
PASSWORD = "password".freeze,
CLIENT_CREDENTIALS = "client_credentials".freeze,
REFRESH_TOKEN = "refresh_token".freeze,
AUTHORIZATION_CODE = "authorization_code",
IMPLICIT = "implicit",
PASSWORD = "password",
CLIENT_CREDENTIALS = "client_credentials",
REFRESH_TOKEN = "refresh_token",
].freeze
end
end
2 changes: 1 addition & 1 deletion lib/doorkeeper/oauth/authorization_code_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def before_successful_response
end

def validate_attributes
return false if grant && grant.uses_pkce? && code_verifier.blank?
return false if grant&.uses_pkce? && code_verifier.blank?
return false if grant && !grant.pkce_supported? && !code_verifier.blank?

redirect_uri.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/oauth/client_credentials_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ClientCredentialsRequest < BaseRequest
attr_reader :response
attr_writer :issuer

alias_method :error_response, :response
alias error_response response

delegate :error, to: :issuer

Expand Down
1 change: 1 addition & 0 deletions lib/doorkeeper/oauth/helpers/uri_checker.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "ipaddr"

module Doorkeeper
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/oauth/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def token_from_header(header, pattern)
end

def match?(header, pattern)
header && header.match(pattern)
header&.match(pattern)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/oauth/token_introspection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def active?

# Token can be valid only if it is not expired or revoked.
def valid_token?
@token && @token.accessible?
@token&.accessible?
end

# RFC7662 Section 2.1
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/orm/active_record/access_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AccessGrant < ActiveRecord::Base
include AccessGrantMixin

belongs_to :application, class_name: "Doorkeeper::Application",
optional: true, inverse_of: :access_grants
optional: true, inverse_of: :access_grants

validates :resource_owner_id,
:application_id,
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/orm/active_record/access_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AccessToken < ActiveRecord::Base
include AccessTokenMixin

belongs_to :application, class_name: "Doorkeeper::Application",
inverse_of: :access_tokens, optional: true
inverse_of: :access_tokens, optional: true

validates :token, presence: true, uniqueness: true
validates :refresh_token, uniqueness: true, if: :use_refresh_token?
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/rails/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def doorkeeper_unauthorized_render_options(**); end
def doorkeeper_forbidden_render_options(**); end

def valid_doorkeeper_token?
doorkeeper_token && doorkeeper_token.acceptable?(@_doorkeeper_scopes)
doorkeeper_token&.acceptable?(@_doorkeeper_scopes)
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/stale_records_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Doorkeeper
class StaleRecordsCleaner
CLEANER_CLASS = "StaleRecordsCleaner".freeze
CLEANER_CLASS = "StaleRecordsCleaner"

def self.for(base_scope)
orm_adapter = "doorkeeper/orm/#{Doorkeeper.configuration.orm}".classify
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class CustomAuthorizationsController < ::ApplicationController
%w[index show new create edit update destroy].each do |action|
define_method action do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class FullProtectedResourcesController < ApplicationController
before_action -> { doorkeeper_authorize! :write, :admin }, only: :show
before_action :doorkeeper_authorize!, only: :index
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class HomeController < ApplicationController
def index; end

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/controllers/metal_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class MetalController < ActionController::Metal
include AbstractController::Callbacks
include ActionController::Head
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class SemiProtectedResourcesController < ApplicationController
before_action :doorkeeper_authorize!, only: :index

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationHelper
def current_user
@current_user ||= User.find_by_id(session[:user_id])
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class User < ActiveRecord::Base
def self.authenticate!(name, password)
User.where(name: name, password: password).first
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file is used by Rack-based servers to start the application.

require ::File.expand_path("../config/environment", __FILE__)
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Dummy::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/initializers/backtrace_silencers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

# Your secret key for verifying the integrity of signed cookies.
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

Dummy::Application.config.session_store :cookie_store, key: "_dummy_session"
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/initializers/wrap_parameters.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.
#
# This file contains settings for ActionController::ParamsWrapper which
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/db/migrate/20170822064514_enable_pkce.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class EnablePkce < ActiveRecord::Migration[4.2]
def change
add_column :oauth_access_grants, :code_challenge, :string, null: true
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/script/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This command will automatically be run when you run "rails" with Rails 3 gems
# installed from the root of your application.

Expand Down
2 changes: 2 additions & 0 deletions spec/generators/templates/routes.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

Rails.application.routes.draw do
end
2 changes: 2 additions & 0 deletions spec/routing/custom_controller_routes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

describe "Custom controller for routes" do
Expand Down
2 changes: 2 additions & 0 deletions spec/routing/default_routes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

describe "Default routes" do
Expand Down
2 changes: 2 additions & 0 deletions spec/routing/scoped_routes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

describe "Scoped routes" do
Expand Down
2 changes: 2 additions & 0 deletions spec/support/dependencies/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

require "factory_bot"
FactoryBot.find_definitions
2 changes: 2 additions & 0 deletions spec/support/doorkeeper_rspec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
class RSpec
# Print's useful information about env: Ruby / Rails versions,
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/access_token_request_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module AccessTokenRequestHelper
def client_is_authorized(client, resource_owner, access_token_attributes = {})
attributes = {
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/authorization_request_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module AuthorizationRequestHelper
def resource_owner_is_authenticated(resource_owner = nil)
resource_owner ||= User.create!(name: "Joe", password: "sekret")
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/config_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ConfigHelper
def config_is_set(setting, value = nil, &block)
setting_ivar = "@#{setting}"
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/model_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ModelHelper
def client_exists(client_attributes = {})
@client = FactoryBot.create(:application, client_attributes)
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/request_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module RequestSpecHelper
def i_am_logged_in
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) {})
Expand Down
2 changes: 2 additions & 0 deletions spec/support/helpers/url_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module UrlHelper
def token_endpoint_url(options = {})
parameters = {
Expand Down
2 changes: 2 additions & 0 deletions spec/support/http_method_shim.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Rails 5 deprecates calling HTTP action methods with positional arguments
# in favor of keyword arguments. However, the keyword argument form is only
# supported in Rails 5+. Since we support back to 4, we need some sort of shim
Expand Down
2 changes: 2 additions & 0 deletions spec/support/orm/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# load schema to in memory sqlite
ActiveRecord::Migration.verbose = false
load Rails.root + "db/schema.rb"
2 changes: 2 additions & 0 deletions spec/support/shared/controllers_shared_context.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

shared_context "valid token", token: :valid do
let(:token_string) { "1A2B3C4D" }

Expand Down
2 changes: 2 additions & 0 deletions spec/support/shared/models_shared_examples.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

shared_examples "an accessible token" do
describe :accessible? do
it "is accessible if token is not expired" do
Expand Down
2 changes: 2 additions & 0 deletions spec/validators/redirect_uri_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "spec_helper"

describe RedirectUriValidator do
Expand Down

0 comments on commit 625dcd9

Please sign in to comment.