Skip to content

Commit 8311de6

Browse files
Complete rubocop flags and settings removal
If the CLI flags are used, we abort early as usual. As per the settings, I decided to ignore them. We've been migrating them automatically to the new name for a long time and we don't yet have a standard way to deprecate and remove settings (we should probably use the existing setting validators). So I think it's fine for now to do what we normally do (ignore the setting).
1 parent 2c16b0e commit 8311de6

File tree

6 files changed

+12
-157
lines changed

6 files changed

+12
-157
lines changed

bundler/lib/bundler/cli.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def viz
525525
method_option :ext, type: :string, banner: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
526526
method_option :git, type: :boolean, default: true, banner: "Initialize a git repo inside your library."
527527
method_option :mit, type: :boolean, banner: "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
528-
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`."
528+
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)."
529529
method_option :changelog, type: :boolean, banner: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
530530
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)`."
531531
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)`"
@@ -535,6 +535,10 @@ def viz
535535

536536
def gem(name)
537537
require_relative "cli/gem"
538+
539+
raise InvalidOption, "--rubocop has been removed, use --linter=rubocop" if ARGV.include?("--rubocop")
540+
raise InvalidOption, "--no-rubocop has been removed, use --no-linter" if ARGV.include?("--no-rubocop")
541+
538542
cmd_args = args + [self]
539543
cmd_args.unshift(options)
540544

bundler/lib/bundler/cli/gem.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ def ask_and_set_ci
382382
def ask_and_set_linter
383383
return if skip?(:linter)
384384
linter_template = options[:linter] || Bundler.settings["gem.linter"]
385-
linter_template = deprecated_rubocop_option if linter_template.nil?
386385

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

418-
def deprecated_rubocop_option
419-
if !options[:rubocop].nil?
420-
if options[:rubocop]
421-
Bundler::SharedHelpers.major_deprecation 2,
422-
"--rubocop is deprecated, use --linter=rubocop",
423-
removed_message: "--rubocop has been removed, use --linter=rubocop"
424-
"rubocop"
425-
else
426-
Bundler::SharedHelpers.major_deprecation 2,
427-
"--no-rubocop is deprecated, use --no-linter",
428-
removed_message: "--no-rubocop has been removed, use --no-linter"
429-
false
430-
end
431-
elsif !Bundler.settings["gem.rubocop"].nil?
432-
Bundler::SharedHelpers.major_deprecation 2,
433-
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
434-
removed_message: "config gem.rubocop has been removed; use gem.linter instead"
435-
Bundler.settings["gem.rubocop"] ? "rubocop" : false
436-
end
437-
end
438-
439417
def bundler_dependency_version
440418
v = Gem::Version.new(Bundler::VERSION)
441419
req = v.segments[0..1]

bundler/lib/bundler/man/bundle-gem.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ When Bundler is unconfigured, an interactive prompt will be displayed and the an
9292
\fB\-\-no\-linter\fR
9393
Do not add a linter (overrides \fB\-\-linter\fR specified in the global config)\.
9494
.TP
95-
\fB\-\-rubocop\fR
96-
Add rubocop to the generated Rakefile and gemspec\. Set a default with \fBbundle config set \-\-global gem\.rubocop true\fR\.
97-
.TP
9895
\fB\-\-edit=EDIT\fR, \fB\-e=EDIT\fR
9996
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\.
10097
.TP

bundler/lib/bundler/man/bundle-gem.1.ronn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ configuration file using the following names:
135135
* `--no-linter`:
136136
Do not add a linter (overrides `--linter` specified in the global config).
137137

138-
* `--rubocop`:
139-
Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`.
140-
141138
* `--edit=EDIT`, `-e=EDIT`:
142139
Open the resulting GEM_NAME.gemspec in EDIT, or the default editor if not
143140
specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.

bundler/spec/commands/newgem_spec.rb

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -175,75 +175,6 @@ def ignore_paths
175175
end
176176
end
177177

178-
shared_examples_for "--rubocop flag" do
179-
context "is deprecated" do
180-
before do
181-
global_config "BUNDLE_GEM__LINTER" => nil
182-
bundle "gem #{gem_name} --rubocop"
183-
end
184-
185-
it "generates a gem skeleton with rubocop" do
186-
gem_skeleton_assertions
187-
expect(bundled_app("#{gem_name}/Rakefile")).to read_as(
188-
include("# frozen_string_literal: true").
189-
and(include('require "rubocop/rake_task"').
190-
and(include("RuboCop::RakeTask.new").
191-
and(match(/default:.+:rubocop/))))
192-
)
193-
end
194-
195-
it "includes rubocop in generated Gemfile" do
196-
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
197-
builder = Bundler::Dsl.new
198-
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
199-
builder.dependencies
200-
rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
201-
expect(rubocop_dep).not_to be_nil
202-
end
203-
204-
it "generates a default .rubocop.yml" do
205-
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
206-
end
207-
208-
it "includes .rubocop.yml into ignore list" do
209-
expect(ignore_paths).to include(".rubocop.yml")
210-
end
211-
end
212-
end
213-
214-
shared_examples_for "--no-rubocop flag" do
215-
context "is deprecated" do
216-
define_negated_matcher :exclude, :include
217-
218-
before do
219-
bundle "gem #{gem_name} --no-rubocop"
220-
end
221-
222-
it "generates a gem skeleton without rubocop" do
223-
gem_skeleton_assertions
224-
expect(bundled_app("#{gem_name}/Rakefile")).to read_as(exclude("rubocop"))
225-
expect(bundled_app("#{gem_name}/#{gem_name}.gemspec")).to read_as(exclude("rubocop"))
226-
end
227-
228-
it "does not include rubocop in generated Gemfile" do
229-
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
230-
builder = Bundler::Dsl.new
231-
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
232-
builder.dependencies
233-
rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
234-
expect(rubocop_dep).to be_nil
235-
end
236-
237-
it "doesn't generate a default .rubocop.yml" do
238-
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
239-
end
240-
241-
it "does not add .rubocop.yml into ignore list" do
242-
expect(ignore_paths).not_to include(".rubocop.yml")
243-
end
244-
end
245-
end
246-
247178
shared_examples_for "--linter=rubocop flag" do
248179
before do
249180
bundle "gem #{gem_name} --linter=rubocop"
@@ -1335,32 +1266,6 @@ def create_temporary_dir(dir)
13351266
end
13361267
end
13371268

1338-
context "gem.rubocop setting set to true" do
1339-
before do
1340-
global_config "BUNDLE_GEM__LINTER" => nil
1341-
bundle "config set gem.rubocop true"
1342-
bundle "gem #{gem_name}"
1343-
end
1344-
1345-
it "generates rubocop config" do
1346-
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
1347-
end
1348-
1349-
it "includes .rubocop.yml into ignore list" do
1350-
expect(ignore_paths).to include(".rubocop.yml")
1351-
end
1352-
1353-
it "unsets gem.rubocop" do
1354-
bundle "config gem.rubocop"
1355-
expect(out).to include("You have not configured a value for `gem.rubocop`")
1356-
end
1357-
1358-
it "sets gem.linter=rubocop instead" do
1359-
bundle "config gem.linter"
1360-
expect(out).to match(/Set for the current user .*: "rubocop"/)
1361-
end
1362-
end
1363-
13641269
context "gem.linter set to rubocop and --linter with no arguments" do
13651270
before do
13661271
bundle "config set gem.linter rubocop"
@@ -1558,8 +1463,6 @@ def create_temporary_dir(dir)
15581463
it_behaves_like "--linter=rubocop flag"
15591464
it_behaves_like "--linter=standard flag"
15601465
it_behaves_like "--no-linter flag"
1561-
it_behaves_like "--rubocop flag"
1562-
it_behaves_like "--no-rubocop flag"
15631466
end
15641467

15651468
context "with rubocop option in bundle config settings set to false" do
@@ -1569,8 +1472,6 @@ def create_temporary_dir(dir)
15691472
it_behaves_like "--linter=rubocop flag"
15701473
it_behaves_like "--linter=standard flag"
15711474
it_behaves_like "--no-linter flag"
1572-
it_behaves_like "--rubocop flag"
1573-
it_behaves_like "--no-rubocop flag"
15741475
end
15751476

15761477
context "with linter option in bundle config settings set to rubocop" do

bundler/spec/other/major_deprecation_spec.rb

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@
711711
pending "fails with a helpful message", bundler: "4"
712712
end
713713

714-
describe "deprecating rubocop" do
714+
describe "removing rubocop" do
715715
before do
716716
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false",
717717
"BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false"
@@ -722,9 +722,9 @@
722722
bundle "gem my_new_gem --rubocop", raise_on_error: false
723723
end
724724

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

@@ -733,31 +733,9 @@
733733
bundle "gem my_new_gem --no-rubocop", raise_on_error: false
734734
end
735735

736-
it "prints a deprecation warning" do
737-
expect(deprecations).to include \
738-
"--no-rubocop is deprecated, use --no-linter"
739-
end
740-
end
741-
742-
context "bundle gem with gem.rubocop set to true" do
743-
before do
744-
bundle "gem my_new_gem", env: { "BUNDLE_GEM__RUBOCOP" => "true" }, raise_on_error: false
745-
end
746-
747-
it "prints a deprecation warning" do
748-
expect(deprecations).to include \
749-
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
750-
end
751-
end
752-
753-
context "bundle gem with gem.rubocop set to false" do
754-
before do
755-
bundle "gem my_new_gem", env: { "BUNDLE_GEM__RUBOCOP" => "false" }, raise_on_error: false
756-
end
757-
758-
it "prints a deprecation warning" do
759-
expect(deprecations).to include \
760-
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
736+
it "prints an error" do
737+
expect(err).to include \
738+
"--no-rubocop has been removed, use --no-linter"
761739
end
762740
end
763741
end

0 commit comments

Comments
 (0)