在 GitHub 操作中運行作業流時,rubocop 出錯,但它抱怨的代碼不在我的倉庫中。我怎樣才能解決這個問題?
錯誤:
Run bin/rubocop --parallel
vendor/bundle/ruby/2.7.0/gems/activerecord-import-1.1.0/.rubocop.yml: Lint/EndAlignment has the wrong namespace - should be Layout
vendor/bundle/ruby/2.7.0/gems/activerecord-import-1.1.0/.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
vendor/bundle/ruby/2.7.0/gems/activerecord-import-1.1.0/.rubocop.yml: Style/ElseAlignment has the wrong namespace - should be Layout
vendor/bundle/ruby/2.7.0/gems/activerecord-import-1.1.0/.rubocop.yml: Style/SpaceInsideParens has the wrong namespace - should be Layout
Error: The `Lint/HandleExceptions` cop has been renamed to `Lint/SuppressedException`.
(obsolete configuration found in vendor/bundle/ruby/2.7.0/gems/activerecord-import-1.1.0/.rubocop_todo.yml, please update it)
Error: Process completed with exit code 2.
GitHub Actions 作業流 yml 檔案:
name: Verify
on: [push]
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10.13.0
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
yarn install --pure-lockfile
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
- name: Run linters
run: |
bin/rubocop --parallel
tests:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: myapp
POSTGRES_DB: myapp_test
POSTGRES_PASSWORD: ""
ports: ["5432:5432"]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10.13.0
- name: Find yarn cache location
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: JS package cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup test database
env:
RAILS_ENV: test
PGHOST: localhost
PGUSER: myapp
run: |
bundle exec rails db:create
bundle exec rails db:migrate
- name: Run tests
run: |
bundle exec rails test
uj5u.com熱心網友回復:
正如您已經注意到的那樣,針對第三方代碼和外部 gem 運行 RuboCop 并沒有真正的好處,因為它們并沒有真正在您的控制之下,而且您當然不想“修復”它們。
因此我建議排除帶有外部代碼的檔案夾,例如vendor/bundle檔案夾中的 gems。這可以通過將以下行添加到專案的.rubycop.yml組態檔中來完成:
AllCops:
Exclude:
- 'vendor/bundle/**/*'
請參閱有關排除檔案和檔案夾的RuboCop 檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/489077.html
標籤:轨道上的红宝石 红宝石 活动记录 github-动作 鲁博科普
上一篇:如何避免RailsSidekiq調度作業和作業人員使用相同代碼的代碼重復
下一篇:使用關系計數和性能查詢模型資料
