Skip to content

Commit

Permalink
Some maintenance tasks. (#906)
Browse files Browse the repository at this point in the history
* Improves rubocop config.

* Replaces grape 1.6 action job by grape 1.8.

* Removes 3.0 test in action.

* Bump actions/checkout from 3 to 4.

- closes #32
  • Loading branch information
LeFnord authored Sep 6, 2023
1 parent 3a5da56 commit 55267ac
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 83 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
- name: Run rubocop
run: bundle exec rubocop --parallel --format progress

grape-16:
grape-17:
runs-on: ubuntu-latest
needs: ['rubocop']
env:
GRAPE_VERSION: '1.6.2'
GRAPE_VERSION: '1.7.1'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
ruby-version: ['3.1', '3.2', 'head']
steps:
- name: Check out branch
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -55,17 +55,17 @@ jobs:
bundle update
bundle exec rspec
grape-17:
grape-18:
runs-on: ubuntu-latest
needs: ['rubocop']
env:
GRAPE_VERSION: '1.7.1'
GRAPE_VERSION: '1.8.0'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
ruby-version: ['3.1', '3.2', 'head']
steps:
- name: Check out branch
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down Expand Up @@ -94,10 +94,10 @@ jobs:
GRAPE_VERSION: 'HEAD'
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2', 'head']
ruby-version: ['3.1', '3.2', 'head']
steps:
- name: Check out branch
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
67 changes: 4 additions & 63 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AllCops:
Exclude:
- vendor/**/*
- example/**/*
UseCache: true
NewCops: enable
TargetRubyVersion: 3.2
SuggestExtensions: false
Expand All @@ -24,30 +25,12 @@ Layout/LineLength:
Exclude:
- spec/**/*

Layout/SpaceAroundMethodCallOperator:
Enabled: true

# Lint stuff
#
Lint/ConstantDefinitionInBlock:
Exclude:
- spec/**/*

Lint/DeprecatedOpenSSLConstant:
Enabled: true

Lint/DuplicateElsifCondition:
Enabled: true

Lint/MixedRegexpCaptureTypes:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

# Metrics stuff
#
Metrics/BlockLength:
Expand All @@ -71,66 +54,24 @@ Naming:

# Style stuff
#
Style/AccessorGrouping:
Enabled: true

Style/AsciiComments:
Enabled: false

Style/ArrayCoercion:
Enabled: true

Style/BisectedAttrAccessor:
Enabled: true

Style/CaseLikeIf:
Enabled: true

Style/ExponentialNotation:
Enabled: true

Style/ExplicitBlockArgument:
Enabled: false

Style/HashAsLastArrayItem:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashLikeCase:
Enabled: true

Style/HashSyntax:
Enabled: false

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

Style/OpenStructUse:
Exclude:
- spec/**/*

Style/RegexpLiteral:
Style/RedundantArrayConstructor:
Enabled: false

Style/RedundantAssignment:
Enabled: true

Style/RedundantFetchBlock:
Enabled: true

Style/RedundantFileExtensionInRequire:
Enabled: true

Style/RedundantRegexpCharacterClass:
Enabled: true

Style/RedundantRegexpEscape:
Enabled: true
Style/RegexpLiteral:
Enabled: false

Style/SlicingWithRange:
Enabled: false
11 changes: 4 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ group :development, :test do
gem 'rdoc'
gem 'rspec', '~> 3.9'
gem 'rubocop', '~> 1.50', require: false
gem 'webrick'

unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity'
end
end

group :test do
Expand All @@ -35,9 +38,3 @@ group :test do
gem 'ruby-grape-danger', '~> 0.2.0', require: false
gem 'simplecov', require: false
end

group :test, :development do
unless ENV['MODEL_PARSER'] == 'grape-swagger-entity'
gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity'
end
end
3 changes: 2 additions & 1 deletion lib/grape-swagger/doc_methods/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def find_definition(status, path)
return if response.nil?

return response[:schema]['$ref'].split('/').last if response[:schema].key?('$ref')
return response[:schema]['items']['$ref'].split('/').last if response[:schema].key?('items')

response[:schema]['items']['$ref'].split('/').last if response[:schema].key?('items')
end

def add_extension_to(part, extensions)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape-swagger/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def expose_params(value)
end

def expose_params_from_model(model)
model = model.is_a?(String) ? model.constantize : model
model = model.constantize if model.is_a?(String)
model_name = model_name(model)

return model_name if @definitions.key?(model_name)
Expand Down

0 comments on commit 55267ac

Please sign in to comment.