Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept pending cops in the development build #7664

Merged
merged 1 commit into from
Jan 25, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 39 additions & 1 deletion spec/rubocop/cli/cli_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,47 @@ class SomeCop < Cop
# process. Otherwise, the extra cop will affect other specs.
output =
`ruby -I . "#{rubocop}" --require redirect.rb --only Style/SomeCop`
expect($CHILD_STATUS.success?).to be_truthy
# Excludes a warning when new `Enabled: pending` status cop is specified
# in config/default.yml.
output_excluding_warn_for_pending_cops =
output.split("\n").last(4).join("\n") << "\n"
expect(output_excluding_warn_for_pending_cops)
.to eq(<<~RESULT)
Inspecting 2 files
..

2 files inspected, no offenses detected
RESULT
end

it 'accepts cop names from plugins with a pending cop' do
create_file('.rubocop.yml', <<~YAML)
require: rubocop_ext

Style/SomeCop:
Description: Something
Enabled: pending
YAML
create_file('rubocop_ext.rb', <<~RUBY)
module RuboCop
module Cop
module Style
class SomeCop < Cop
end
end
end
end
RUBY
create_file('redirect.rb', '$stderr = STDOUT')
rubocop = "#{RuboCop::ConfigLoader::RUBOCOP_HOME}/exe/rubocop"
# Since we define a new cop class, we have to do this in a separate
# process. Otherwise, the extra cop will affect other specs.
output =
`ruby -I . "#{rubocop}" --require redirect.rb --only Style/SomeCop`
expect(output)
.to eq(<<~RESULT)
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file:
- Style/SomeCop
Inspecting 2 files
..

Expand Down
16 changes: 16 additions & 0 deletions spec/support/suppress_pending_warning.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

#
# This is a file that supports testing. An open class has been applied to
# `RuboCop::ConfigLoader.warn_on_pending_cops` to suppress pending cop
# warnings during testing.
#
module RuboCop
class ConfigLoader
class << self
def warn_on_pending_cops(config)
# noop
end
end
end
end