Skip to content

Commit 6d937c9

Browse files
committed
Enable new cops for RuboCop.
1 parent 7e43215 commit 6d937c9

File tree

11 files changed

+37
-50
lines changed

11 files changed

+37
-50
lines changed

.rubocop.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
require:
2-
- rubocop-performance
3-
41
AllCops:
2+
NewCops: enable
53
TargetRubyVersion: 2.4
64
Exclude:
75
- vendor/**/*
86
- bin/**/*
97

8+
require:
9+
- rubocop-performance
10+
1011
inherit_from: .rubocop_todo.yml
1112

1213
Style/Documentation:

.rubocop_todo.yml

Lines changed: 11 additions & 38 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 2020-05-26 08:28:37 -0400 using RuboCop version 0.84.0.
3+
# on 2020-09-30 12:54:06 -0400 using RuboCop version 0.84.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
@@ -13,7 +13,7 @@ Layout/ClosingHeredocIndentation:
1313
- 'spec/grape/api_spec.rb'
1414
- 'spec/grape/entity_spec.rb'
1515

16-
# Offense count: 71
16+
# Offense count: 73
1717
# Cop supports --auto-correct.
1818
Layout/EmptyLineAfterGuardClause:
1919
Enabled: false
@@ -53,43 +53,37 @@ Lint/NonDeterministicRequireOrder:
5353
Exclude:
5454
- 'spec/spec_helper.rb'
5555

56-
# Offense count: 1
57-
# Cop supports --auto-correct.
58-
Lint/RedundantCopDisableDirective:
59-
Exclude:
60-
- 'lib/grape/router/attribute_translator.rb'
61-
6256
# Offense count: 2
6357
# Cop supports --auto-correct.
6458
Lint/ToJSON:
6559
Exclude:
6660
- 'spec/grape/middleware/formatter_spec.rb'
6761

68-
# Offense count: 47
62+
# Offense count: 50
6963
# Configuration parameters: IgnoredMethods.
7064
Metrics/AbcSize:
71-
Max: 44
65+
Max: 43
7266

7367
# Offense count: 6
7468
# Configuration parameters: CountComments, ExcludedMethods.
7569
# ExcludedMethods: refine
7670
Metrics/BlockLength:
7771
Max: 182
7872

79-
# Offense count: 10
73+
# Offense count: 11
8074
# Configuration parameters: CountComments.
8175
Metrics/ClassLength:
82-
Max: 305
76+
Max: 304
8377

8478
# Offense count: 30
8579
# Configuration parameters: IgnoredMethods.
8680
Metrics/CyclomaticComplexity:
8781
Max: 14
8882

89-
# Offense count: 61
83+
# Offense count: 69
9084
# Configuration parameters: CountComments, ExcludedMethods.
9185
Metrics/MethodLength:
92-
Max: 36
86+
Max: 32
9387

9488
# Offense count: 12
9589
# Configuration parameters: CountComments.
@@ -120,13 +114,6 @@ Naming/MethodParameterName:
120114
- 'lib/grape/middleware/stack.rb'
121115
- 'spec/grape/api_spec.rb'
122116

123-
# Offense count: 1
124-
# Cop supports --auto-correct.
125-
# Configuration parameters: PreferredName.
126-
Naming/RescuedExceptionsVariableName:
127-
Exclude:
128-
- 'lib/grape/middleware/error.rb'
129-
130117
# Offense count: 3
131118
# Cop supports --auto-correct.
132119
Performance/InefficientHashSearch:
@@ -157,25 +144,20 @@ Style/ExpandPathArguments:
157144
Style/FormatStringToken:
158145
EnforcedStyle: template
159146

160-
# Offense count: 23
147+
# Offense count: 19
161148
# Cop supports --auto-correct.
162149
Style/IfUnlessModifier:
163150
Exclude:
164151
- 'lib/grape/api/instance.rb'
165152
- 'lib/grape/dsl/desc.rb'
166153
- 'lib/grape/dsl/request_response.rb'
167-
- 'lib/grape/dsl/routing.rb'
168154
- 'lib/grape/dsl/settings.rb'
169155
- 'lib/grape/endpoint.rb'
170156
- 'lib/grape/error_formatter/json.rb'
171157
- 'lib/grape/error_formatter/xml.rb'
172-
- 'lib/grape/middleware/error.rb'
173158
- 'lib/grape/middleware/formatter.rb'
174159
- 'lib/grape/middleware/versioner/accept_version_header.rb'
175160
- 'lib/grape/validations/params_scope.rb'
176-
- 'lib/grape/validations/validators/base.rb'
177-
- 'lib/grape/validations/validators/default.rb'
178-
- 'spec/support/versioned_helpers.rb'
179161

180162
# Offense count: 1
181163
Style/MethodMissingSuper:
@@ -191,7 +173,7 @@ Style/NumericPredicate:
191173
- 'spec/**/*'
192174
- 'lib/grape/middleware/formatter.rb'
193175

194-
# Offense count: 11
176+
# Offense count: 10
195177
# Cop supports --auto-correct.
196178
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
197179
# AllowedMethods: present?, blank?, presence, try, try!
@@ -202,18 +184,9 @@ Style/SafeNavigation:
202184
- 'lib/grape/dsl/inside_route.rb'
203185
- 'lib/grape/dsl/request_response.rb'
204186
- 'lib/grape/endpoint.rb'
205-
- 'lib/grape/middleware/error.rb'
206187
- 'lib/grape/middleware/versioner/accept_version_header.rb'
207188
- 'lib/grape/middleware/versioner/header.rb'
208189

209-
# Offense count: 2
210-
# Cop supports --auto-correct.
211-
# Configuration parameters: EnforcedStyleForMultiline.
212-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
213-
Style/TrailingCommaInHashLiteral:
214-
Exclude:
215-
- 'lib/grape/middleware/error.rb'
216-
217190
# Offense count: 10
218191
# Cop supports --auto-correct.
219192
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
@@ -223,7 +196,7 @@ Style/WordArray:
223196
- 'spec/grape/validations/validators/except_values_spec.rb'
224197
- 'spec/grape/validations/validators/values_spec.rb'
225198

226-
# Offense count: 125
199+
# Offense count: 131
227200
# Cop supports --auto-correct.
228201
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
229202
# URISchemes: http, https

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
source 'https://rubygems.org'
5+
source('https://rubygems.org')
66

77
gemspec
88

Rakefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

3-
require 'rubygems'
4-
require 'bundler'
5-
Bundler.setup :default, :test, :development
3+
require('rubygems')
4+
require('bundler')
5+
Bundler.setup(:default, :test, :development)
66

77
Bundler::GemHelper.install_tasks
88

9-
require 'rspec/core/rake_task'
9+
require('rspec/core/rake_task')
1010
RSpec::Core::RakeTask.new(:spec) do |spec|
1111
spec.pattern = 'spec/**/*_spec.rb'
1212
spec.exclude_pattern = 'spec/integration/**/*_spec.rb'
@@ -17,11 +17,11 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
1717
spec.rcov = true
1818
end
1919

20-
task :spec
20+
task(:spec)
2121

22-
require 'rainbow/ext/string' unless String.respond_to?(:color)
22+
require('rainbow/ext/string') unless String.respond_to?(:color)
2323

24-
require 'rubocop/rake_task'
24+
require('rubocop/rake_task')
2525
RuboCop::RakeTask.new
2626

27-
task default: %i[rubocop spec]
27+
task(default: %i[rubocop spec])

benchmark/remounting.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/memory'

lib/grape/dsl/helpers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def inject_api_helpers_to_mod(mod, &_block)
8181
# to provide some API-specific functionality.
8282
module BaseHelper
8383
attr_accessor :api
84+
8485
def params(name, &block)
8586
@named_params ||= {}
8687
@named_params[name] = block

lib/grape/middleware/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Base
88
include Helpers
99

1010
attr_reader :app, :env, :options
11+
1112
TEXT_HTML = 'text/html'
1213

1314
include Grape::DSL::Headers

lib/grape/util/lazy_value.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Grape
44
module Util
55
class LazyValue
66
attr_reader :access_keys
7+
78
def initialize(value, access_keys = [])
89
@value = value
910
@access_keys = access_keys

spec/grape/entity_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def first
181181
subject.get '/example' do
182182
c = Class.new do
183183
attr_reader :id
184+
184185
def initialize(id)
185186
@id = id
186187
end
@@ -202,6 +203,7 @@ def initialize(id)
202203
subject.get '/examples' do
203204
c = Class.new do
204205
attr_reader :id
206+
205207
def initialize(id)
206208
@id = id
207209
end
@@ -226,6 +228,7 @@ def initialize(id)
226228
subject.get '/example' do
227229
c = Class.new do
228230
attr_reader :name
231+
229232
def initialize(args)
230233
@name = args[:name] || 'no name set'
231234
end
@@ -255,6 +258,7 @@ def initialize(args)
255258
subject.get '/example' do
256259
c = Class.new do
257260
attr_reader :name
261+
258262
def initialize(args)
259263
@name = args[:name] || 'no name set'
260264
end
@@ -284,6 +288,7 @@ def initialize(args)
284288
subject.get '/example' do
285289
c = Class.new do
286290
attr_reader :name
291+
287292
def initialize(args)
288293
@name = args[:name] || 'no name set'
289294
end
@@ -302,6 +307,7 @@ def initialize(args)
302307
it 'present with multiple entities using optional symbol' do
303308
user = Class.new do
304309
attr_reader :name
310+
305311
def initialize(args)
306312
@name = args[:name] || 'no name set'
307313
end

spec/grape/middleware/stack_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class FooMiddleware; end
88
class BarMiddleware; end
99
class BlockMiddleware
1010
attr_reader :block
11+
1112
def initialize(&block)
1213
@block = block
1314
end

spec/grape/validations/validators/except_values_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ExceptValuesModel
88
DEFAULT_EXCEPTS = ['invalid-type1', 'invalid-type2', 'invalid-type3'].freeze
99
class << self
1010
attr_accessor :excepts
11+
1112
def excepts
1213
@excepts ||= []
1314
[DEFAULT_EXCEPTS + @excepts].flatten.uniq

0 commit comments

Comments
 (0)