Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup RuboCop #74

Merged
merged 3 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Rubocop"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
rubocop:
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6

- name: Install dependencies
run: bundle install

- name: Rubocop run
run: |
bash -c "
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
[[ $? -ne 2 ]]
"

- name: Upload Sarif output
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: rubocop.sarif
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ end

group :development do
gem 'pry'
gem "code-scanning-rubocop"
end
2 changes: 1 addition & 1 deletion lib/rspec/openapi/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

RSpec.configuration.after(:each) do |example|
if RSpec::OpenAPI.example_types.include?(example.metadata[:type]) && example.metadata[:openapi] != false
path = RSpec::OpenAPI.path.yield_self { |path| path.is_a?(Proc) ? path.call(example) : path }
path = RSpec::OpenAPI.path.yield_self { |p| p.is_a?(Proc) ? p.call(example) : p }
record = RSpec::OpenAPI::RecordBuilder.build(self, example: example)
path_records[path] << record if record
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/record.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec::OpenAPI::Record = Struct.new(
:method, # @param [String] - "GET"
:http_method, # @param [String] - "GET"
:path, # @param [String] - "/v1/status/:id"
:path_params, # @param [Hash] - {:controller=>"v1/statuses", :action=>"create", :id=>"1"}
:query_params, # @param [Hash] - {:query=>"string"}
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/record_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def build(context, example:)
end

RSpec::OpenAPI::Record.new(
method: request.request_method,
http_method: request.method,
path: path,
path_params: raw_path_params(request),
query_params: request.query_parameters,
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/openapi/schema_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def build(record)
{
paths: {
normalize_path(record.path) => {
record.method.downcase => {
record.http_method.downcase => {
summary: record.summary,
tags: record.tags,
parameters: build_parameters(record),
Expand Down