# Kiribori Template for RailsBestPractices
context = <<EOM
  * RailsBestPracticesのインストールと設定を追加
EOM


## Add gems

gem_group :development, :test do
  gem 'rails_best_practices'
end

bundle_command 'install --quiet'


## Configuration for RailsBestPractices

create_file 'config/rails_best_practices.yml', <<'CODE'
AddModelVirtualAttributeCheck: { }
AlwaysAddDbIndexCheck: { }
CheckSaveReturnValueCheck: { }
CheckDestroyReturnValueCheck: { }
DefaultScopeIsEvilCheck: { }
DryBundlerInCapistranoCheck: { }
#HashSyntaxCheck: { }
IsolateSeedDataCheck: { }
KeepFindersOnTheirOwnModelCheck: { }
LawOfDemeterCheck: { }
#LongLineCheck: { max_line_length: 80 }
MoveCodeIntoControllerCheck: { }
MoveCodeIntoHelperCheck: { array_count: 3 }
MoveCodeIntoModelCheck:
  use_count: 2
  ignored_files:
    - 'app/views/kaminari/_paginator.html.haml'
MoveFinderToNamedScopeCheck: { }
MoveModelLogicIntoModelCheck: { use_count: 4 }
NeedlessDeepNestingCheck: { nested_count: 2 }
NotRescueExceptionCheck: { }
NotUseDefaultRouteCheck: { }
NotUseTimeAgoInWordsCheck: { }
OveruseRouteCustomizationsCheck: { customize_count: 3 }
ProtectMassAssignmentCheck: { }
RemoveEmptyHelpersCheck:
  ignored_files:
    - 'app/helpers/my_helper.rb'
    - 'app/helpers/home_helper.rb'
RemoveTabCheck: { }
RemoveTrailingWhitespaceCheck: { }
RemoveUnusedMethodsInControllersCheck:
  except_methods:
    - 'MyController#top'
RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
RemoveUnusedMethodsInModelsCheck: { except_methods: [] }
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }
ReplaceInstanceVariableWithLocalVariableCheck: { }
RestrictAutoGeneratedRoutesCheck: { }
SimplifyRenderInControllersCheck: { }
SimplifyRenderInViewsCheck: { }
UseBeforeFilterCheck: { customize_count: 2 }
UseModelAssociationCheck: { }
UseMultipartAlternativeAsContentTypeOfEmailCheck: { }
UseParenthesesInMethodDefCheck: { }
UseObserverCheck: { }
UseQueryAttributeCheck: { }
UseSayWithTimeInMigrationsCheck: { }
UseScopeAccessCheck: { }
UseTurboSprocketsRails3Check: { }
CODE


git add: %w[
  Gemfile
  Gemfile.lock
  config/rails_best_practices.yml
].join(' ')

git commit: "-m 'Apply RailsBestPractices template by Kiribori.\n#{context}'"
