-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore injection for old rubocop versions
- Loading branch information
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rubocop" | ||
require "rubocop/sorbet/version" | ||
require "rubocop/sorbet/plugin" | ||
require "pathname" | ||
require "yaml" | ||
|
||
module RuboCop | ||
module Sorbet | ||
class Error < StandardError; end | ||
|
||
unless Plugin::SUPPORTED | ||
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze | ||
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze | ||
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze | ||
|
||
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT) | ||
|
||
::RuboCop::ConfigObsoletion.files << PROJECT_ROOT.join("config", "obsoletion.yml") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
# The original code is from https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb | ||
# See https://github.com/rubocop-hq/rubocop-rspec/blob/master/MIT-LICENSE.md | ||
module RuboCop | ||
module Sorbet | ||
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a | ||
# bit of our configuration. | ||
module Inject | ||
class << self | ||
def defaults! | ||
path = CONFIG_DEFAULT.to_s | ||
hash = ConfigLoader.send(:load_yaml_configuration, path) | ||
if Gem::Version.new(RuboCop::Version::STRING) >= Gem::Version.new("1.66") | ||
# We use markdown for cop documentation. Unconditionally setting | ||
# the base url will produce incorrect urls on older RuboCop versions, | ||
# so we do that for fully supported version only here. | ||
hash["Sorbet"] ||= {} | ||
hash["Sorbet"]["DocumentationBaseURL"] = "https://github.com/Shopify/rubocop-sorbet/blob/main/manual" | ||
hash["Sorbet"]["DocumentationExtension"] = ".md" | ||
end | ||
config = Config.new(hash, path).tap(&:make_excludes_absolute) | ||
puts "configuration from #{path}" if ConfigLoader.debug? | ||
config = ConfigLoader.merge_with_default(config, path) | ||
ConfigLoader.instance_variable_set(:@default_configuration, config) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters