-
Notifications
You must be signed in to change notification settings - Fork 23
Migrate all T::Enum usages to bare Ruby classes
#843
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
base: main
Are you sure you want to change the base?
Changes from all commits
eec680c
b286e11
a57b2e9
62cd6bd
dcab5c7
40f6f84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,6 @@ Sorbet/TrueSigil: | |
|
|
||
| Sorbet/EnforceSigilOrder: | ||
| Enabled: true | ||
|
|
||
| Sorbet/ForbidTEnum: | ||
| Enabled: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,8 @@ module Spoom::Cli::Helper | |
| def yellow(string); end | ||
| end | ||
|
|
||
| Spoom::Cli::Helper::HIGHLIGHT_COLOR = T.let(T.unsafe(nil), Spoom::Color) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where did this come from?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be definitely be here: https://github.com/Shopify/spoom/blob/main/lib/spoom/cli/helper.rb#L106. I think it wasn't before because the constant was pointing to the enum variant instead of a real constant.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, makes sense! |
||
|
|
||
| class Spoom::Cli::Main < ::Thor | ||
| include ::Spoom::Colorize | ||
| include ::Spoom::Cli::Helper | ||
|
|
@@ -212,32 +214,33 @@ Spoom::Cli::Srb::Tc::SORT_CODE = T.let(T.unsafe(nil), String) | |
| Spoom::Cli::Srb::Tc::SORT_ENUM = T.let(T.unsafe(nil), Array) | ||
| Spoom::Cli::Srb::Tc::SORT_LOC = T.let(T.unsafe(nil), String) | ||
|
|
||
| class Spoom::Color < ::T::Enum | ||
| enums do | ||
| BLACK = new | ||
| BLUE = new | ||
| BOLD = new | ||
| CLEAR = new | ||
| CYAN = new | ||
| GREEN = new | ||
| LIGHT_BLACK = new | ||
| LIGHT_BLUE = new | ||
| LIGHT_CYAN = new | ||
| LIGHT_GREEN = new | ||
| LIGHT_MAGENTA = new | ||
| LIGHT_RED = new | ||
| LIGHT_WHITE = new | ||
| LIGHT_YELLOW = new | ||
| MAGENTA = new | ||
| RED = new | ||
| WHITE = new | ||
| YELLOW = new | ||
| end | ||
| class Spoom::Color | ||
| sig { params(ansi_code: ::String).void } | ||
| def initialize(ansi_code); end | ||
|
|
||
| sig { returns(::String) } | ||
| def ansi_code; end | ||
| end | ||
|
|
||
| Spoom::Color::BLACK = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::BLUE = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::BOLD = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::CLEAR = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::CYAN = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::GREEN = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_BLACK = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_BLUE = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_CYAN = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_GREEN = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_MAGENTA = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_RED = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_WHITE = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::LIGHT_YELLOW = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::MAGENTA = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::RED = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::WHITE = T.let(T.unsafe(nil), Spoom::Color) | ||
| Spoom::Color::YELLOW = T.let(T.unsafe(nil), Spoom::Color) | ||
|
|
||
| module Spoom::Colorize | ||
| sig { params(string: ::String, color: ::Spoom::Color).returns(::String) } | ||
| def set_color(string, *color); end | ||
|
|
@@ -999,25 +1002,25 @@ class Spoom::Deadcode::Definition < ::T::Struct | |
| def to_json(*args); end | ||
| end | ||
|
|
||
| class Spoom::Deadcode::Definition::Kind < ::T::Enum | ||
| enums do | ||
| AttrReader = new | ||
| AttrWriter = new | ||
| Class = new | ||
| Constant = new | ||
| Method = new | ||
| Module = new | ||
| end | ||
| end | ||
| class Spoom::Deadcode::Definition::Kind | ||
| sig { params(name: ::String).void } | ||
| def initialize(name); end | ||
|
|
||
| class Spoom::Deadcode::Definition::Status < ::T::Enum | ||
| enums do | ||
| ALIVE = new | ||
| DEAD = new | ||
| IGNORED = new | ||
| end | ||
| sig { override.returns(::String) } | ||
| def to_s; end | ||
| end | ||
|
|
||
| Spoom::Deadcode::Definition::Kind::AttrReader = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| Spoom::Deadcode::Definition::Kind::AttrWriter = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| Spoom::Deadcode::Definition::Kind::Class = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| Spoom::Deadcode::Definition::Kind::Constant = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| Spoom::Deadcode::Definition::Kind::Method = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| Spoom::Deadcode::Definition::Kind::Module = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Kind) | ||
| class Spoom::Deadcode::Definition::Status; end | ||
| Spoom::Deadcode::Definition::Status::ALIVE = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Status) | ||
| Spoom::Deadcode::Definition::Status::DEAD = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Status) | ||
| Spoom::Deadcode::Definition::Status::IGNORED = T.let(T.unsafe(nil), Spoom::Deadcode::Definition::Status) | ||
|
|
||
| class Spoom::Deadcode::ERB < ::Erubi::Engine | ||
| sig { params(input: T.untyped, properties: T.untyped).void } | ||
| def initialize(input, properties = T.unsafe(nil)); end | ||
|
|
@@ -2277,13 +2280,14 @@ class Spoom::Model::Reference < ::T::Struct | |
| end | ||
| end | ||
|
|
||
| class Spoom::Model::Reference::Kind < ::T::Enum | ||
| enums do | ||
| Constant = new | ||
| Method = new | ||
| end | ||
| class Spoom::Model::Reference::Kind | ||
| sig { params(name: ::String).void } | ||
| def initialize(name); end | ||
| end | ||
|
|
||
| Spoom::Model::Reference::Kind::Constant = T.let(T.unsafe(nil), Spoom::Model::Reference::Kind) | ||
| Spoom::Model::Reference::Kind::Method = T.let(T.unsafe(nil), Spoom::Model::Reference::Kind) | ||
|
|
||
| class Spoom::Model::ReferencesVisitor < ::Spoom::Visitor | ||
| sig { params(file: ::String).void } | ||
| def initialize(file); end | ||
|
|
@@ -2433,14 +2437,22 @@ class Spoom::Model::UnresolvedSymbol < ::Spoom::Model::Symbol | |
| def to_s; end | ||
| end | ||
|
|
||
| class Spoom::Model::Visibility < ::T::Enum | ||
| enums do | ||
| Private = new | ||
| Protected = new | ||
| Public = new | ||
| class Spoom::Model::Visibility | ||
| sig { params(name: ::String).void } | ||
| def initialize(name); end | ||
|
|
||
| sig { override.returns(::String) } | ||
| def to_s; end | ||
|
|
||
| class << self | ||
| sig { params(name: ::String).returns(::Spoom::Model::Visibility) } | ||
| def from_string(name); end | ||
| end | ||
| end | ||
|
|
||
| Spoom::Model::Visibility::Private = T.let(T.unsafe(nil), Spoom::Model::Visibility) | ||
| Spoom::Model::Visibility::Protected = T.let(T.unsafe(nil), Spoom::Model::Visibility) | ||
| Spoom::Model::Visibility::Public = T.let(T.unsafe(nil), Spoom::Model::Visibility) | ||
| class Spoom::ParseError < ::Spoom::Error; end | ||
|
|
||
| class Spoom::Poset | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to raise
ArgumentErrorhere: