Skip to content

Commit 15225c3

Browse files
committed
rubocop -a
1 parent 1864b67 commit 15225c3

File tree

216 files changed

+2796
-3827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+2796
-3827
lines changed

.rubocop_todo.yml

Lines changed: 57 additions & 1266 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
source 'https://rubygems.org'
2-
3-
gemspec name: 'solargraph'
4-
5-
# Local gemfile for development tools, etc.
6-
local_gemfile = File.expand_path(".Gemfile", __dir__)
7-
instance_eval File.read local_gemfile if File.exist? local_gemfile
1+
source 'https://rubygems.org'
2+
3+
gemspec name: 'solargraph'
4+
5+
# Local gemfile for development tools, etc.
6+
local_gemfile = File.expand_path('.Gemfile', __dir__)
7+
instance_eval File.read local_gemfile if File.exist? local_gemfile

Rakefile

Lines changed: 137 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,137 @@
1-
require 'rake'
2-
require 'bundler/gem_tasks'
3-
require 'fileutils'
4-
require 'open3'
5-
6-
desc "Open a Pry session preloaded with this library"
7-
task :console do
8-
sh "pry -I lib -r solargraph.rb"
9-
end
10-
11-
desc "Run the type checker"
12-
task typecheck: [:typecheck_typed]
13-
14-
desc "Run the type checker at typed level - return code issues provable without annotations being correct"
15-
task :typecheck_typed do
16-
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed"
17-
end
18-
19-
desc "Run the type checker at strict level - report issues using type annotations"
20-
task :typecheck_strict do
21-
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict"
22-
end
23-
24-
desc "Run the type checker at strong level - enforce that type annotations exist"
25-
task :typecheck_strong do
26-
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong"
27-
end
28-
29-
desc "Run the type checker at alpha level - run high-false-alarm checks"
30-
task :typecheck_alpha do
31-
sh "SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha"
32-
end
33-
34-
desc "Run RSpec tests, starting with the ones that failed last time"
35-
task spec: %i[spec_failed undercover_no_fail full_spec] do
36-
undercover
37-
end
38-
39-
desc "Run all RSpec tests"
40-
task :full_spec do
41-
warn 'starting spec'
42-
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
43-
warn 'ending spec'
44-
# move coverage/full-new to coverage/full on success so that we
45-
# always have the last successful run's 'coverage info
46-
FileUtils.rm_rf('coverage/full')
47-
FileUtils.mv('coverage/full-new', 'coverage/full')
48-
end
49-
50-
# @sg-ignore #undercover return type could not be inferred
51-
# @return [Process::Status]
52-
def undercover
53-
simplecov_collate
54-
cmd = 'bundle exec undercover ' \
55-
'--simplecov coverage/combined/coverage.json ' \
56-
'--exclude-files "Rakefile,spec/*,spec/**/*,lib/solargraph/version.rb" ' \
57-
'--compare origin/master'
58-
output, status = Bundler.with_unbundled_env do
59-
Open3.capture2e(cmd)
60-
end
61-
puts output
62-
$stdout.flush
63-
status
64-
rescue StandardError => e
65-
warn "hit error: #{e.message}"
66-
warn "Backtrace:\n#{e.backtrace.join("\n")}"
67-
warn "output: #{output}"
68-
puts "Flushing"
69-
$stdout.flush
70-
raise
71-
end
72-
73-
desc "Check PR coverage"
74-
task :undercover do
75-
raise "Undercover failed" unless undercover.success?
76-
end
77-
78-
desc "Branch-focused fast-feedback quality/spec/coverage checks"
79-
task test: %i[overcommit spec typecheck] do
80-
# do these in order
81-
Rake::Task['typecheck_strict'].invoke
82-
Rake::Task['typecheck_strong'].invoke
83-
Rake::Task['typecheck_alpha'].invoke
84-
end
85-
86-
desc "Re-run failed specs. Add --fail-fast in your .rspec-local file if desired."
87-
task :spec_failed do
88-
# allow user to check out any persistent failures while looking for
89-
# more in the whole test suite
90-
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
91-
end
92-
93-
desc "Run undercover and show output without failing the task if it fails"
94-
task :undercover_no_fail do
95-
undercover
96-
rescue StandardError
97-
puts "Undercover failed, but continuing with other tasks."
98-
end
99-
100-
# @return [void]
101-
def simplecov_collate
102-
require 'simplecov'
103-
require 'simplecov-lcov'
104-
require 'undercover/simplecov_formatter'
105-
106-
SimpleCov.collate(Dir["coverage/{next-failure,full,ad-hoc}/.resultset.json"]) do
107-
cname = 'combined'
108-
command_name cname
109-
new_dir = File.join('coverage', cname)
110-
coverage_dir new_dir
111-
112-
formatter \
113-
SimpleCov::Formatter::MultiFormatter
114-
.new([
115-
SimpleCov::Formatter::HTMLFormatter,
116-
SimpleCov::Formatter::Undercover,
117-
SimpleCov::Formatter::LcovFormatter
118-
])
119-
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
120-
end
121-
puts "Simplecov collated results into coverage/combined/.resultset.json"
122-
rescue StandardError => e
123-
puts "Simplecov collate failed: #{e.message}"
124-
ensure
125-
$stdout.flush
126-
end
127-
128-
desc 'Add incremental coverage for rapid iteration with undercover'
129-
task :simplecov_collate do
130-
simplecov_collate
131-
end
132-
133-
desc "Show quality checks on this development branch so far, including any staged files"
134-
task :overcommit do
135-
# OVERCOMMIT_DEBUG=1 will show more detail
136-
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
137-
end
1+
require 'rake'
2+
require 'bundler/gem_tasks'
3+
require 'fileutils'
4+
require 'open3'
5+
6+
desc 'Open a Pry session preloaded with this library'
7+
task :console do
8+
sh 'pry -I lib -r solargraph.rb'
9+
end
10+
11+
desc 'Run the type checker'
12+
task typecheck: [:typecheck_typed]
13+
14+
desc 'Run the type checker at typed level - return code issues provable without annotations being correct'
15+
task :typecheck_typed do
16+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed'
17+
end
18+
19+
desc 'Run the type checker at strict level - report issues using type annotations'
20+
task :typecheck_strict do
21+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strict'
22+
end
23+
24+
desc 'Run the type checker at strong level - enforce that type annotations exist'
25+
task :typecheck_strong do
26+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong'
27+
end
28+
29+
desc 'Run the type checker at alpha level - run high-false-alarm checks'
30+
task :typecheck_alpha do
31+
sh 'SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level alpha'
32+
end
33+
34+
desc 'Run RSpec tests, starting with the ones that failed last time'
35+
task spec: %i[spec_failed undercover_no_fail full_spec] do
36+
undercover
37+
end
38+
39+
desc 'Run all RSpec tests'
40+
task :full_spec do
41+
warn 'starting spec'
42+
sh 'TEST_COVERAGE_COMMAND_NAME=full-new bundle exec rspec' # --profile'
43+
warn 'ending spec'
44+
# move coverage/full-new to coverage/full on success so that we
45+
# always have the last successful run's 'coverage info
46+
FileUtils.rm_rf('coverage/full')
47+
FileUtils.mv('coverage/full-new', 'coverage/full')
48+
end
49+
50+
# @sg-ignore #undercover return type could not be inferred
51+
# @return [Process::Status]
52+
def undercover
53+
simplecov_collate
54+
cmd = 'bundle exec undercover ' \
55+
'--simplecov coverage/combined/coverage.json ' \
56+
'--exclude-files "Rakefile,spec/*,spec/**/*,lib/solargraph/version.rb" ' \
57+
'--compare origin/master'
58+
output, status = Bundler.with_unbundled_env do
59+
Open3.capture2e(cmd)
60+
end
61+
puts output
62+
$stdout.flush
63+
status
64+
rescue StandardError => e
65+
warn "hit error: #{e.message}"
66+
warn "Backtrace:\n#{e.backtrace.join("\n")}"
67+
warn "output: #{output}"
68+
puts 'Flushing'
69+
$stdout.flush
70+
raise
71+
end
72+
73+
desc 'Check PR coverage'
74+
task :undercover do
75+
raise 'Undercover failed' unless undercover.success?
76+
end
77+
78+
desc 'Branch-focused fast-feedback quality/spec/coverage checks'
79+
task test: %i[overcommit spec typecheck] do
80+
# do these in order
81+
Rake::Task['typecheck_strict'].invoke
82+
Rake::Task['typecheck_strong'].invoke
83+
Rake::Task['typecheck_alpha'].invoke
84+
end
85+
86+
desc 'Re-run failed specs. Add --fail-fast in your .rspec-local file if desired.'
87+
task :spec_failed do
88+
# allow user to check out any persistent failures while looking for
89+
# more in the whole test suite
90+
sh 'TEST_COVERAGE_COMMAND_NAME=next-failure bundle exec rspec --only-failures || true'
91+
end
92+
93+
desc 'Run undercover and show output without failing the task if it fails'
94+
task :undercover_no_fail do
95+
undercover
96+
rescue StandardError
97+
puts 'Undercover failed, but continuing with other tasks.'
98+
end
99+
100+
# @return [void]
101+
def simplecov_collate
102+
require 'simplecov'
103+
require 'simplecov-lcov'
104+
require 'undercover/simplecov_formatter'
105+
106+
SimpleCov.collate(Dir['coverage/{next-failure,full,ad-hoc}/.resultset.json']) do
107+
cname = 'combined'
108+
command_name cname
109+
new_dir = File.join('coverage', cname)
110+
coverage_dir new_dir
111+
112+
formatter \
113+
SimpleCov::Formatter::MultiFormatter
114+
.new([
115+
SimpleCov::Formatter::HTMLFormatter,
116+
SimpleCov::Formatter::Undercover,
117+
SimpleCov::Formatter::LcovFormatter
118+
])
119+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
120+
end
121+
puts 'Simplecov collated results into coverage/combined/.resultset.json'
122+
rescue StandardError => e
123+
puts "Simplecov collate failed: #{e.message}"
124+
ensure
125+
$stdout.flush
126+
end
127+
128+
desc 'Add incremental coverage for rapid iteration with undercover'
129+
task :simplecov_collate do
130+
simplecov_collate
131+
end
132+
133+
desc 'Show quality checks on this development branch so far, including any staged files'
134+
task :overcommit do
135+
# OVERCOMMIT_DEBUG=1 will show more detail
136+
sh 'SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master'
137+
end

lib/solargraph.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class InvalidRubocopVersionError < RuntimeError; end
5656
CHDIR_MUTEX = Mutex.new
5757

5858
# @param type [Symbol] Type of assert.
59-
def self.asserts_on?(type)
59+
def self.asserts_on? type
6060
if ENV['SOLARGRAPH_ASSERTS'].nil? || ENV['SOLARGRAPH_ASSERTS'].empty?
6161
false
6262
elsif ENV['SOLARGRAPH_ASSERTS'] == 'on'
@@ -71,8 +71,8 @@ def self.asserts_on?(type)
7171
# @param msg [String, nil] An optional message to log
7272
# @param block [Proc] A block that returns a message to log
7373
# @return [void]
74-
def self.assert_or_log(type, msg = nil, &block)
75-
raise (msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
74+
def self.assert_or_log type, msg = nil, &block
75+
raise(msg || block.call) if asserts_on?(type) && ![:combine_with_visibility].include?(type)
7676
logger.info msg, &block
7777
end
7878

@@ -92,10 +92,10 @@ def self.logger
9292
# @return [generic<T>]
9393
def self.with_clean_env &block
9494
meth = if Bundler.respond_to?(:with_original_env)
95-
:with_original_env
96-
else
97-
:with_clean_env
98-
end
95+
:with_original_env
96+
else
97+
:with_clean_env
98+
end
9999
Bundler.send meth, &block
100100
end
101101
end

0 commit comments

Comments
 (0)