Skip to content

Commit 1443468

Browse files
committed
Updates travis matrix ...
- changed to some rubocop suggestions
1 parent 05d743b commit 1443468

13 files changed

+85
-79
lines changed

Diff for: .rubocop.yml

+33-22
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
AllCops:
4+
Exclude:
5+
- vendor/**/*
6+
- example/**/*
27
TargetRubyVersion: 2.4
3-
Include:
4-
- Dangerfile
58

9+
Layout/EmptyLinesAroundArguments:
10+
Enabled: false
11+
12+
Layout/IndentHash:
13+
EnforcedStyle: consistent
14+
15+
Metrics/AbcSize:
16+
Max: 25
17+
18+
Metrics/BlockLength:
619
Exclude:
7-
- vendor/**/*
8-
- bin/**/*
9-
- Guardfile
20+
- spec/**/*
1021

11-
inherit_from: .rubocop_todo.yml
22+
Metrics/CyclomaticComplexity:
23+
Max: 10
1224

13-
Gemspec/RequiredRubyVersion:
14-
Enabled: false
25+
Metrics/ClassLength:
26+
Max: 300
1527

16-
Naming/FileName:
28+
Metrics/LineLength:
29+
Max: 120
1730
Exclude:
18-
- 'Gemfile'
19-
- 'Rakefile'
20-
- 'grape-entity.gemspec'
21-
- 'lib/grape-entity.rb'
31+
- spec/**/*
2232

23-
Style/Documentation:
24-
Enabled: false
33+
Metrics/MethodLength:
34+
Max: 26
35+
Exclude:
36+
- spec/**/*
2537

26-
Style/MultilineIfModifier:
27-
Enabled: false
38+
Metrics/PerceivedComplexity:
39+
Max: 11
2840

29-
Style/RaiseArgs:
41+
Naming:
3042
Enabled: false
3143

32-
Lint/BooleanSymbol:
33-
Exclude:
34-
- 'spec/grape_entity/exposure_spec.rb'
44+
Style/Documentation:
45+
Enabled: false
3546

36-
Lint/UnneededDisable:
47+
Style/RegexpLiteral:
3748
Enabled: false

Diff for: .rubocop_todo.yml

+12-43
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,34 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2018-03-28 21:26:18 +0200 using RuboCop version 0.54.0.
3+
# on 2019-03-15 00:00:57 +0100 using RuboCop version 0.65.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
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 1
10-
Lint/AmbiguousBlockAssociation:
9+
# Offense count: 6
10+
Lint/BooleanSymbol:
1111
Exclude:
12-
- 'spec/grape_entity/exposure/represent_exposure_spec.rb'
13-
14-
# Offense count: 5
15-
Metrics/AbcSize:
16-
Max: 25
12+
- 'spec/grape_entity/exposure_spec.rb'
1713

18-
# Offense count: 39
19-
# Configuration parameters: CountComments, ExcludedMethods.
20-
Metrics/BlockLength:
21-
Max: 1632
2214

23-
# Offense count: 1
24-
# Configuration parameters: CountComments.
25-
Metrics/ClassLength:
26-
Max: 205
27-
28-
# Offense count: 1
29-
Metrics/CyclomaticComplexity:
30-
Max: 10
31-
32-
# Offense count: 6
33-
# Configuration parameters: CountComments.
34-
Metrics/MethodLength:
35-
Max: 26
15+
# Offense count: 4
16+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
17+
# URISchemes: http, https
18+
Metrics/LineLength:
19+
Max: 146
3620

3721
# Offense count: 1
38-
Metrics/PerceivedComplexity:
39-
Max: 11
40-
41-
# Offense count: 3
42-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
43-
# AllowedNames: io, id, to
44-
Naming/UncommunicativeMethodParamName:
22+
# Configuration parameters: EnforcedStyle.
23+
# SupportedStyles: inline, group
24+
Style/AccessModifierDeclarations:
4525
Exclude:
4626
- 'spec/grape_entity/entity_spec.rb'
4727

48-
# Offense count: 1
49-
Style/EvalWithLocation:
50-
Exclude:
51-
- 'lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb'
52-
5328
# Offense count: 1
5429
# Cop supports --auto-correct.
5530
# Configuration parameters: IgnoredMethods.
5631
# IgnoredMethods: respond_to, define_method
5732
Style/SymbolProc:
5833
Exclude:
5934
- 'spec/grape_entity/entity_spec.rb'
60-
61-
# Offense count: 272
62-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
63-
# URISchemes: http, https
64-
Metrics/LineLength:
65-
Max: 146

Diff for: .travis.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ after_success:
77
- bundle exec danger
88

99
rvm:
10-
- 2.3.8
1110
- 2.4.5
12-
- 2.5.3
13-
- 2.6.0
11+
- 2.5.4
12+
- 2.6.2
1413
- ruby-head
1514
- jruby-head
1615

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ source 'http://rubygems.org'
55
gemspec
66

77
group :development, :test do
8-
gem 'rubocop', '~> 0.61', require: false
8+
gem 'rubocop', '~> 0.65', require: false
99
end
1010

1111
group :test do

Diff for: Guardfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# frozen_string_literal: true
2+
13
# A sample Guardfile
24
# More info at https://github.com/guard/guard#readme
35

46
guard 'rspec', version: 2 do
57
watch(%r{^spec/.+_spec\.rb$})
6-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
79
watch(%r{^spec/support/shared_versioning_examples.rb$}) { |_m| 'spec/' }
8-
watch('spec/spec_helper.rb') { 'spec/' }
10+
watch('spec/spec_helper.rb') { 'spec/' }
911
end
1012

1113
guard 'bundler' do

Diff for: grape-entity.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
1414
s.description = 'Extracted from Grape, A Ruby framework for rapid API development with great conventions.'
1515
s.license = 'MIT'
1616

17-
s.required_ruby_version = '>= 2.3'
17+
s.required_ruby_version = '>= 2.4'
1818

1919
s.rubyforge_project = 'grape-entity'
2020

Diff for: lib/grape_entity/entity.rb

+21-1
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ def self.inherited(subclass)
168168
# @option options :documentation Define documenation for an exposed
169169
# field, typically the value is a hash with two fields, type and desc.
170170
# @option options :merge This option allows you to merge an exposed field to the root
171+
#
172+
# rubocop:disable Metrics/LineLength
171173
def self.expose(*args, &block)
172174
options = merge_options(args.last.is_a?(Hash) ? args.pop : {})
173175

174176
if args.size > 1
177+
175178
raise ArgumentError, 'You may not use the :as option on multi-attribute exposures.' if options[:as]
176179
raise ArgumentError, 'You may not use the :expose_nil on multi-attribute exposures.' if options.key?(:expose_nil)
177180
raise ArgumentError, 'You may not use block-setting on multi-attribute exposures.' if block_given?
@@ -191,6 +194,7 @@ def self.expose(*args, &block)
191194
@nesting_stack ||= []
192195
args.each { |attribute| build_exposure_for_attribute(attribute, @nesting_stack, options, block) }
193196
end
197+
# rubocop:enable Metrics/LineLength
194198

195199
def self.build_exposure_for_attribute(attribute, nesting_stack, options, block)
196200
exposure_list = nesting_stack.empty? ? root_exposures : nesting_stack.last.nested_exposures
@@ -291,6 +295,7 @@ def self.documentation
291295
#
292296
def self.format_with(name, &block)
293297
raise ArgumentError, 'You must pass a block for formatters' unless block_given?
298+
294299
formatters[name.to_sym] = block
295300
end
296301

@@ -534,7 +539,22 @@ def to_xml(options = {})
534539

535540
# All supported options.
536541
OPTIONS = %i[
537-
rewrite as if unless using with proc documentation format_with safe attr_path if_extras unless_extras merge expose_nil override
542+
rewrite
543+
as
544+
if
545+
unless
546+
using
547+
with
548+
proc
549+
documentation
550+
format_with
551+
safe
552+
attr_path
553+
if_extras
554+
unless_extras
555+
merge
556+
expose_nil
557+
override
538558
].to_set.freeze
539559

540560
# Merges the given options with current block options.

Diff for: lib/grape_entity/exposure/base.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ def valid?(entity)
5454
if @is_safe
5555
is_delegatable
5656
else
57-
is_delegatable || raise(NoMethodError, "#{entity.class.name} missing attribute `#{@attribute}' on #{entity.object}")
57+
is_delegatable || raise(
58+
NoMethodError,
59+
"#{entity.class.name} missing attribute `#{@attribute}' on #{entity.object}"
60+
)
5861
end
5962
end
6063

Diff for: lib/grape_entity/exposure/nesting_exposure.rb

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def normalized_exposures(entity, options)
8787
exposure.should_expose?(entity, options)
8888
end
8989
next unless should_expose
90+
9091
output[exposure.key(entity)] ||= []
9192
output[exposure.key(entity)] << exposure
9293
end

Diff for: lib/grape_entity/exposure/nesting_exposure/nested_exposures.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def clear
4949
length
5050
empty?
5151
].each do |name|
52-
class_eval <<-RUBY, __FILE__, __LINE__
52+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
5353
def #{name}(*args, &block)
5454
@exposures.#{name}(*args, &block)
5555
end

Diff for: lib/grape_entity/exposure/nesting_exposure/output_builder.rb

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def add(exposure, result)
1919
# If we have an array which should not be merged - save it with a key as a hash
2020
# If we have hash which should be merged - save it without a key (merge)
2121
return unless result
22+
2223
@output_hash.merge! result, &merge_strategy(exposure.for_merge)
2324
else
2425
@output_hash[exposure.key(@entity)] = result

Diff for: spec/grape_entity/entity_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ class TestEntity < Grape::Entity
13761376
expect(res).to have_key :nonexistent_attribute
13771377
end
13781378

1379-
it "exposes attributes defined through module inclusion" do
1379+
it 'exposes attributes defined through module inclusion' do
13801380
module SharedAttributes
13811381
def a_value
13821382
3.14

Diff for: spec/grape_entity/exposure/represent_exposure_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
let(:subexposure) { double(:subexposure) }
1313

1414
it 'sets using_class_name' do
15-
expect { subject }.to change { exposure.using_class_name }.to(using_class_name)
15+
expect { subject }.to change(exposure, :using_class_name).to(using_class_name)
1616
end
1717

1818
it 'sets subexposure' do
19-
expect { subject }.to change { exposure.subexposure }.to(subexposure)
19+
expect { subject }.to change(exposure, :subexposure).to(subexposure)
2020
end
2121

2222
context 'when using_class is set' do
@@ -25,7 +25,7 @@
2525
end
2626

2727
it 'resets using_class' do
28-
expect { subject }.to change { exposure.using_class }
28+
expect { subject }.to change(exposure, :using_class)
2929
end
3030
end
3131
end

0 commit comments

Comments
 (0)