Skip to content

Commit b0fe2f8

Browse files
committed
Upgraded RuboCop to 0.28.0.
1 parent 738c8c0 commit b0fe2f8

File tree

9 files changed

+96
-95
lines changed

9 files changed

+96
-95
lines changed

.rubocop.yml

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,5 @@
11
AllCops:
22
Exclude:
3-
- vendor/**
3+
- vendor/**/*
44

5-
LineLength:
6-
Enabled: false
7-
8-
MethodLength:
9-
Enabled: false
10-
11-
ClassLength:
12-
Enabled: false
13-
14-
Documentation:
15-
# don't require classes to be documented
16-
Enabled: false
17-
18-
CollectionMethods:
19-
# don't prefer map to collect, recuce to inject
20-
Enabled: false
21-
22-
Encoding:
23-
# no need to always specify encoding
24-
Enabled: false
25-
26-
Void:
27-
# == operator used in void context in specs
28-
Enabled: false
29-
30-
SignalException:
31-
# prefer raise to fail
32-
EnforcedStyle: only_raise
33-
34-
RaiseArgs:
35-
# don't care for what kind of raise
36-
Enabled: false
37-
38-
PerlBackrefs:
39-
# TODO: regular expression matching with $1, $2, etc.
40-
Enabled: false
41-
42-
BlockNesting:
43-
# TODO: fix too much nesting
44-
Max: 4
45-
46-
Lambda:
47-
# TODO: replace all lambda with -> or Proc
48-
Enabled: false
49-
50-
Blocks:
51-
# allow multi-line blocks like expect { }
52-
Enabled: false
53-
54-
WordArray:
55-
# %w vs. [ '', ... ]
56-
Enabled: false
57-
58-
CyclomaticComplexity:
59-
Enabled: false
60-
61-
FileName:
62-
# allow grape-entity.rb for a require
63-
Enabled: false
5+
inherit_from: .rubocop_todo.yml

.rubocop_todo.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This configuration was generated by `rubocop --auto-gen-config`
2+
# on 2014-12-11 15:27:22 -0500 using RuboCop version 0.28.0.
3+
# The point is for the user to remove these configuration records
4+
# one by one as the offenses are removed from the code base.
5+
# Note that changes in the inspected code, or installation of new
6+
# versions of RuboCop, may require this file to be generated again.
7+
8+
# Offense count: 5
9+
Metrics/AbcSize:
10+
Max: 53
11+
12+
# Offense count: 1
13+
# Configuration parameters: CountComments.
14+
Metrics/ClassLength:
15+
Max: 292
16+
17+
# Offense count: 4
18+
Metrics/CyclomaticComplexity:
19+
Max: 17
20+
21+
# Offense count: 175
22+
# Configuration parameters: AllowURI, URISchemes.
23+
Metrics/LineLength:
24+
Max: 147
25+
26+
# Offense count: 6
27+
# Configuration parameters: CountComments.
28+
Metrics/MethodLength:
29+
Max: 34
30+
31+
# Offense count: 4
32+
Metrics/PerceivedComplexity:
33+
Max: 15
34+
35+
# Offense count: 2
36+
# Cop supports --auto-correct.
37+
Style/Blocks:
38+
Enabled: false
39+
40+
# Offense count: 30
41+
Style/Documentation:
42+
Enabled: false
43+
44+
# Offense count: 2
45+
Style/EachWithObject:
46+
Enabled: false
47+
48+
# Offense count: 1
49+
# Configuration parameters: Exclude.
50+
Style/FileName:
51+
Enabled: false
52+
53+
# Offense count: 16
54+
Style/Lambda:
55+
Enabled: false
56+
57+
# Offense count: 1
58+
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
59+
Style/Next:
60+
Enabled: false
61+
62+
# Offense count: 2
63+
Style/RegexpLiteral:
64+
MaxSlashes: 0

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ group :development, :test do
1111
gem 'growl'
1212
gem 'json'
1313
gem 'rspec'
14-
gem 'rack-test', "~> 0.6.2", :require => "rack/test"
15-
gem 'rubocop', '0.21.0'
14+
gem 'rack-test', '~> 0.6.2', require: 'rack/test'
15+
gem 'rubocop', '0.28.0'
1616
end

Guardfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# A sample Guardfile
22
# More info at https://github.com/guard/guard#readme
33

4-
guard 'rspec', :version => 2 do
4+
guard 'rspec', version: 2 do
55
watch(%r{^spec/.+_spec\.rb$})
66
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7-
watch(%r{^spec/support/shared_versioning_examples.rb$}) { |m| "spec/" }
8-
watch('spec/spec_helper.rb') { "spec/" }
7+
watch(%r{^spec/support/shared_versioning_examples.rb$}) { |_m| 'spec/' }
8+
watch('spec/spec_helper.rb') { 'spec/' }
99
end
1010

1111
guard 'bundler' do

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ end
1717
task :spec
1818
require 'rainbow/ext/string' unless String.respond_to?(:color)
1919
require 'rubocop/rake_task'
20-
Rubocop::RakeTask.new(:rubocop)
20+
RuboCop::RakeTask.new(:rubocop)
2121

2222
task default: [:rubocop, :spec]

grape-entity.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
88
s.authors = ['Michael Bleigh']
99
s.email = ['michael@intridea.com']
1010
s.homepage = 'https://github.com/intridea/grape-entity'
11-
s.summary = %q(A simple facade for managing the relationship between your model and API.)
12-
s.description = %q(Extracted from Grape, A Ruby framework for rapid API development with great conventions.)
11+
s.summary = 'A simple facade for managing the relationship between your model and API.'
12+
s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
1313
s.license = 'MIT'
1414

1515
s.rubyforge_project = 'grape-entity'

lib/grape_entity/entity.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ def self.expose(*args, &block)
127127
options = merge_options(args.last.is_a?(Hash) ? args.pop : {})
128128

129129
if args.size > 1
130-
raise ArgumentError, 'You may not use the :as option on multi-attribute exposures.' if options[:as]
131-
raise ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given?
130+
fail ArgumentError, 'You may not use the :as option on multi-attribute exposures.' if options[:as]
131+
fail ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given?
132132
end
133133

134-
raise ArgumentError, 'You may not use block-setting when also using format_with' if block_given? && options[:format_with].respond_to?(:call)
134+
fail ArgumentError, 'You may not use block-setting when also using format_with' if block_given? && options[:format_with].respond_to?(:call)
135135

136136
options[:proc] = block if block_given? && block.parameters.any?
137137

@@ -270,7 +270,7 @@ def self.documentation
270270
# end
271271
#
272272
def self.format_with(name, &block)
273-
raise ArgumentError, 'You must pass a block for formatters' unless block_given?
273+
fail ArgumentError, 'You must pass a block for formatters' unless block_given?
274274
formatters[name.to_sym] = block
275275
end
276276

@@ -461,9 +461,9 @@ def serializable_hash(runtime_options = {})
461461
output[self.class.key_for(attribute)] =
462462
if partial_output.respond_to? :serializable_hash
463463
partial_output.serializable_hash(runtime_options)
464-
elsif partial_output.kind_of?(Array) && !partial_output.map { |o| o.respond_to? :serializable_hash }.include?(false)
465-
partial_output.map { |o| o.serializable_hash }
466-
elsif partial_output.kind_of?(Hash)
464+
elsif partial_output.is_a?(Array) && !partial_output.map { |o| o.respond_to? :serializable_hash }.include?(false)
465+
partial_output.map(&:serializable_hash)
466+
elsif partial_output.is_a?(Hash)
467467
partial_output.each do |key, value|
468468
partial_output[key] = value.serializable_hash if value.respond_to? :serializable_hash
469469
end
@@ -566,9 +566,9 @@ def delegate_attribute(attribute)
566566
def valid_exposure?(attribute, exposure_options)
567567
nested_exposures = self.class.nested_exposures_for(attribute)
568568
(nested_exposures.any? && nested_exposures.all? { |a, o| valid_exposure?(a, o) }) || \
569-
exposure_options.key?(:proc) || \
570-
!exposure_options[:safe] || \
571-
object.respond_to?(self.class.name_for(attribute))
569+
exposure_options.key?(:proc) || \
570+
!exposure_options[:safe] || \
571+
object.respond_to?(self.class.name_for(attribute))
572572
end
573573

574574
def conditions_met?(exposure_options, options)
@@ -642,7 +642,7 @@ def self.merge_options(options)
642642
# @param options [Hash] Exposure options.
643643
def self.valid_options(options)
644644
options.keys.each do |key|
645-
raise ArgumentError, "#{key.inspect} is not a valid option." unless OPTIONS.include?(key)
645+
fail ArgumentError, "#{key.inspect} is not a valid option." unless OPTIONS.include?(key)
646646
end
647647

648648
options[:using] = options.delete(:with) if options.key?(:with)

spec/grape_entity/entity_spec.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require 'ostruct'
33

44
describe Grape::Entity do
5-
65
let(:fresh_class) { Class.new(Grape::Entity) }
76

87
context 'class methods' do
@@ -427,7 +426,7 @@ class Parent < Person
427426
representation = subject.represent(4.times.map { Object.new })
428427
expect(representation).to be_kind_of Array
429428
expect(representation.size).to eq(4)
430-
expect(representation.reject { |r| r.kind_of?(subject) }).to be_empty
429+
expect(representation.reject { |r| r.is_a?(subject) }).to be_empty
431430
end
432431

433432
it 'adds the collection: true option if called with a collection' do
@@ -461,9 +460,9 @@ class Parent < Person
461460

462461
it 'raises error if field not found' do
463462
subject.expose(:awesome)
464-
expect {
463+
expect do
465464
subject.represent(Object.new, serializable: true)
466-
}.to raise_error(NoMethodError)
465+
end.to raise_error(NoMethodError)
467466
end
468467
end
469468

@@ -514,7 +513,7 @@ class Parent < Person
514513
expect(representation).to have_key 'things'
515514
expect(representation['things']).to be_kind_of Array
516515
expect(representation['things'].size).to eq 4
517-
expect(representation['things'].reject { |r| r.kind_of?(subject) }).to be_empty
516+
expect(representation['things'].reject { |r| r.is_a?(subject) }).to be_empty
518517
end
519518
end
520519

@@ -523,15 +522,15 @@ class Parent < Person
523522
representation = subject.represent(4.times.map { Object.new }, root: false)
524523
expect(representation).to be_kind_of Array
525524
expect(representation.size).to eq 4
526-
expect(representation.reject { |r| r.kind_of?(subject) }).to be_empty
525+
expect(representation.reject { |r| r.is_a?(subject) }).to be_empty
527526
end
528527
it 'can use a different name' do
529528
representation = subject.represent(4.times.map { Object.new }, root: 'others')
530529
expect(representation).to be_kind_of Hash
531530
expect(representation).to have_key 'others'
532531
expect(representation['others']).to be_kind_of Array
533532
expect(representation['others'].size).to eq 4
534-
expect(representation['others'].reject { |r| r.kind_of?(subject) }).to be_empty
533+
expect(representation['others'].reject { |r| r.is_a?(subject) }).to be_empty
535534
end
536535
end
537536
end
@@ -555,7 +554,7 @@ class Parent < Person
555554
representation = subject.represent(4.times.map { Object.new })
556555
expect(representation).to be_kind_of Array
557556
expect(representation.size).to eq 4
558-
expect(representation.reject { |r| r.kind_of?(subject) }).to be_empty
557+
expect(representation.reject { |r| r.is_a?(subject) }).to be_empty
559558
end
560559
end
561560
end
@@ -578,7 +577,7 @@ class Parent < Person
578577
expect(representation).to have_key('things')
579578
expect(representation['things']).to be_kind_of Array
580579
expect(representation['things'].size).to eq 4
581-
expect(representation['things'].reject { |r| r.kind_of?(subject) }).to be_empty
580+
expect(representation['things'].reject { |r| r.is_a?(subject) }).to be_empty
582581
end
583582
end
584583
end
@@ -597,14 +596,12 @@ class Parent < Person
597596
expect(entity.options).to eq({})
598597
end
599598
end
600-
601599
end
602600

603601
context 'instance methods' do
604-
605602
let(:model) { double(attributes) }
606603

607-
let(:attributes) {
604+
let(:attributes) do
608605
{
609606
name: 'Bob Bobson',
610607
email: 'bob@example.com',
@@ -615,7 +612,7 @@ class Parent < Person
615612
double(name: 'Friend 2', email: 'friend2@example.com', fantasies: [], birthday: Time.gm(2012, 2, 27), friends: [])
616613
]
617614
}
618-
}
615+
end
619616

620617
subject { fresh_class.new(model) }
621618

spec/spec_helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99

1010
require 'pry'
1111

12-
RSpec.configure do |config|
13-
config.raise_errors_for_deprecations!
14-
end
12+
RSpec.configure(&:raise_errors_for_deprecations!)

0 commit comments

Comments
 (0)