Skip to content

Commit

Permalink
Merge pull request #186 from koic/fix_a_build_error
Browse files Browse the repository at this point in the history
Fix a build error
  • Loading branch information
koic committed Oct 30, 2022
2 parents 11f5529 + 0234244 commit 4f0c4aa
Showing 1 changed file with 27 additions and 1 deletion.
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

0 comments on commit 4f0c4aa

Please sign in to comment.