Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,513 changes: 820 additions & 693 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
gemspec name: 'solargraph'
# Local gemfile for development tools, etc.
local_gemfile = File.expand_path(".Gemfile", __dir__)
instance_eval File.read local_gemfile if File.exist? local_gemfile
source 'https://rubygems.org'

gemspec name: 'solargraph'

# Local gemfile for development tools, etc.
local_gemfile = File.expand_path('.Gemfile', __dir__)
instance_eval File.read local_gemfile if File.exist? local_gemfile
274 changes: 137 additions & 137 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,137 +1,137 @@
require 'rake'
require 'bundler/gem_tasks'
require 'fileutils'
require 'open3'
desc "Open a Pry session preloaded with this library"
task :console do
sh "pry -I lib -r solargraph.rb"
end
desc "Run the type checker"
task typecheck: [:typecheck_typed]
desc "Run the type checker at typed level - return code issues provable without annotations being correct"
task :typecheck_typed do
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed"
end
desc "Run the type checker at strict level - report issues using type annotations"
task :typecheck_strict do
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict"
end
desc "Run the type checker at strong level - enforce that type annotations exist"
task :typecheck_strong do
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong"
end
desc "Run the type checker at alpha level - run high-false-alarm checks"
task :typecheck_alpha do
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha"
end
desc "Run RSpec tests, starting with the ones that failed last time"
task spec: %i[spec_failed undercover_no_fail full_spec] do
undercover
end
desc "Run all RSpec tests"
task :full_spec do
warn 'starting spec'
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
warn 'ending spec'
# move coverage/full-new to coverage/full on success so that we
# always have the last successful run's 'coverage info
FileUtils.rm_rf('coverage/full')
FileUtils.mv('coverage/full-new', 'coverage/full')
end
# @sg-ignore #undercover return type could not be inferred
# @return [Process::Status]
def undercover
simplecov_collate
cmd = 'bundle exec undercover ' \
'--simplecov coverage/combined/coverage.json ' \
'--exclude-files "Rakefile,spec/*,spec/**/*,lib/solargraph/version.rb" ' \
'--compare origin/master'
output, status = Bundler.with_unbundled_env do
Open3.capture2e(cmd)
end
puts output
$stdout.flush
status
rescue StandardError => e
warn "hit error: #{e.message}"
warn "Backtrace:\n#{e.backtrace.join("\n")}"
warn "output: #{output}"
puts "Flushing"
$stdout.flush
raise
end
desc "Check PR coverage"
task :undercover do
raise "Undercover failed" unless undercover.success?
end
desc "Branch-focused fast-feedback quality/spec/coverage checks"
task test: %i[overcommit spec typecheck] do
# do these in order
Rake::Task['typecheck_strict'].invoke
Rake::Task['typecheck_strong'].invoke
Rake::Task['typecheck_alpha'].invoke
end
desc "Re-run failed specs. Add --fail-fast in your .rspec-local file if desired."
task :spec_failed do
# allow user to check out any persistent failures while looking for
# more in the whole test suite
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
end
desc "Run undercover and show output without failing the task if it fails"
task :undercover_no_fail do
undercover
rescue StandardError
puts "Undercover failed, but continuing with other tasks."
end
# @return [void]
def simplecov_collate
require 'simplecov'
require 'simplecov-lcov'
require 'undercover/simplecov_formatter'
SimpleCov.collate(Dir["coverage/{next-failure,full,ad-hoc}/.resultset.json"]) do
cname = 'combined'
command_name cname
new_dir = File.join('coverage', cname)
coverage_dir new_dir
formatter \
SimpleCov::Formatter::MultiFormatter
.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Undercover,
SimpleCov::Formatter::LcovFormatter
])
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
end
puts "Simplecov collated results into coverage/combined/.resultset.json"
rescue StandardError => e
puts "Simplecov collate failed: #{e.message}"
ensure
$stdout.flush
end
desc 'Add incremental coverage for rapid iteration with undercover'
task :simplecov_collate do
simplecov_collate
end
desc "Show quality checks on this development branch so far, including any staged files"
task :overcommit do
# OVERCOMMIT_DEBUG=1 will show more detail
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
end
require 'rake'
require 'bundler/gem_tasks'
require 'fileutils'
require 'open3'

desc 'Open a Pry session preloaded with this library'
task :console do
sh 'pry -I lib -r solargraph.rb'
end

desc 'Run the type checker'
task typecheck: [:typecheck_typed]

desc 'Run the type checker at typed level - return code issues provable without annotations being correct'
task :typecheck_typed do
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed'
end

desc 'Run the type checker at strict level - report issues using type annotations'
task :typecheck_strict do
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict'
end

desc 'Run the type checker at strong level - enforce that type annotations exist'
task :typecheck_strong do
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong'
end

desc 'Run the type checker at alpha level - run high-false-alarm checks'
task :typecheck_alpha do
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha'
end

desc 'Run RSpec tests, starting with the ones that failed last time'
task spec: %i[spec_failed undercover_no_fail full_spec] do
undercover
end

desc 'Run all RSpec tests'
task :full_spec do
warn 'starting spec'
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
warn 'ending spec'
# move coverage/full-new to coverage/full on success so that we
# always have the last successful run's 'coverage info
FileUtils.rm_rf('coverage/full')
FileUtils.mv('coverage/full-new', 'coverage/full')
end

# @sg-ignore #undercover return type could not be inferred
# @return [Process::Status]
def undercover
simplecov_collate
cmd = 'bundle exec undercover ' \
'--simplecov coverage/combined/coverage.json ' \
'--exclude-files "Rakefile,spec/*,spec/**/*,lib/solargraph/version.rb" ' \
'--compare origin/master'
output, status = Bundler.with_unbundled_env do
Open3.capture2e(cmd)
end
puts output
$stdout.flush
status
rescue StandardError => e
warn "hit error: #{e.message}"
warn "Backtrace:\n#{e.backtrace.join("\n")}"
warn "output: #{output}"
puts 'Flushing'
$stdout.flush
raise
end

desc 'Check PR coverage'
task :undercover do
raise 'Undercover failed' unless undercover.success?
end

desc 'Branch-focused fast-feedback quality/spec/coverage checks'
task test: %i[overcommit spec typecheck] do
# do these in order
Rake::Task['typecheck_strict'].invoke
Rake::Task['typecheck_strong'].invoke
Rake::Task['typecheck_alpha'].invoke
end

desc 'Re-run failed specs. Add --fail-fast in your .rspec-local file if desired.'
task :spec_failed do
# allow user to check out any persistent failures while looking for
# more in the whole test suite
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
end

desc 'Run undercover and show output without failing the task if it fails'
task :undercover_no_fail do
undercover
rescue StandardError
puts 'Undercover failed, but continuing with other tasks.'
end

# @return [void]
def simplecov_collate
require 'simplecov'
require 'simplecov-lcov'
require 'undercover/simplecov_formatter'

SimpleCov.collate(Dir['coverage/{next-failure,full,ad-hoc}/.resultset.json']) do
cname = 'combined'
command_name cname
new_dir = File.join('coverage', cname)
coverage_dir new_dir

formatter \
SimpleCov::Formatter::MultiFormatter
.new([
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::Undercover,
SimpleCov::Formatter::LcovFormatter
])
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
end
puts 'Simplecov collated results into coverage/combined/.resultset.json'
rescue StandardError => e
puts "Simplecov collate failed: #{e.message}"
ensure
$stdout.flush
end

desc 'Add incremental coverage for rapid iteration with undercover'
task :simplecov_collate do
simplecov_collate
end

desc 'Show quality checks on this development branch so far, including any staged files'
task :overcommit do
# OVERCOMMIT_DEBUG=1 will show more detail
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
end
14 changes: 7 additions & 7 deletions lib/solargraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class InvalidRubocopVersionError < RuntimeError; end
CHDIR_MUTEX = Mutex.new

# @param type [Symbol] Type of assert.
def self.asserts_on?(type)
def self.asserts_on? type
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
false
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
Expand All @@ -71,8 +71,8 @@ def self.asserts_on?(type)
# @param msg [String, nil] An optional message to log
# @param block [Proc] A block that returns a message to log
# @return [void]
def self.assert_or_log(type, msg = nil, &block)
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
def self.assert_or_log type, msg = nil, &block
raise(msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
logger.info msg, &block
end

Expand All @@ -92,10 +92,10 @@ def self.logger
# @return [generic<T>]
def self.with_clean_env &block
meth = if Bundler.respond_to?(:with_original_env)
:with_original_env
else
:with_clean_env
end
:with_original_env
else
:with_clean_env
end
Bundler.send meth, &block
end
end
Expand Down
Loading
Loading