Class: Boring::Rubocop::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/boring/rubocop/install/install_generator.rb

Constant Summary collapse

DEFAULT_RUBY_VERSION =
"2.7.1"

Instance Method Summary collapse

Instance Method Details

#add_rails_prefered_rubocop_rulesObject

[View source]

35
36
37
38
39
40
# File 'lib/generators/boring/rubocop/install/install_generator.rb', line 35

def add_rails_prefered_rubocop_rules
  say "Adding rubocop style guides", :green
  @skip_adding_rules = options[:skip_adding_rubocop_rules]
  @target_ruby_version = options[:ruby_version]
  template(".rubocop.yml", ".rubocop.yml")
end

#add_rubocop_gemsObject

[View source]

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/generators/boring/rubocop/install/install_generator.rb', line 18

def add_rubocop_gems
  say "Adding rubocop gems", :green
  rubocop_gem_content = <<~RUBY
    \n
    \t# A Ruby static code analyzer, based on the community Ruby style guide
    \tgem "rubocop",  require: false
    \tgem "rubocop-rails",  require: false
    \tgem "rubocop-performance", require: false
    \tgem "rubocop-rake", require: false
    #{rubocop_test_gem_content}
  RUBY
  insert_into_file "Gemfile", rubocop_gem_content, after: /group :development do/
  Bundler.with_unbundled_env do
    run "bundle install"
  end
end