Skip to content

Commit 5154b36

Browse files
committed
Upgraded RuboCop to 0.33.0.
1 parent 96b516e commit 5154b36

39 files changed

+150
-189
lines changed

.rubocop_todo.yml

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
1-
# This configuration was generated by `rubocop --auto-gen-config`
2-
# on 2015-06-04 09:15:17 -0400 using RuboCop version 0.31.0.
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2015-08-19 13:28:59 -0400 using RuboCop version 0.33.0.
34
# The point is for the user to remove these configuration records
45
# one by one as the offenses are removed from the code base.
56
# Note that changes in the inspected code, or installation of new
67
# versions of RuboCop, may require this file to be generated again.
78

9+
# Offense count: 1
10+
Lint/NestedMethodDefinition:
11+
Exclude:
12+
- 'lib/grape/util/strict_hash_configuration.rb'
13+
814
# Offense count: 37
915
Metrics/AbcSize:
10-
Max: 48
16+
Max: 46
1117

12-
# Offense count: 2
18+
# Offense count: 1
1319
Metrics/BlockNesting:
1420
Max: 4
1521

16-
# Offense count: 4
22+
# Offense count: 5
1723
# Configuration parameters: CountComments.
1824
Metrics/ClassLength:
19-
Max: 252
25+
Max: 249
2026

2127
# Offense count: 23
2228
Metrics/CyclomaticComplexity:
23-
Max: 20
29+
Max: 16
2430

25-
# Offense count: 675
31+
# Offense count: 717
2632
# Configuration parameters: AllowURI, URISchemes.
2733
Metrics/LineLength:
28-
Max: 198
34+
Max: 215
2935

30-
# Offense count: 44
36+
# Offense count: 42
3137
# Configuration parameters: CountComments.
3238
Metrics/MethodLength:
3339
Max: 35
@@ -39,46 +45,34 @@ Metrics/ModuleLength:
3945

4046
# Offense count: 17
4147
Metrics/PerceivedComplexity:
42-
Max: 22
48+
Max: 18
4349

44-
# Offense count: 26
50+
# Offense count: 30
4551
# Cop supports --auto-correct.
4652
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
4753
Style/BlockDelimiters:
4854
Enabled: false
4955

50-
# Offense count: 174
56+
# Offense count: 167
5157
Style/Documentation:
5258
Enabled: false
5359

5460
# Offense count: 7
5561
Style/DoubleNegation:
56-
Enabled: false
57-
58-
# Offense count: 5
59-
Style/EachWithObject:
60-
Enabled: false
61-
62-
# Offense count: 15
63-
# Configuration parameters: MinBodyLength.
64-
Style/GuardClause:
65-
Enabled: false
66-
67-
# Offense count: 4
68-
# Cop supports --auto-correct.
69-
Style/Lambda:
70-
Enabled: false
71-
72-
# Offense count: 3
73-
Style/MultilineTernaryOperator:
74-
Enabled: false
62+
Exclude:
63+
- 'lib/grape/api.rb'
64+
- 'lib/grape/middleware/versioner/accept_version_header.rb'
65+
- 'lib/grape/middleware/versioner/header.rb'
66+
- 'lib/grape/path.rb'
7567

7668
# Offense count: 3
77-
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
78-
Style/PredicateName:
79-
Enabled: false
69+
Style/EachWithObject:
70+
Exclude:
71+
- 'lib/grape/dsl/inside_route.rb'
72+
- 'lib/grape/exceptions/base.rb'
73+
- 'lib/grape/formatter/serializable_hash.rb'
8074

81-
# Offense count: 13
75+
# Offense count: 14
8276
# Configuration parameters: EnforcedStyle, SupportedStyles.
8377
Style/RaiseArgs:
8478
Enabled: false

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
33
gemspec
44

55
group :development, :test do
6-
gem 'rubocop', '~> 0.31.0'
6+
gem 'rubocop', '0.33.0'
77
gem 'guard'
88
gem 'guard-rspec'
99
gem 'guard-rubocop'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ Custom error formatters for existing and additional types can be defined with a
15041504

15051505
```ruby
15061506
class Twitter::API < Grape::API
1507-
error_formatter :txt, lambda { |message, backtrace, options, env|
1507+
error_formatter :txt, ->(message, backtrace, options, env) {
15081508
"error: #{message} from #{backtrace}"
15091509
}
15101510
end
@@ -1818,7 +1818,7 @@ Custom formatters for existing and additional types can be defined with a proc.
18181818
```ruby
18191819
class Twitter::API < Grape::API
18201820
content_type :xls, "application/vnd.ms-excel"
1821-
formatter :xls, lambda { |object, env| object.to_xls }
1821+
formatter :xls, ->(object, env) { object.to_xls }
18221822
end
18231823
```
18241824

@@ -1956,7 +1956,7 @@ module API
19561956
expose :user_name
19571957
expose :text, documentation: { type: "string", desc: "Status update text." }
19581958
expose :ip, if: { type: :full }
1959-
expose :user_type, :user_id, if: lambda { |status, options| status.user.public? }
1959+
expose :user_type, :user_id, if: ->(status, options) { status.user.public? }
19601960
expose :digest { |status, options| Digest::MD5.hexdigest(status.txt) }
19611961
expose :replies, using: API::Status, as: :replies
19621962
end

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ begin
2727
DOC_FILES = ['lib/**/*.rb', 'README.md']
2828

2929
YARD::Rake::YardocTask.new(:doc) do |t|
30-
t.files = DOC_FILES
30+
t.files = DOC_FILES
3131
end
3232

3333
namespace :doc do

lib/grape/dsl/helpers.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ def api_changed(new_api)
7575
protected
7676

7777
def process_named_params
78-
if @named_params && @named_params.any?
79-
api.namespace_stackable(:named_params, @named_params)
80-
end
78+
return unless @named_params && @named_params.any?
79+
api.namespace_stackable(:named_params, @named_params)
8180
end
8281
end
8382
end

lib/grape/dsl/inside_route.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@ def declared(params, options = {}, declared_params = nil)
1919
options[:include_missing] = true unless options.key?(:include_missing)
2020
options[:include_parent_namespaces] = true unless options.key?(:include_parent_namespaces)
2121

22-
if declared_params.nil?
23-
declared_params = (!options[:include_parent_namespaces] ? route_setting(:declared_params) :
24-
(route_setting(:saved_declared_params) || [])).flatten(1) || []
25-
end
22+
declared_params ||= (!options[:include_parent_namespaces] ? route_setting(:declared_params) : (route_setting(:saved_declared_params) || [])).flatten(1) || []
2623

27-
unless declared_params
28-
fail ArgumentError, 'Tried to filter for declared parameters but none exist.'
29-
end
24+
fail ArgumentError, 'Tried to filter for declared parameters but none exist.' unless declared_params
3025

3126
if params.is_a? Array
3227
params.map do |param|

lib/grape/dsl/parameters.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def requires(*attrs, &block)
9494
else
9595
validate_attributes(attrs, opts, &block)
9696

97-
block_given? ? new_scope(orig_attrs, &block) :
98-
push_declared_params(attrs)
97+
block_given? ? new_scope(orig_attrs, &block) : push_declared_params(attrs)
9998
end
10099
end
101100

@@ -120,8 +119,7 @@ def optional(*attrs, &block)
120119
else
121120
validate_attributes(attrs, opts, &block)
122121

123-
block_given? ? new_scope(orig_attrs, true, &block) :
124-
push_declared_params(attrs)
122+
block_given? ? new_scope(orig_attrs, true, &block) : push_declared_params(attrs)
125123
end
126124
end
127125

lib/grape/dsl/routing.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def mount(mounts)
7676

7777
if app.respond_to?(:inheritable_setting, true)
7878
mount_path = Rack::Mount::Utils.normalize_path(path)
79-
app.top_level_setting.namespace_stackable[:mount_path] = mount_path
79+
app.top_level_setting.namespace_stackable[:mount_path] = mount_path
8080

8181
app.inherit_settings(inheritable_setting)
8282

lib/grape/endpoint.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def initialize(new_settings, options = {}, &block)
7474
@options[:method] = Array(options[:method])
7575
@options[:route_options] ||= {}
7676

77-
if block_given?
78-
@source = block
79-
@block = self.class.generate_api_method(method_name, &block)
80-
end
77+
return unless block_given?
78+
79+
@source = block
80+
@block = self.class.generate_api_method(method_name, &block)
8181
end
8282

8383
def require_option(options, key)
@@ -119,7 +119,7 @@ def mount_in(route_set)
119119
route_set.add_route(self, {
120120
path_info: route.route_compiled,
121121
request_method: method
122-
}, route_info: route)
122+
}, route_info: route)
123123
end
124124
end
125125
end

lib/grape/middleware/auth/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _call(env)
2626
auth_proc = options[:proc]
2727
auth_proc_context = context
2828

29-
strategy_info = Grape::Middleware::Auth::Strategies[options[:type]]
29+
strategy_info = Grape::Middleware::Auth::Strategies[options[:type]]
3030

3131
throw(:error, status: 401, message: 'API Authorization Failed.') unless strategy_info.present?
3232

0 commit comments

Comments
 (0)