如何在Github Actions中设置RuboCop [英] How to setup Rubocop in Github Actions

查看:16
本文介绍了如何在Github Actions中设置RuboCop的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有项目,目前RuboCop检查通过(我有rubocope_todo.yml)。我正在尝试自己在Github Actions中设置LinterStage(没有第三方操作来运行RuboCOP,已经存在),但由于某种原因,RuboCOP没有通过:

The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.

Please also note that you can opt-in to new cops by default by adding this to your config:
  AllCops:
    NewCops: enable
Gemspec/DateAssignment: # new in 1.10
  Enabled: true
Layout/LineEndStringConcatenationIndentation: # new in 1.18
  Enabled: true
Layout/SpaceBeforeBrackets: # new in 1.7
  Enabled: true
Lint/AmbiguousAssignment: # new in 1.7
  Enabled: true
Lint/AmbiguousOperatorPrecedence: # new in 1.21
  Enabled: true
Lint/AmbiguousRange: # new in 1.19
  Enabled: true
Performance/SortReverse: # new in 1.7
  Enabled: true
Performance/Squeeze: # new in 1.7
  Enabled: true
Performance/StringInclude: # new in 1.7
  Enabled: true
Performance/Sum: # new in 1.8
  Enabled: true
Rails/ActiveRecordCallbacksOrder: # new in 2.7
  Enabled: true
Rails/AddColumnIndex: # new in 2.11
  Enabled: true
Rails/AfterCommitOverride: # new in 2.8
  Enabled: true
Rails/AttributeDefaultBlockValue: # new in 2.9
  Enabled: true
Rails/EagerEvaluationLogMessage: # new in 2.11
  Enabled: true
Rails/ExpandedDateRange: # new in 2.11
  Enabled: true
Rails/FindById: # new in 2.7
  Enabled: true
Rails/I18nLocaleAssignment: # new in 2.11
  Enabled: true
Rails/Inquiry: # new in 2.7
  Enabled: true
Rails/MailerName: # new in 2.7
  Enabled: true
Rails/MatchRoute: # new in 2.7
  Enabled: true
Rails/NegateInclude: # new in 2.7
  Enabled: true
Rails/Pluck: # new in 2.7
  Enabled: true
Rails/PluckInWhere: # new in 2.7
  Enabled: true
Rails/RedundantTravelBack: # new in 2.12
  Enabled: true
Rails/RenderInline: # new in 2.7
  Enabled: true
Rails/RenderPlainText: # new in 2.7
  Enabled: true
Rails/ShortI18n: # new in 2.7
  Enabled: true
Rails/SquishedSQLHeredocs: # new in 2.8
  Enabled: true
Rails/TimeZoneAssignment: # new in 2.10
  Enabled: true
Rails/UnusedIgnoredColumns: # new in 2.11
  Enabled: true
Rails/WhereEquals: # new in 2.9
  Enabled: true
Rails/WhereExists: # new in 2.7
  Enabled: true
Rails/WhereNot: # new in 2.8
  Enabled: true
RSpec/ExcessiveDocstringSpacing: # new in 2.5
  Enabled: true
RSpec/IdenticalEqualityAssertion: # new in 2.4
  Enabled: true
RSpec/SubjectDeclaration: # new in 2.5
  Enabled: true
RSpec/Rails/AvoidSetupHook: # new in 2.4
  Enabled: true
For more information: https://docs.rubocop.org/rubocop/versioning.html
vendor/bundle/ruby/2.7.0/bundler/gems/cbr-42bd88bec0e7/.rubocop.yml: Metrics/LineLength has the wrong namespace - should be Layout
/home/runner/work/izi-ndfl/izi-ndfl/vendor/bundle/ruby/2.7.0/bundler/gems/cbr-42bd88bec0e7/.rubocop.yml: Warning: no department given for Documentation.
Error: obsolete parameter `RunRailsCops` (for `AllCops`) found in vendor/bundle/ruby/2.7.0/bundler/gems/cbr-42bd88bec0e7/.rubocop.yml
Use the following configuration instead:
Rails:
  Enabled: true
Error: Process completed with exit code 2.

它似乎读取了错误的配置,因为我的.rubocop.yml中有AllCops设置

AllCops:
  NewCops: enable

以下是我对GA的配置:

.github/workflows/rubocop.yml

name: Rubocop

on: [pull_request]
jobs:
  rubocop:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: Run rubocop
        run: |
          bundle exec rubocop

推荐答案

看起来像是从vendor/目录中的一个宝石中读取.rubocop.yml。试试这个:

AllCops:
  NewCops: enable
  Exclude:
  - 'vendor/'

这篇关于如何在Github Actions中设置RuboCop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆