From 3ee2ad755c4af36689faefe62d56eb1a8b533e1b Mon Sep 17 00:00:00 2001 From: ydah Date: Thu, 21 Mar 2024 18:38:47 +0900 Subject: [PATCH] Support Prism as a Ruby parser Follow up rubocop/rubocop-ast#277 --- .github/workflows/main.yml | 16 ++++++++++++++++ CHANGELOG.md | 2 ++ Gemfile | 1 + Rakefile | 9 ++++++++- rubocop-factory_bot.gemspec | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e63ec98a..f7fb0648 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -75,3 +75,19 @@ jobs: ruby-version: "3.3" bundler-cache: true - run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }} + + prism: + runs-on: ubuntu-latest + name: Prism + steps: + - uses: actions/checkout@v4 + - name: set up Ruby + uses: ruby/setup-ruby@v1 + with: + # Specify the minimum Ruby version 2.7 required for Prism to run. + ruby-version: 2.7 + bundler-cache: true + - name: spec + env: + PARSER_ENGINE: parser_prism + run: NO_COVERAGE=true bundle exec rake prism_spec diff --git a/CHANGELOG.md b/CHANGELOG.md index 077d767a..6ce8ff53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Master (Unreleased) +- Support Prism as a Ruby parser (experimental). ([@ydah]) + ## 2.25.1 (2024-01-08) - Fix a false positive for `FactoryBot/CreateList` when create call does have method calls and repeat multiple times with other argument. ([@ydah]) diff --git a/Gemfile b/Gemfile index 199966eb..12d7e17b 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gemspec gem 'bump' gem 'danger' +gem 'prism' gem 'rack' gem 'rake' gem 'rspec', '~> 3.11' diff --git a/Rakefile b/Rakefile index 89a6128c..1557855c 100644 --- a/Rakefile +++ b/Rakefile @@ -77,7 +77,14 @@ task confirm_documentation: :generate_cops_documentation do end end -task default: %i[build_config spec +desc 'Run RSpec with Prism' +task :prism_spec do + sh('PARSER_ENGINE=parser_prism bundle exec rake spec') +end + +task default: %i[build_config + spec + prism_spec internal_investigation confirm_config documentation_syntax_check diff --git a/rubocop-factory_bot.gemspec b/rubocop-factory_bot.gemspec index a539db20..47b66303 100644 --- a/rubocop-factory_bot.gemspec +++ b/rubocop-factory_bot.gemspec @@ -34,4 +34,5 @@ Gem::Specification.new do |spec| } spec.add_runtime_dependency 'rubocop', '~> 1.41' + spec.add_runtime_dependency 'rubocop-ast', '>= 1.31.1', '< 2.0' end