Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
issyl0 committed Mar 30, 2024
1 parent 67a096f commit 828e214
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions Library/Homebrew/sorbet/tapioca/compilers/tty.rb
Expand Up @@ -9,25 +9,19 @@ module Compilers
class Tty < Tapioca::Dsl::Compiler
# FIXME: Enable cop again when https://github.com/sorbet/sorbet/issues/3532 is fixed.
# rubocop:disable Style/MutableConstant
# This should be a module whose singleton class contains RuboCop::AST::NodePattern::Macros,
# but I don't know how to express that in Sorbet.
ConstantType = type_member { { fixed: Module } }
# rubocop:enable Style/MutableConstant

sig { override.returns(T::Enumerable[Module]) }
def self.gather_constants
[::Tty]
end
def self.gather_constants = [::Tty]

sig { override.void }
def decorate
root.create_module("Tty") do |mod|
dynamic_methods = ::Tty::COLOR_CODES.keys + ::Tty::STYLE_CODES.keys + ::Tty::SPECIAL_CODES.keys
methods = ::Tty.methods(false).sort.select { |method| dynamic_methods.include?(method) }

methods.each do |method|
return_type = (method.to_s.end_with?("?") ? "T::Boolean" : "String")
mod.create_method(method.to_s, return_type:, class_method: true)
dynamic_methods.each do |method|
mod.create_method(method.to_s, return_type: "String", class_method: true)
end
end
end
Expand Down

0 comments on commit 828e214

Please sign in to comment.