Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bundler/lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def viz
method_option :ext, type: :string, banner: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
method_option :git, type: :boolean, default: true, banner: "Initialize a git repo inside your library."
method_option :mit, type: :boolean, banner: "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
method_option :rubocop, type: :boolean, banner: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
method_option :rubocop, type: :boolean, banner: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true` (removed)."
method_option :changelog, type: :boolean, banner: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library", enum: %w[rspec minitest test-unit], desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "", enum: %w[github gitlab circle], banner: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
Expand All @@ -535,6 +535,10 @@ def viz

def gem(name)
require_relative "cli/gem"

raise InvalidOption, "--rubocop has been removed, use --linter=rubocop" if ARGV.include?("--rubocop")
raise InvalidOption, "--no-rubocop has been removed, use --no-linter" if ARGV.include?("--no-rubocop")

cmd_args = args + [self]
cmd_args.unshift(options)

Expand Down
22 changes: 0 additions & 22 deletions bundler/lib/bundler/cli/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ def ask_and_set_ci
def ask_and_set_linter
return if skip?(:linter)
linter_template = options[:linter] || Bundler.settings["gem.linter"]
linter_template = deprecated_rubocop_option if linter_template.nil?

if linter_template.to_s.empty?
Bundler.ui.info "\nDo you want to add a code linter and formatter to your gem? " \
Expand Down Expand Up @@ -415,27 +414,6 @@ def ask_and_set_linter
linter_template
end

def deprecated_rubocop_option
if !options[:rubocop].nil?
if options[:rubocop]
Bundler::SharedHelpers.major_deprecation 2,
"--rubocop is deprecated, use --linter=rubocop",
removed_message: "--rubocop has been removed, use --linter=rubocop"
"rubocop"
else
Bundler::SharedHelpers.major_deprecation 2,
"--no-rubocop is deprecated, use --linter",
removed_message: "--no-rubocop has been removed, use --linter"
false
end
elsif !Bundler.settings["gem.rubocop"].nil?
Bundler::SharedHelpers.major_deprecation 2,
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
removed_message: "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
Bundler.settings["gem.rubocop"] ? "rubocop" : false
end
end

def bundler_dependency_version
v = Gem::Version.new(Bundler::VERSION)
req = v.segments[0..1]
Expand Down
3 changes: 0 additions & 3 deletions bundler/lib/bundler/man/bundle-gem.1
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ When Bundler is unconfigured, an interactive prompt will be displayed and the an
\fB\-\-no\-linter\fR
Do not add a linter (overrides \fB\-\-linter\fR specified in the global config)\.
.TP
\fB\-\-rubocop\fR
Add rubocop to the generated Rakefile and gemspec\. Set a default with \fBbundle config set \-\-global gem\.rubocop true\fR\.
.TP
\fB\-\-edit=EDIT\fR, \fB\-e=EDIT\fR
Open the resulting GEM_NAME\.gemspec in EDIT, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
.TP
Expand Down
3 changes: 0 additions & 3 deletions bundler/lib/bundler/man/bundle-gem.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ configuration file using the following names:
* `--no-linter`:
Do not add a linter (overrides `--linter` specified in the global config).

* `--rubocop`:
Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`.

* `--edit=EDIT`, `-e=EDIT`:
Open the resulting GEM_NAME.gemspec in EDIT, or the default editor if not
specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.
Expand Down
99 changes: 0 additions & 99 deletions bundler/spec/commands/newgem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,75 +175,6 @@ def ignore_paths
end
end

shared_examples_for "--rubocop flag" do
context "is deprecated" do
before do
global_config "BUNDLE_GEM__LINTER" => nil
bundle "gem #{gem_name} --rubocop"
end

it "generates a gem skeleton with rubocop" do
gem_skeleton_assertions
expect(bundled_app("#{gem_name}/Rakefile")).to read_as(
include("# frozen_string_literal: true").
and(include('require "rubocop/rake_task"').
and(include("RuboCop::RakeTask.new").
and(match(/default:.+:rubocop/))))
)
end

it "includes rubocop in generated Gemfile" do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
builder = Bundler::Dsl.new
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
builder.dependencies
rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
expect(rubocop_dep).not_to be_nil
end

it "generates a default .rubocop.yml" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end

it "includes .rubocop.yml into ignore list" do
expect(ignore_paths).to include(".rubocop.yml")
end
end
end

shared_examples_for "--no-rubocop flag" do
context "is deprecated" do
define_negated_matcher :exclude, :include

before do
bundle "gem #{gem_name} --no-rubocop"
end

it "generates a gem skeleton without rubocop" do
gem_skeleton_assertions
expect(bundled_app("#{gem_name}/Rakefile")).to read_as(exclude("rubocop"))
expect(bundled_app("#{gem_name}/#{gem_name}.gemspec")).to read_as(exclude("rubocop"))
end

it "does not include rubocop in generated Gemfile" do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
builder = Bundler::Dsl.new
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
builder.dependencies
rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
expect(rubocop_dep).to be_nil
end

it "doesn't generate a default .rubocop.yml" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
end

it "does not add .rubocop.yml into ignore list" do
expect(ignore_paths).not_to include(".rubocop.yml")
end
end
end

shared_examples_for "--linter=rubocop flag" do
before do
bundle "gem #{gem_name} --linter=rubocop"
Expand Down Expand Up @@ -1335,32 +1266,6 @@ def create_temporary_dir(dir)
end
end

context "gem.rubocop setting set to true" do
before do
global_config "BUNDLE_GEM__LINTER" => nil
bundle "config set gem.rubocop true"
bundle "gem #{gem_name}"
end

it "generates rubocop config" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end

it "includes .rubocop.yml into ignore list" do
expect(ignore_paths).to include(".rubocop.yml")
end

it "unsets gem.rubocop" do
bundle "config gem.rubocop"
expect(out).to include("You have not configured a value for `gem.rubocop`")
end

it "sets gem.linter=rubocop instead" do
bundle "config gem.linter"
expect(out).to match(/Set for the current user .*: "rubocop"/)
end
end

context "gem.linter set to rubocop and --linter with no arguments" do
before do
bundle "config set gem.linter rubocop"
Expand Down Expand Up @@ -1558,8 +1463,6 @@ def create_temporary_dir(dir)
it_behaves_like "--linter=rubocop flag"
it_behaves_like "--linter=standard flag"
it_behaves_like "--no-linter flag"
it_behaves_like "--rubocop flag"
it_behaves_like "--no-rubocop flag"
end

context "with rubocop option in bundle config settings set to false" do
Expand All @@ -1569,8 +1472,6 @@ def create_temporary_dir(dir)
it_behaves_like "--linter=rubocop flag"
it_behaves_like "--linter=standard flag"
it_behaves_like "--no-linter flag"
it_behaves_like "--rubocop flag"
it_behaves_like "--no-rubocop flag"
end

context "with linter option in bundle config settings set to rubocop" do
Expand Down
36 changes: 7 additions & 29 deletions bundler/spec/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@
pending "fails with a helpful message", bundler: "4"
end

describe "deprecating rubocop" do
describe "removing rubocop" do
before do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false",
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false"
Expand All @@ -722,9 +722,9 @@
bundle "gem my_new_gem --rubocop", raise_on_error: false
end

it "prints a deprecation warning" do
expect(deprecations).to include \
"--rubocop is deprecated, use --linter=rubocop"
it "prints an error" do
expect(err).to include \
"--rubocop has been removed, use --linter=rubocop"
end
end

Expand All @@ -733,31 +733,9 @@
bundle "gem my_new_gem --no-rubocop", raise_on_error: false
end

it "prints a deprecation warning" do
expect(deprecations).to include \
"--no-rubocop is deprecated, use --linter"
end
end

context "bundle gem with gem.rubocop set to true" do
before do
bundle "gem my_new_gem", env: { "BUNDLE_GEM__RUBOCOP" => "true" }, raise_on_error: false
end

it "prints a deprecation warning" do
expect(deprecations).to include \
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
end
end

context "bundle gem with gem.rubocop set to false" do
before do
bundle "gem my_new_gem", env: { "BUNDLE_GEM__RUBOCOP" => "false" }, raise_on_error: false
end

it "prints a deprecation warning" do
expect(deprecations).to include \
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
it "prints an error" do
expect(err).to include \
"--no-rubocop has been removed, use --no-linter"
end
end
end
Expand Down