Class: Spoom::Cli::Srb::Metrics
- Inherits:
-
Thor
- Object
- Thor
- Spoom::Cli::Srb::Metrics
- Includes:
- Helper
- Defined in:
- lib/spoom/cli/srb/metrics.rb
Constant Summary
Constants included from Helper
Instance Method Summary collapse
Methods included from Helper
#blue, #collect_files, #color?, #colorize, #context, #context_requiring_sorbet!, #cyan, #exec_path, #gray, #green, #highlight, #red, #say, #say_error, #say_warning, #yellow
Methods included from Spoom::Colorize
Instance Method Details
#show(*paths) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/spoom/cli/srb/metrics.rb', line 14 def show(*paths) files = collect_files(paths) metrics = Spoom::Sorbet::Metrics.collect_code_metrics(files) if [:dump] metrics.sort_by { |key, _value| key }.each do |key, value| puts "#{key} #{value}" end return end say("Files: `#{files.size}`") ["classes", "modules", "singleton_classes"].each do |key| value = metrics[key] next if value == 0 say("\n#{key.capitalize}: `#{value}`") ["with_srb_type_params", "with_rbs_type_params"].each do |subkey| say(" * #{subkey.gsub("_", " ")}: `#{metrics["#{key}_#{subkey}"]}`") end end ["methods", "accessors"].each do |key| value = metrics[key] next if value == 0 say("\n#{key.capitalize}: `#{value}`") ["without_sig", "with_srb_sig", "with_rbs_sig"].each do |subkey| say(" * #{subkey.gsub("_", " ")}: `#{metrics["#{key}_#{subkey}"]}`") end end say("\nT. calls: `#{metrics["T_calls"]}`") metrics .select { |key, _value| key.start_with?("T.") } .sort_by { |_key, value| -value } .each do |key, value| say(" * #{key}: `#{value}`") end say("\nRBS Assertions: `#{metrics["rbs_assertions"]}`") metrics .reject { |key, _value| key == "rbs_assertions" } .select { |key, _value| key.start_with?("rbs_") } .sort_by { |_key, value| -value } .each do |key, value| say(" * #{key}: `#{value}`") end end |