Skip to content

Commit c4cc44a

Browse files
fix(internal): ensure formatting always uses c.utf-8 locale
1 parent e572719 commit c4cc44a

File tree

588 files changed

+82722
-63016
lines changed

Some content is hidden

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

588 files changed

+82722
-63016
lines changed

.rubocop.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ Layout/MultilineMethodParameterLineBreaks:
6363
# Prefer compact hash literals.
6464
Layout/SpaceInsideHashLiteralBraces:
6565
EnforcedStyle: no_space
66+
Exclude:
67+
- "**/*.rbi"
6668

6769
Lint/BooleanSymbol:
6870
Enabled: false
@@ -90,6 +92,10 @@ Lint/MissingSuper:
9092
Exclude:
9193
- "**/*.rbi"
9294

95+
Lint/SymbolConversion:
96+
Exclude:
97+
- "**/*.rbi"
98+
9399
# Disabled for safety reasons, this option changes code semantics.
94100
Lint/UnusedMethodArgument:
95101
AutoCorrect: false
@@ -244,6 +250,10 @@ Style/RedundantInitialize:
244250
Exclude:
245251
- "**/*.rbi"
246252

253+
Style/RedundantParentheses:
254+
Exclude:
255+
- "**/*.rbi"
256+
247257
# Prefer slashes for regex literals.
248258
Style/RegexpLiteral:
249259
EnforcedStyle: slashes

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: https://github.com/stainless-api/syntax_tree-rbs.git
3-
revision: 140eb3ba2ff4b959b345ac2a7927cd758a9f1284
3+
revision: c30b50219918be7cfe3ef803a00b59d1e77fcada
44
branch: main
55
specs:
66
syntax_tree-rbs (1.0.0)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ Sorbet's typed enums require sub-classing of the [`T::Enum` class](https://sorbe
200200
Since this library does not depend on `sorbet-runtime`, it uses a [`T.all` intersection type](https://sorbet.org/docs/intersection-types) with a ruby primitive type to construct a "tagged alias" instead.
201201

202202
```ruby
203-
module Orb::Models::BillingCycleRelativeDate
203+
module Orb::BillingCycleRelativeDate
204204
# This alias aids language service driven navigation.
205-
TaggedSymbol = T.type_alias { T.all(Symbol, Orb::Models::BillingCycleRelativeDate) }
205+
TaggedSymbol = T.type_alias { T.all(Symbol, Orb::BillingCycleRelativeDate) }
206206
end
207207
```
208208

Rakefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,40 @@ multitask(:test) do
3434
ruby(*%w[-w -e], rb, verbose: false) { fail unless _1 }
3535
end
3636

37-
rubo_find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
3837
xargs = %w[xargs --no-run-if-empty --null --max-procs=0 --max-args=300 --]
38+
locale = {"LC_ALL" => "C.UTF-8"}
3939

4040
desc("Lint `*.rb(i)`")
4141
multitask(:"lint:rubocop") do
42+
find = %w[find ./lib ./test ./rbi -type f -and ( -name *.rb -or -name *.rbi ) -print0]
43+
4244
rubocop = %w[rubocop --fail-level E]
4345
rubocop += %w[--format github] if ENV.key?("CI")
4446

4547
# some lines cannot be shortened
4648
rubocop += %w[--except Lint/RedundantCopDisableDirective,Layout/LineLength]
4749

4850
lint = xargs + rubocop
49-
sh("#{rubo_find.shelljoin} | #{lint.shelljoin}")
51+
sh("#{find.shelljoin} | #{lint.shelljoin}")
5052
end
5153

52-
desc("Format `*.rb(i)`")
53-
multitask(:"format:rubocop") do
54+
desc("Format `*.rb`")
55+
multitask(:"format:rb") do
56+
# while `syntax_tree` is much faster than `rubocop`, `rubocop` is the only formatter with full syntax support
57+
find = %w[find ./lib ./test -type f -and -name *.rb -print0]
5458
fmt = xargs + %w[rubocop --fail-level F --autocorrect --format simple --]
55-
sh("#{rubo_find.shelljoin} | #{fmt.shelljoin}")
59+
sh("#{find.shelljoin} | #{fmt.shelljoin}")
60+
end
61+
62+
desc("Format `*.rbi`")
63+
multitask(:"format:rbi") do
64+
find = %w[find ./rbi -type f -and -name *.rbi -print0]
65+
fmt = xargs + %w[stree write --]
66+
sh(locale, "#{find.shelljoin} | #{fmt.shelljoin}")
5667
end
5768

5869
desc("Format `*.rbs`")
59-
multitask(:"format:syntax_tree") do
70+
multitask(:"format:rbs") do
6071
find = %w[find ./sig -type f -name *.rbs -print0]
6172
inplace = /darwin|bsd/ =~ RUBY_PLATFORM ? ["-i", ""] : %w[-i]
6273
uuid = SecureRandom.uuid
@@ -88,7 +99,7 @@ multitask(:"format:syntax_tree") do
8899
# transform class aliases to type aliases, which syntax tree has no trouble with
89100
sh("#{find.shelljoin} | #{pre.shelljoin}")
90101
# run syntax tree to format `*.rbs` files
91-
sh("#{find.shelljoin} | #{fmt.shelljoin}") do
102+
sh(locale, "#{find.shelljoin} | #{fmt.shelljoin}") do
92103
success = _1
93104
end
94105
# transform type aliases back to class aliases
@@ -99,7 +110,7 @@ multitask(:"format:syntax_tree") do
99110
end
100111

101112
desc("Format everything")
102-
multitask(format: [:"format:rubocop", :"format:syntax_tree"])
113+
multitask(format: [:"format:rb", :"format:rbi", :"format:rbs"])
103114

104115
desc("Typecheck `*.rbs`")
105116
multitask(:"typecheck:steep") do

lib/orb.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
require_relative "orb/models/top_level_ping_response"
220220
require_relative "orb/models/trial_discount"
221221
require_relative "orb/models/usage_discount"
222+
require_relative "orb/models"
222223
require_relative "orb/resources/alerts"
223224
require_relative "orb/resources/coupons"
224225
require_relative "orb/resources/coupons/subscriptions"

lib/orb/file_part.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def initialize(content, filename: nil, content_type: nil)
4545
@filename =
4646
case content
4747
in Pathname
48-
filename.nil? ? content.basename.to_path : File.basename(filename)
48+
filename.nil? ? content.basename.to_path : ::File.basename(filename)
4949
else
50-
filename.nil? ? nil : File.basename(filename)
50+
filename.nil? ? nil : ::File.basename(filename)
5151
end
5252
@content_type = content_type
5353
end

lib/orb/internal/type/enum.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ module Type
1717
# values safely.
1818
#
1919
# @example
20-
# # `billing_cycle_relative_date` is a `Orb::Models::BillingCycleRelativeDate`
20+
# # `billing_cycle_relative_date` is a `Orb::BillingCycleRelativeDate`
2121
# case billing_cycle_relative_date
22-
# when Orb::Models::BillingCycleRelativeDate::START_OF_TERM
22+
# when Orb::BillingCycleRelativeDate::START_OF_TERM
2323
# # ...
24-
# when Orb::Models::BillingCycleRelativeDate::END_OF_TERM
24+
# when Orb::BillingCycleRelativeDate::END_OF_TERM
2525
# # ...
2626
# else
2727
# puts(billing_cycle_relative_date)

lib/orb/internal/type/request_parameters.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module Internal
55
module Type
66
# @api private
77
module RequestParameters
8-
# @!parse
9-
# # Options to specify HTTP behaviour for this request.
10-
# # @return [Orb::RequestOptions, Hash{Symbol=>Object}]
11-
# attr_accessor :request_options
8+
# @!attribute request_options
9+
# Options to specify HTTP behaviour for this request.
10+
#
11+
# @return [Orb::RequestOptions, Hash{Symbol=>Object}]
1212

1313
# @param mod [Module]
1414
def self.included(mod)

lib/orb/internal/type/union.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ module Type
66
# @api private
77
#
88
# @example
9-
# # `discount` is a `Orb::Models::Discount`
9+
# # `discount` is a `Orb::Discount`
1010
# case discount
11-
# when Orb::Models::PercentageDiscount
11+
# when Orb::PercentageDiscount
1212
# puts(discount.applies_to_price_ids)
13-
# when Orb::Models::TrialDiscount
13+
# when Orb::TrialDiscount
1414
# puts(discount.discount_type)
15-
# when Orb::Models::UsageDiscount
15+
# when Orb::UsageDiscount
1616
# puts(discount.usage_discount)
1717
# else
1818
# puts(discount)

lib/orb/internal/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class << self
535535
filename = ERB::Util.url_encode(val.filename)
536536
y << "; filename=\"#{filename}\""
537537
in Pathname | IO
538-
filename = ERB::Util.url_encode(File.basename(val.to_path))
538+
filename = ERB::Util.url_encode(::File.basename(val.to_path))
539539
y << "; filename=\"#{filename}\""
540540
else
541541
end

0 commit comments

Comments
 (0)