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

Fix a build error #186

Merged
merged 1 commit into from
Oct 30, 2022
Merged
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
28 changes: 27 additions & 1 deletion lib/rubocop/minitest/assert_offense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,33 @@ def parse_source!(source, file = nil)
file = file.path
end

RuboCop::ProcessedSource.new(source, ruby_version, file)
processed_source = RuboCop::ProcessedSource.new(source, ruby_version, file)

# Follow up https://github.com/rubocop/rubocop/pull/10987.
# When support for RuboCop 1.37.1 ends, this condition can be removed.
if processed_source.respond_to?(:config) && processed_source.respond_to?(:registry)
processed_source.config = configuration
processed_source.registry = registry
end

processed_source
end

def configuration
@configuration ||= if defined?(config)
config
else
RuboCop::Config.new({}, "#{Dir.pwd}/.rubocop.yml")
end
end

def registry
@registry ||= begin
cops = configuration.keys.map { |cop| RuboCop::Cop::Registry.global.find_by_cop_name(cop) }
cops << cop_class if defined?(cop_class) && !cops.include?(cop_class)
cops.compact!
RuboCop::Cop::Registry.new(cops)
end
end

def ruby_version
Expand Down