Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] Make better vscode experience for ruby #314

Merged
merged 7 commits into from
Jan 22, 2023
Merged
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
10 changes: 6 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Naming:

Layout:
Enabled: true
Include:
- 'lib/**/*'

Migration:
Enabled: true
Expand Down Expand Up @@ -50,8 +48,9 @@ Gemspec:

Performance:
Enabled: true
Include:
- 'lib/**/*'
Exclude:
- 'test/**/*.rb'
- '**/*.md'

Security/MarshalLoad:
Exclude:
Expand Down Expand Up @@ -786,6 +785,9 @@ Layout/SpaceAroundMethodCallOperator:
Layout/LineLength:
Enabled: false

Layout/HeredocIndentation:
Enabled: false

Layout/SpaceAroundOperators:
Enabled: true
EnforcedStyleForExponentOperator: 'space'
Expand Down
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"soutaro.steep-vscode",
"soutaro.rbs-syntax",
"dprint.dprint",
"rebornix.ruby",
"pucelle.run-on-save",
"jnoortheen.nix-ide"
]
}
16 changes: 9 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"editor.defaultFormatter": "dprint.dprint",
"editor.formatOnSave": true,
"ruby.useBundler": true,
"ruby.useLanguageServer": true,
"ruby.lint": {
"rubocop": {
"useBundler": true
"runOnSave.statusMessageTimeout": 3000,
"runOnSave.commands": [
{
"match": "(.*\\.rb|Rakefile|Gemfile|.*\\.gemspec)$",
"command": "bundle exec rubocop --autocorrect ${file}",
"runIn": "backend",
"runningStatusMessage": "Formatting with rubocop ${fileBasename}",
"finishStatusMessage": "${fileBasename} formatted"
}
},
"ruby.format": "rubocop",
],
"cSpell.words": [
"kwargs",
"Undocumentable",
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
# This can't be used `bundle exec rake`. Use `rake` instead
desc(%q{Compare generating String performance with other gems})
task(:benchmark_with_other_gems) do
[{kachick: 'ruby-ulid(This one)'}, { rafaelsales: 'ulid'}, {abachman: 'ulid-ruby'}].each do |gem_name_by_author|
[{ kachick: 'ruby-ulid(This one)' }, { rafaelsales: 'ulid' }, { abachman: 'ulid-ruby' }].each do |gem_name_by_author|
gem_name_by_author.each_pair do |author, gem_name|
puts('-' * 72)
puts("#### #{author} - #{gem_name}")
Expand Down
8 changes: 4 additions & 4 deletions ruby-ulid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Gem::Specification.new do |gem|

gem.metadata = {
'documentation_uri' => 'https://kachick.github.io/ruby-ulid/',
'homepage_uri' => repository_url,
'source_code_uri' => repository_url,
'bug_tracker_uri' => "#{repository_url}/issues",
'homepage_uri' => repository_url,
'source_code_uri' => repository_url,
'bug_tracker_uri' => "#{repository_url}/issues",
'rubygems_mfa_required' => 'true'
}

Expand All @@ -32,7 +32,7 @@ Gem::Specification.new do |gem|
gem.email = ['[email protected]']
git_managed_files = `git ls-files`.lines.map(&:chomp)
might_be_parsing_by_tool_as_dependabot = git_managed_files.empty?
base_files = Dir['README*', '*LICENSE*', 'lib/**/*', 'sig/**/*'].uniq
base_files = Dir['README*', '*LICENSE*', 'lib/**/*', 'sig/**/*'].uniq
files = might_be_parsing_by_tool_as_dependabot ? base_files : (base_files & git_managed_files)

unless might_be_parsing_by_tool_as_dependabot
Expand Down
1 change: 0 additions & 1 deletion scripts/generate_many_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
filename = "dumped_fixed_examples_#{Time.now.strftime('%Y-%m-%d_%H-%M')}.bin"
output_path = "#{File.expand_path('.')}/test/many_data/fixtures/#{filename}"


File.open(output_path, 'w+b') do |file|
Marshal.dump(examples, file)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_thread_safe_generate_with_randomized_time
assert(basically_random_but_contain_same_1000_times.none?(initial_and_median.to_time))

# Might be flaky...
later_than_initial_and_median_count = basically_random_but_contain_same_1000_times.count{ |time| time > initial_and_median.to_time }
later_than_initial_and_median_count = basically_random_but_contain_same_1000_times.count { |time| time > initial_and_median.to_time }
assert do
1500 < later_than_initial_and_median_count
end
Expand Down
1 change: 1 addition & 0 deletions test/core/test_library_loading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def test_naming_convention_for_bundler

compilable_paths = Dir.glob('lib/**/*.rb')
raise unless compilable_paths.size >= 5

compilable_paths.each do |path|
data(path, path)
end
Expand Down
1 change: 1 addition & 0 deletions test/core/test_ractor_shareable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_instances_are_can_be_shareable

const_name_to_value = ULID.constants.to_h { |const_name| [const_name, ULID.const_get(const_name)] }
raise unless const_name_to_value.size >= 10

const_name_to_value.each_pair do |name, value|
data(name.to_s, value)
end
Expand Down
6 changes: 3 additions & 3 deletions test/core/test_ulid_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def test_range
assert_equal(ULID.min..range.end, ULID.range(nil..range.end))

[nil, 42, 1..42, time_has_more_value_than_milliseconds1, ULID.sample.to_s, ULID.sample,
BasicObject.new, Object.new, range.begin.to_s..range.end.to_s].each do |evil|
BasicObject.new, Object.new, range.begin.to_s..range.end.to_s].each do |evil|
err = assert_raises(ArgumentError) do
ULID.range(evil)
end
Expand Down Expand Up @@ -581,7 +581,7 @@ def test_constant_regexp
assert_true(subset_pattern.match?('00000000000000000000000000'))
assert_true(subset_pattern.match?('7ZZZZZZZZZZZZZZZZZZZZZZZZZ'))
assert_false(subset_pattern.match?('80000000000000000000000000'))
assert_equal({'timestamp' => '01ARZ3NDEK', 'randomness' => 'TSV4RRFFQ69G5FAV'}, subset_pattern.match('01ARZ3NDEKTSV4RRFFQ69G5FAV').named_captures)
assert_equal({ 'timestamp' => '01ARZ3NDEK', 'randomness' => 'TSV4RRFFQ69G5FAV' }, subset_pattern.match('01ARZ3NDEKTSV4RRFFQ69G5FAV').named_captures)

assert_true(strict_pattern.casefold?)
assert_equal(Encoding::US_ASCII, strict_pattern.encoding)
Expand All @@ -594,7 +594,7 @@ def test_constant_regexp
assert_true(strict_pattern.match?('00000000000000000000000000'))
assert_true(strict_pattern.match?('7ZZZZZZZZZZZZZZZZZZZZZZZZZ'))
assert_false(strict_pattern.match?('80000000000000000000000000'))
assert_equal({'timestamp' => '01ARZ3NDEK', 'randomness' => 'TSV4RRFFQ69G5FAV'}, strict_pattern.match('01ARZ3NDEKTSV4RRFFQ69G5FAV').named_captures)
assert_equal({ 'timestamp' => '01ARZ3NDEK', 'randomness' => 'TSV4RRFFQ69G5FAV' }, strict_pattern.match('01ARZ3NDEKTSV4RRFFQ69G5FAV').named_captures)

assert_true(scanning_pattern.casefold?)
assert_equal(Encoding::US_ASCII, scanning_pattern.encoding)
Expand Down
2 changes: 1 addition & 1 deletion test/core/test_ulid_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestULIDInstance < Test::Unit::TestCase
pred
].freeze

raise 'Incorrect fixture setup' unless (EXPOSED_METHODS & ULID_RETURNING_METHODS).sort == ULID_RETURNING_METHODS.sort
raise 'Incorrect fixture setup' unless (EXPOSED_METHODS & ULID_RETURNING_METHODS).sort == ULID_RETURNING_METHODS.sort

def setup
@actual_timezone = ENV.fetch('TZ', nil)
Expand Down
8 changes: 4 additions & 4 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Warning[:deprecated] = true
Warning[:experimental] = true

WARNING_PROCESS = -> _warning_message {
WARNING_PROCESS = ->_warning_message {
:raise
}

Expand All @@ -35,16 +35,16 @@ module ULIDAssertions
def assert_acceptable_randomized_string(ulids)
awesome_randomized_ulids = ulids.select { |ulid|
(0..3).cover?(ULID::TIMESTAMP_ENCODED_LENGTH - ulid.timestamp.squeeze.size) ||
(0..3).cover?(ULID::RANDOMNESS_ENCODED_LENGTH - ulid.randomness.squeeze.size) ||
'000' != ulid.randomness.slice(-3, 3)
(0..3).cover?(ULID::RANDOMNESS_ENCODED_LENGTH - ulid.randomness.squeeze.size) ||
'000' != ulid.randomness.slice(-3, 3)
}

assert_in_epsilon(awesome_randomized_ulids.size, ulids.size, (5/100r).to_f)
end
end

def assert_warning(pattern, &block)
raise(ArgumentError, 'should pass block as an warning sandbox') unless block_given?
raise(ArgumentError, 'should pass block as an warning sandbox') unless block_given?

org_stderr = $stderr
$stderr = fake_io = StringIO.new(+'', 'r+')
Expand Down