Skip to content

Commit f1f4e0d

Browse files
committed
Rubocop target version now 2.4 (following gemspec)
Rubocop autocorrect frozen_string_literal Contribution Fixed frozen_string in subject Fix frozen body in spec
1 parent 41dced0 commit f1f4e0d

File tree

261 files changed

+612
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+612
-56
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.1
2+
TargetRubyVersion: 2.4
33
Include:
44
- Dangerfile
55
- gemfiles/*.gemfile

.rubocop_todo.yml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-12-20 21:38:24 +0000 using RuboCop version 0.51.0.
3+
# on 2019-12-09 18:07:42 +0100 using RuboCop version 0.51.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -26,41 +26,47 @@ Lint/RescueWithoutErrorClass:
2626
Exclude:
2727
- 'lib/grape/validations/validators/coerce.rb'
2828

29-
# Offense count: 47
29+
# Offense count: 1
30+
# Cop supports --auto-correct.
31+
Lint/UnneededRequireStatement:
32+
Exclude:
33+
- 'lib/grape.rb'
34+
35+
# Offense count: 46
3036
Metrics/AbcSize:
3137
Max: 44
3238

33-
# Offense count: 4
39+
# Offense count: 7
3440
# Configuration parameters: CountComments, ExcludedMethods.
3541
Metrics/BlockLength:
3642
Max: 182
3743

38-
# Offense count: 9
44+
# Offense count: 10
3945
# Configuration parameters: CountComments.
4046
Metrics/ClassLength:
4147
Max: 302
4248

43-
# Offense count: 31
49+
# Offense count: 30
4450
Metrics/CyclomaticComplexity:
4551
Max: 14
4652

47-
# Offense count: 1234
53+
# Offense count: 1300
4854
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
4955
# URISchemes: http, https
5056
Metrics/LineLength:
5157
Max: 215
5258

53-
# Offense count: 57
59+
# Offense count: 60
5460
# Configuration parameters: CountComments.
5561
Metrics/MethodLength:
56-
Max: 34
62+
Max: 33
5763

5864
# Offense count: 12
5965
# Configuration parameters: CountComments.
6066
Metrics/ModuleLength:
6167
Max: 220
6268

63-
# Offense count: 21
69+
# Offense count: 22
6470
Metrics/PerceivedComplexity:
6571
Max: 14
6672

@@ -74,8 +80,40 @@ Naming/FileName:
7480
- 'Guardfile'
7581
- 'Rakefile'
7682

83+
# Offense count: 1
84+
# Cop supports --auto-correct.
85+
Performance/RegexpMatch:
86+
Exclude:
87+
- 'lib/grape/middleware/versioner/path.rb'
88+
7789
# Offense count: 2
7890
# Configuration parameters: SupportedStyles.
7991
# SupportedStyles: annotated, template
8092
Style/FormatStringToken:
8193
EnforcedStyle: template
94+
95+
# Offense count: 1
96+
# Cop supports --auto-correct.
97+
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
98+
# SupportedStyles: predicate, comparison
99+
Style/NumericPredicate:
100+
Exclude:
101+
- 'spec/**/*'
102+
- 'lib/grape/middleware/formatter.rb'
103+
104+
# Offense count: 12
105+
# Cop supports --auto-correct.
106+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
107+
Style/SafeNavigation:
108+
Exclude:
109+
- 'lib/grape/api/instance.rb'
110+
- 'lib/grape/dsl/desc.rb'
111+
- 'lib/grape/dsl/helpers.rb'
112+
- 'lib/grape/dsl/inside_route.rb'
113+
- 'lib/grape/dsl/routing.rb'
114+
- 'lib/grape/endpoint.rb'
115+
- 'lib/grape/middleware/error.rb'
116+
- 'lib/grape/middleware/versioner/accept_version_header.rb'
117+
- 'lib/grape/middleware/versioner/header.rb'
118+
- 'lib/grape/middleware/versioner/param.rb'
119+
- 'lib/grape/middleware/versioner/path.rb'

Appraisals

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
appraise 'rails-5' do
24
gem 'rails', '5.2.1'
35
end

CHANGELOG.md

Lines changed: 1 addition & 0 deletions

Dangerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
danger.import_dangerfile(gem: 'ruby-grape-danger')
24
toc.check

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# when changing this file, run appraisal install ; rubocop -a gemfiles/*.gemfile
24

35
source 'https://rubygems.org'

Guardfile

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

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'rubygems'
24
require 'bundler'
35
Bundler.setup :default, :test, :development

benchmark/nested_params.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'grape'
24
require 'benchmark/ips'
35

benchmark/simple.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
24
require 'grape'
35
require 'benchmark/ips'

benchmark/simple_with_type_coercer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
24
require 'grape'
35
require 'benchmark/ips'

gemfiles/multi_json.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source 'https://rubygems.org'

gemfiles/multi_xml.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source 'https://rubygems.org'

gemfiles/rack_edge.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source 'https://rubygems.org'

gemfiles/rails_5.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source 'https://rubygems.org'

gemfiles/rails_edge.gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
# This file was generated by Appraisal
24

35
source 'https://rubygems.org'

grape.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
24
require 'grape/version'
35

lib/grape.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'logger'
24
require 'rack'
35
require 'rack/builder'

lib/grape/api.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'grape/router'
24
require 'grape/api/instance'
35

lib/grape/api/helpers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
class API
35
module Helpers

lib/grape/api/instance.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'grape/router'
24

35
module Grape

lib/grape/config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module Config
35
class Configuration

lib/grape/cookies.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
class Cookies
35
def initialize

lib/grape/dsl/api.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/callbacks.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/configuration.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/desc.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module DSL
35
module Desc

lib/grape/dsl/headers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module DSL
35
module Headers

lib/grape/dsl/helpers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/inside_route.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24
require 'grape/dsl/headers'
35

lib/grape/dsl/logger.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module DSL
35
module Logger

lib/grape/dsl/middleware.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/parameters.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/request_response.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/routing.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/settings.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/dsl/validations.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'active_support/concern'
24

35
module Grape

lib/grape/eager_load.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
Grape.eager_load!
24
Grape::Http.eager_load!
35
Grape::Exceptions.eager_load!

lib/grape/endpoint.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
# An Endpoint is the proxy scope in which all routing
35
# blocks are executed. In other words, any methods

lib/grape/error_formatter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module ErrorFormatter
35
extend Util::Registrable

lib/grape/error_formatter/base.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module ErrorFormatter
35
module Base

lib/grape/error_formatter/json.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module ErrorFormatter
35
module Json

lib/grape/error_formatter/txt.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module ErrorFormatter
35
module Txt

lib/grape/error_formatter/xml.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module ErrorFormatter
35
module Xml

lib/grape/exceptions/base.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module Exceptions
35
class Base < StandardError
4-
BASE_MESSAGES_KEY = 'grape.errors.messages'.freeze
5-
BASE_ATTRIBUTES_KEY = 'grape.errors.attributes'.freeze
6+
BASE_MESSAGES_KEY = 'grape.errors.messages'
7+
BASE_ATTRIBUTES_KEY = 'grape.errors.attributes'
68
FALLBACK_LOCALE = :en
79

810
attr_reader :status, :message, :headers
@@ -28,7 +30,7 @@ def compose_message(key, **attributes)
2830
@problem = problem(key, **attributes)
2931
@summary = summary(key, **attributes)
3032
@resolution = resolution(key, **attributes)
31-
[['Problem', @problem], ['Summary', @summary], ['Resolution', @resolution]].reduce('') do |message, detail_array|
33+
[['Problem', @problem], ['Summary', @summary], ['Resolution', @resolution]].each_with_object(+'') do |detail_array, message|
3234
message << "\n#{detail_array[0]}:\n #{detail_array[1]}" unless detail_array[1].blank?
3335
message
3436
end

lib/grape/exceptions/incompatible_option_values.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module Exceptions
35
class IncompatibleOptionValues < Base

lib/grape/exceptions/invalid_accept_header.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Grape
24
module Exceptions
35
class InvalidAcceptHeader < Base

0 commit comments

Comments
 (0)