Skip to content

Commit

Permalink
Merge feaf8dc into 090326e
Browse files Browse the repository at this point in the history
  • Loading branch information
ericproulx committed Oct 29, 2019
2 parents 090326e + feaf8dc commit caf6afb
Show file tree
Hide file tree
Showing 258 changed files with 605 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 2.1
TargetRubyVersion: 2.3
Include:
- Dangerfile
- gemfiles/*.gemfile
Expand Down
48 changes: 40 additions & 8 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-12-20 21:38:24 +0000 using RuboCop version 0.51.0.
# on 2019-10-27 10:47:06 -0400 using RuboCop version 0.51.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -26,16 +26,22 @@ Lint/RescueWithoutErrorClass:
Exclude:
- 'lib/grape/validations/validators/coerce.rb'

# Offense count: 47
# Offense count: 1
# Cop supports --auto-correct.
Lint/UnneededRequireStatement:
Exclude:
- 'lib/grape.rb'

# Offense count: 48
Metrics/AbcSize:
Max: 44

# Offense count: 4
# Offense count: 6
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 182

# Offense count: 9
# Offense count: 10
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 302
Expand All @@ -44,23 +50,23 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 14

# Offense count: 1234
# Offense count: 1287
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 215

# Offense count: 57
# Offense count: 59
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 34
Max: 33

# Offense count: 12
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 220

# Offense count: 21
# Offense count: 22
Metrics/PerceivedComplexity:
Max: 14

Expand All @@ -79,3 +85,29 @@ Naming/FileName:
# SupportedStyles: annotated, template
Style/FormatStringToken:
EnforcedStyle: template

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'lib/grape/middleware/formatter.rb'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
Style/SafeNavigation:
Exclude:
- 'lib/grape/api/instance.rb'
- 'lib/grape/dsl/desc.rb'
- 'lib/grape/dsl/helpers.rb'
- 'lib/grape/dsl/inside_route.rb'
- 'lib/grape/dsl/routing.rb'
- 'lib/grape/endpoint.rb'
- 'lib/grape/middleware/error.rb'
- 'lib/grape/middleware/versioner/accept_version_header.rb'
- 'lib/grape/middleware/versioner/header.rb'
- 'lib/grape/middleware/versioner/param.rb'
- 'lib/grape/middleware/versioner/path.rb'
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' do
gem 'rails', '5.2.1'
end
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [#1904](https://github.com/ruby-grape/grape/pull/1904): Allows Grape to load files on startup rather than on the first call - [@myxoh](https://github.com/myxoh).
* [#1907](https://github.com/ruby-grape/grape/pull/1907): Adds outside configuration to Grape with `configure` - [@unleashy](https://github.com/unleashy).
* [#1914](https://github.com/ruby-grape/grape/pull/1914): Run specs in random order - [@splattael](https://github.com/splattael).
* [#1790](https://github.com/ruby-grape/grape/pull/1790): Added frozen_string_literal - [@ericproulx](https://github.com/ericproulx).

#### Fixes

Expand Down
2 changes: 2 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

danger.import_dangerfile(gem: 'ruby-grape-danger')
toc.check
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

# when changing this file, run appraisal install ; rubocop -a gemfiles/*.gemfile

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

guard :rspec, all_on_start: true, cmd: 'bundle exec rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rubygems'
require 'bundler'
Bundler.setup :default, :test, :development
Expand Down
2 changes: 2 additions & 0 deletions benchmark/nested_params.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'grape'
require 'benchmark/ips'

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

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'grape'
require 'benchmark/ips'
Expand Down
2 changes: 2 additions & 0 deletions benchmark/simple_with_type_coercer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'grape'
require 'benchmark/ips'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/multi_json.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/multi_xml.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rack_edge.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_5.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_edge.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by Appraisal

source 'https://rubygems.org'
Expand Down
2 changes: 2 additions & 0 deletions grape.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'grape/version'

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

require 'logger'
require 'rack'
require 'rack/builder'
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'grape/router'
require 'grape/api/instance'

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

module Grape
class API
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/api/instance.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'grape/router'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module Config
class Configuration
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/cookies.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
class Cookies
def initialize
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/api.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/callbacks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/desc.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module DSL
module Desc
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/headers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module DSL
module Headers
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/inside_route.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'
require 'grape/dsl/headers'

Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/logger.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module DSL
module Logger
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/middleware.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/parameters.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/request_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/routing.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/dsl/validations.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/concern'

module Grape
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/eager_load.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Grape.eager_load!
Grape::Http.eager_load!
Grape::Exceptions.eager_load!
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/endpoint.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
# An Endpoint is the proxy scope in which all routing
# blocks are executed. In other words, any methods
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/error_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module ErrorFormatter
extend Util::Registrable
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/error_formatter/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module ErrorFormatter
module Base
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/error_formatter/json.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module ErrorFormatter
module Json
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/error_formatter/txt.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module ErrorFormatter
module Txt
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/error_formatter/xml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module ErrorFormatter
module Xml
Expand Down
11 changes: 6 additions & 5 deletions lib/grape/exceptions/base.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

module Grape
module Exceptions
class Base < StandardError
BASE_MESSAGES_KEY = 'grape.errors.messages'.freeze
BASE_ATTRIBUTES_KEY = 'grape.errors.attributes'.freeze
BASE_MESSAGES_KEY = 'grape.errors.messages'
BASE_ATTRIBUTES_KEY = 'grape.errors.attributes'
FALLBACK_LOCALE = :en

attr_reader :status, :message, :headers
Expand All @@ -28,9 +30,8 @@ def compose_message(key, **attributes)
@problem = problem(key, **attributes)
@summary = summary(key, **attributes)
@resolution = resolution(key, **attributes)
[['Problem', @problem], ['Summary', @summary], ['Resolution', @resolution]].reduce('') do |message, detail_array|
message << "\n#{detail_array[0]}:\n #{detail_array[1]}" unless detail_array[1].blank?
message
[['Problem', @problem], ['Summary', @summary], ['Resolution', @resolution]].each_with_object(+'') do |detail_array, final_message|
final_message << "\n#{detail_array[0]}:\n #{detail_array[1]}" unless detail_array[1].blank?
end
else
short_message
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/exceptions/incompatible_option_values.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module Exceptions
class IncompatibleOptionValues < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/exceptions/invalid_accept_header.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module Exceptions
class InvalidAcceptHeader < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/grape/exceptions/invalid_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Grape
module Exceptions
class InvalidFormatter < Base
Expand Down
Loading

0 comments on commit caf6afb

Please sign in to comment.