module Solargraph::Diagnostics::RubocopHelpers
def fix_drive_letter path
-
(String)-
Parameters:
-
path(String) --
def fix_drive_letter path return path unless path.match(/^[a-z]:/) path[0].upcase + path[1..-1] end
def generate_options filename, code
-
(Array(Array-, Array ))
Parameters:
-
code(String) -- -
filename(String) --
def generate_options filename, code args = ['-f', 'j', '--force-exclusion', filename] base_options = RuboCop::Options.new options, paths = base_options.parse(args) options[:stdin] = code [options, paths] end
def redirect_stdout
-
(String)-
Other tags:
- Todo: - This is a smelly way to redirect output, but the RuboCop specs do
def redirect_stdout redir = StringIO.new $stdout = redir yield if block_given? $stdout = STDOUT redir.string end
def require_rubocop(version = nil)
-
(void)-
Raises:
-
(InvalidRubocopVersionError)- if _version_ is not installed
Parameters:
-
version(String, nil) --
def require_rubocop(version = nil) begin # @type [String] gem_path = Gem::Specification.find_by_name('rubocop', version).full_gem_path gem_lib_path = File.join(gem_path, 'lib') $LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path) # @sg-ignore rescue Gem::MissingSpecVersionError => e raise InvalidRubocopVersionError, "could not find '#{e.name}' (#{e.requirement}) - "\ "did find: [#{e.specs.map { |s| s.version.version }.join(', ')}]" end require 'rubocop' end