Permalink
Browse files

Upgraded Rubocop to 0.15.0.

  • Loading branch information...
1 parent a401b52 commit 90a1f89d539f1ab9ba2f6cb40f21c804f79c941e @dblock dblock committed Nov 24, 2013
Showing with 267 additions and 304 deletions.
  1. +4 −0 .rubocop.yml
  2. +1 −1 Gemfile
  3. +8 −8 lib/grape/api.rb
  4. +0 −2 lib/grape/cookies.rb
  5. +6 −6 lib/grape/endpoint.rb
  6. +0 −3 lib/grape/error_formatter/base.rb
  7. +0 −2 lib/grape/error_formatter/json.rb
  8. +0 −2 lib/grape/error_formatter/txt.rb
  9. +0 −2 lib/grape/error_formatter/xml.rb
  10. +0 −2 lib/grape/exceptions/base.rb
  11. +0 −3 lib/grape/exceptions/incompatible_option_values.rb
  12. +0 −3 lib/grape/exceptions/invalid_formatter.rb
  13. +0 −4 lib/grape/exceptions/invalid_versioner_option.rb
  14. +0 −2 lib/grape/exceptions/invalid_with_option_for_represent.rb
  15. +0 −4 lib/grape/exceptions/missing_mime_type.rb
  16. +0 −3 lib/grape/exceptions/missing_option.rb
  17. +0 −3 lib/grape/exceptions/missing_vendor_option.rb
  18. +0 −4 lib/grape/exceptions/unknown_options.rb
  19. +0 −2 lib/grape/exceptions/unknown_validator.rb
  20. +5 −4 lib/grape/exceptions/validation_errors.rb
  21. +0 −3 lib/grape/formatter/base.rb
  22. +0 −2 lib/grape/formatter/json.rb
  23. +15 −16 lib/grape/formatter/serializable_hash.rb
  24. +0 −2 lib/grape/formatter/txt.rb
  25. +0 −2 lib/grape/formatter/xml.rb
  26. +0 −2 lib/grape/http/request.rb
  27. +0 −1 lib/grape/middleware/base.rb
  28. +0 −2 lib/grape/middleware/error.rb
  29. +80 −82 lib/grape/middleware/formatter.rb
  30. +0 −2 lib/grape/middleware/versioner/accept_version_header.rb
  31. +0 −2 lib/grape/middleware/versioner/header.rb
  32. +0 −1 lib/grape/middleware/versioner/param.rb
  33. +3 −4 lib/grape/middleware/versioner/path.rb
  34. +0 −1 lib/grape/namespace.rb
  35. +0 −3 lib/grape/parser/base.rb
  36. +0 −2 lib/grape/parser/json.rb
  37. +0 −2 lib/grape/parser/xml.rb
  38. +0 −2 lib/grape/path.rb
  39. +0 −3 lib/grape/route.rb
  40. +0 −6 lib/grape/validations.rb
  41. +0 −4 lib/grape/validations/coerce.rb
  42. +0 −2 lib/grape/validations/regexp.rb
  43. +20 −24 spec/grape/api_spec.rb
  44. +12 −12 spec/grape/endpoint_spec.rb
  45. +1 −1 spec/grape/middleware/auth/oauth2_spec.rb
  46. +7 −7 spec/grape/middleware/versioner/param_spec.rb
  47. +21 −11 spec/grape/path_spec.rb
  48. +8 −8 spec/grape/util/hash_stack_spec.rb
  49. +74 −32 spec/grape/validations/coerce_spec.rb
  50. +0 −1 spec/grape/validations/values_spec.rb
  51. +2 −2 spec/grape/validations_spec.rb
View
@@ -64,3 +64,7 @@ Blocks:
WordArray:
# %w vs. [ '', ... ]
Enabled: false
+
+CyclomaticComplexity:
+ Enabled: false
+
View
@@ -16,5 +16,5 @@ group :development, :test do
gem 'cookiejar'
gem 'rack-contrib'
gem 'redcarpet', :platforms => :ruby
- gem 'rubocop', '~> 0.14.1'
+ gem 'rubocop', '~> 0.15.0'
end
View
@@ -213,7 +213,7 @@ def rescue_from(*args, &block)
if handler
args.each do |arg|
- imbue(:rescue_handlers, { arg => handler })
+ imbue :rescue_handlers, arg => handler
end
end
@@ -324,11 +324,12 @@ def mount(mounts)
app_settings.set :mount_path, mount_path
app.inherit_settings(app_settings)
end
- endpoints << Grape::Endpoint.new(settings.clone, {
+ endpoints << Grape::Endpoint.new(
+ settings.clone,
method: :any,
path: path,
app: app
- })
+ )
end
end
@@ -567,21 +568,20 @@ def add_head_not_allowed_methods_and_options_methods
end
allow_header = (['OPTIONS'] | methods).join(', ')
if methods.include?('OPTIONS') || !self.class.settings[:do_not_route_options]
- self.class.options(path, {}) {
+ self.class.options(path, {}) do
header 'Allow', allow_header
status 204
''
- }
+ end
end
not_allowed_methods = %w(GET PUT POST DELETE PATCH HEAD) - methods
not_allowed_methods << 'OPTIONS' if self.class.settings[:do_not_route_options]
- self.class.route(not_allowed_methods, path) {
+ self.class.route(not_allowed_methods, path) do
header 'Allow', allow_header
status 405
''
- }
+ end
end
end
-
end
end
@@ -1,6 +1,5 @@
module Grape
class Cookies
-
def initialize
@cookies = {}
@send_cookies = {}
@@ -36,6 +35,5 @@ def delete(name, opts = {})
options = opts.merge(value: 'deleted', expires: Time.at(0))
self.[]=(name, options)
end
-
end
end
View
@@ -80,7 +80,7 @@ def mount_in(route_set)
route_set.add_route(self, {
path_info: route.route_compiled,
request_method: method,
- }, { route_info: route })
+ }, route_info: route)
end
end
end
@@ -427,11 +427,11 @@ def build_middleware
b.use Rack::Auth::Digest::MD5, settings[:auth][:realm], settings[:auth][:opaque], &settings[:auth][:proc] if settings[:auth] && settings[:auth][:type] == :http_digest
if settings[:version]
- b.use Grape::Middleware::Versioner.using(settings[:version_options][:using]), {
- versions: settings[:version] ? settings[:version].flatten : nil,
- version_options: settings[:version_options],
- prefix: settings[:root_prefix]
- }
+ b.use Grape::Middleware::Versioner.using(settings[:version_options][:using]),
+ versions: settings[:version] ? settings[:version].flatten : nil,
+ version_options: settings[:version_options],
+ prefix: settings[:root_prefix]
+
end
b.use Grape::Middleware::Formatter,
@@ -1,9 +1,7 @@
module Grape
module ErrorFormatter
module Base
-
class << self
-
FORMATTERS = {
serializable_hash: Grape::ErrorFormatter::Json,
json: Grape::ErrorFormatter::Json,
@@ -27,7 +25,6 @@ def formatter_for(api_format, options = {})
spec
end
end
-
end
end
end
@@ -2,15 +2,13 @@ module Grape
module ErrorFormatter
module Json
class << self
-
def call(message, backtrace, options = {}, env = nil)
result = message.is_a?(Hash) ? message : { error: message }
if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
result = result.merge(backtrace: backtrace)
end
MultiJson.dump(result)
end
-
end
end
end
@@ -2,7 +2,6 @@ module Grape
module ErrorFormatter
module Txt
class << self
-
def call(message, backtrace, options = {}, env = nil)
result = message.is_a?(Hash) ? MultiJson.dump(message) : message
if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
@@ -11,7 +10,6 @@ def call(message, backtrace, options = {}, env = nil)
end
result
end
-
end
end
end
@@ -2,15 +2,13 @@ module Grape
module ErrorFormatter
module Xml
class << self
-
def call(message, backtrace, options = {}, env = nil)
result = message.is_a?(Hash) ? message : { message: message }
if (options[:rescue_options] || {})[:backtrace] && backtrace && !backtrace.empty?
result = result.merge(backtrace: backtrace)
end
result.respond_to?(:to_xml) ? result.to_xml(root: :error) : result.to_s
end
-
end
end
end
@@ -1,7 +1,6 @@
module Grape
module Exceptions
class Base < StandardError
-
BASE_MESSAGES_KEY = 'grape.errors.messages'
BASE_ATTRIBUTES_KEY = 'grape.errors.attributes'
FALLBACK_LOCALE = :en
@@ -62,7 +61,6 @@ def translate(key, options = {})
message = ::I18n.translate(key, options)
message.present? ? message : ::I18n.translate(key, options.merge(locale: FALLBACK_LOCALE))
end
-
end
end
end
@@ -2,12 +2,9 @@
module Grape
module Exceptions
class IncompatibleOptionValues < Base
-
def initialize(option1, value1, option2, value2)
super(message: compose_message("incompatible_option_values", option1: option1, value1: value1, option2: option2, value2: value2))
end
-
end
-
end
end
@@ -2,12 +2,9 @@
module Grape
module Exceptions
class InvalidFormatter < Base
-
def initialize(klass, to_format)
super(message: compose_message("invalid_formatter", klass: klass, to_format: to_format))
end
-
end
-
end
end
@@ -1,14 +1,10 @@
# encoding: utf-8
module Grape
module Exceptions
-
class InvalidVersionerOption < Base
-
def initialize(strategy)
super(message: compose_message("invalid_versioner_option", strategy: strategy))
end
-
end
-
end
end
@@ -2,11 +2,9 @@
module Grape
module Exceptions
class InvalidWithOptionForRepresent < Base
-
def initialize
super(message: compose_message("invalid_with_option_for_represent"))
end
-
end
end
end
@@ -2,13 +2,9 @@
module Grape
module Exceptions
class MissingMimeType < Base
-
def initialize(new_format)
super(message: compose_message("missing_mime_type", new_format: new_format))
end
-
end
-
end
-
end
@@ -2,12 +2,9 @@
module Grape
module Exceptions
class MissingOption < Base
-
def initialize(option)
super(message: compose_message("missing_option", option: option))
end
-
end
-
end
end
@@ -2,12 +2,9 @@
module Grape
module Exceptions
class MissingVendorOption < Base
-
def initialize
super(message: compose_message("missing_vendor_option"))
end
-
end
-
end
end
@@ -2,13 +2,9 @@
module Grape
module Exceptions
class UnknownOptions < Base
-
def initialize(options)
super(message: compose_message("unknown_options", options: options))
end
-
end
-
end
-
end
@@ -2,11 +2,9 @@
module Grape
module Exceptions
class UnknownValidator < Base
-
def initialize(validator_type)
super(message: compose_message("unknown_validator", validator_type: validator_type))
end
-
end
end
end
@@ -31,11 +31,12 @@ def full_messages
end
def full_message(attribute, error)
- I18n.t("grape.errors.format".to_sym, {
- default: "%{attribute} %{message}",
+ I18n.t(
+ "grape.errors.format".to_sym,
+ default: "%{attribute} %{message}",
attribute: translate_attribute(attribute),
- message: error.message
- })
+ message: error.message
+ )
end
end
end
@@ -1,9 +1,7 @@
module Grape
module Formatter
module Base
-
class << self
-
FORMATTERS = {
json: Grape::Formatter::Json,
jsonapi: Grape::Formatter::Json,
@@ -27,7 +25,6 @@ def formatter_for(api_format, options = {})
spec
end
end
-
end
end
end
@@ -2,12 +2,10 @@ module Grape
module Formatter
module Json
class << self
-
def call(object, env)
return object.to_json if object.respond_to?(:to_json)
MultiJson.dump(object)
end
-
end
end
end
Oops, something went wrong.

0 comments on commit 90a1f89

Please sign in to comment.