summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <2887858+deivid-rodriguez@users.noreply.github.com>2025-09-09 19:19:23 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-16 17:17:32 +0900
commit190a235464398c5b8f556cbf221bfaec8680e3b8 (patch)
tree5cd9a81d9127c182a5d1cde97d0e76b6081d2877
parent1c7fd141f911d97d1f5a2737d0a36cb608100bdc (diff)
[rubygems/rubygems] 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). https://github.com/rubygems/rubygems/commit/8311de6e69
-rw-r--r--lib/bundler/cli.rb6
-rw-r--r--lib/bundler/cli/gem.rb22
-rw-r--r--lib/bundler/man/bundle-gem.13
-rw-r--r--lib/bundler/man/bundle-gem.1.ronn3
-rw-r--r--spec/bundler/commands/newgem_spec.rb99
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb36
6 files changed, 12 insertions, 157 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index e59265e8b2..8151de713a 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -525,7 +525,7 @@ module Bundler
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)`"
@@ -535,6 +535,10 @@ module Bundler
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)
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 71207bc5da..56d23d9e9f 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -382,7 +382,6 @@ module Bundler
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? " \
@@ -415,27 +414,6 @@ module Bundler
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 --no-linter",
- removed_message: "--no-rubocop has been removed, use --no-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; 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]
diff --git a/lib/bundler/man/bundle-gem.1 b/lib/bundler/man/bundle-gem.1
index 884badb584..670a69d67e 100644
--- a/lib/bundler/man/bundle-gem.1
+++ b/lib/bundler/man/bundle-gem.1
@@ -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
diff --git a/lib/bundler/man/bundle-gem.1.ronn b/lib/bundler/man/bundle-gem.1.ronn
index b1327aa342..b71bde9f65 100644
--- a/lib/bundler/man/bundle-gem.1.ronn
+++ b/lib/bundler/man/bundle-gem.1.ronn
@@ -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`.
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 40bc1c3ff4..0b13344f99 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -175,75 +175,6 @@ RSpec.describe "bundle gem" do
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"
@@ -1335,32 +1266,6 @@ RSpec.describe "bundle gem" do
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"
@@ -1558,8 +1463,6 @@ RSpec.describe "bundle gem" do
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
@@ -1569,8 +1472,6 @@ RSpec.describe "bundle gem" do
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
diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb
index 0a8d1d112e..bf0fca5ddd 100644
--- a/spec/bundler/other/major_deprecation_spec.rb
+++ b/spec/bundler/other/major_deprecation_spec.rb
@@ -711,7 +711,7 @@ RSpec.describe "major deprecations" do
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"
@@ -722,9 +722,9 @@ RSpec.describe "major deprecations" do
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
@@ -733,31 +733,9 @@ RSpec.describe "major deprecations" do
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 --no-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