Upgrade to Pro — share decks privately, control downloads, hide ads and more …

あなたの知らないRuboCopの設定

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 あなたの知らないRuboCopの設定

Avatar for vividmuimui

vividmuimui

April 01, 2019
Tweet

More Decks by vividmuimui

Other Decks in Programming

Transcript

  1. inherit( ) inherit( ) RuboCop inhert_from .rubocop_todo.yml inherit_gem Gem onkcop

    , meowcop inherit_from: .rubocop_todo.yml inherit_gem: onkcop: - "config/rubocop.yml" - "config/rails.yml" 5
  2. 1 1 ( : .rubocop.yml ) ( : .rubocop_todo.yml )

    # .rubocop_todo.yml Style/CollectionMethods: PreferredMethods: collect: map # .rubocop.yml inherit_from: '.rubocop_todo.yml' Style/CollectionMethods: PreferredMethods: collect: collect # こっちの設定が有効 8
  3. 2 2 RuboCop Hash Array Hash Merge Array Override Array

    Override Merge Yaml Array Hash ~ (Yaml null) Style/CollectionMethods: # hashの例 PreferredMethods: collect: map # arrayの例 Exclude: - 'foo/bar.rb' 9
  4. 15

  5. rubocop . ├── config │ ├── .my_rubocop_config.yml │ ├── .rubocop_todo.yml

    │ └── .rubocop.yml └── src └── sample.rb # .rubocop.yml inherit_from: - .my_rubocop_config.yml - .rubocop_todo.yml $ rubocop -c config/.rubocop.yml 18
  6. . ├── config │ ├── .my_rubocop_config.yml │ ├── .rubocop_todo.yml │

    └── .rubocop.yml └── src └── sample.rb # config/.rubocop.yml # config/.rubocop_todo.yml Style/CollectionMethods: Exclude: # .rubocopで始まるので、設定ファイルからの相対 - '../src/sample.rb' # config/.my_rubocop_config.yml Style/CollectionMethods: Exclude: # .rubocopではないので、実行ディレクトリからの相対 - 'src/sample.rb' 19
  7. .rubocop rubocop src rubocop . ├── src │ └── server

    │ └── test │ └── foo.rb └── tool └── rubocop └── config └── rubocopの設定ファイル $ rubocop -c ../tool/rubocop/config/{rubocopの設定フ
  8. .rubocop .rubocop test Cop .rubocop **/ .rubocop rubocop src src/server

    # rubocopの設定ファイル Foo/BarCop: Exclude: - '**/test/**/*.rb' 22
  9. 23

  10. : URL inherit inherit_from URL : inherit_mode Hash Merge, Array

    Override inherit_mode Array Merge : inherit_from inherit_from Include/Exclude .rubocop tools/ .rubocop 24