From a6e141f8cc76be1b1dc8776ab045b6117cda6d98 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 1 Mar 2024 13:53:05 -0500 Subject: [PATCH 1/3] Remove useless command `spoom files` Signed-off-by: Alexandre Terrasa --- README.md | 8 --- lib/spoom/cli.rb | 20 ------ test/spoom/cli/cli_test.rb | 126 ------------------------------------- 3 files changed, 154 deletions(-) diff --git a/README.md b/README.md index 6a61d4ed..34a4dc47 100644 --- a/README.md +++ b/README.md @@ -56,14 +56,6 @@ Show Sorbet config options: $ spoom config ``` -#### Listing files - -List the files (and related strictness) that will be typchecked with the current Sorbet config options: - -``` -$ spoom files -``` - #### Errors sorting and filtering List all typechecking errors sorted by location: diff --git a/lib/spoom/cli.rb b/lib/spoom/cli.rb index d1939c67..ea62755b 100644 --- a/lib/spoom/cli.rb +++ b/lib/spoom/cli.rb @@ -37,26 +37,6 @@ class Main < Thor desc "tc", "Run Sorbet and parses its output" subcommand "tc", Spoom::Cli::Run - desc "files", "List all the files typechecked by Sorbet" - option :tree, type: :boolean, default: true, desc: "Display list as an indented tree" - option :rbi, type: :boolean, default: false, desc: "Show RBI files" - def files - context = context_requiring_sorbet! - - files = context.srb_files(include_rbis: options[:rbi]) - if files.empty? - say_error("No file matching `#{Sorbet::CONFIG_PATH}`") - exit(1) - end - - if options[:tree] - tree = FileTree.new(files) - tree.print_with_strictnesses(context, colors: options[:color]) - else - puts files - end - end - desc "--version", "Show version" def __print_version puts "Spoom v#{Spoom::VERSION}" diff --git a/test/spoom/cli/cli_test.rb b/test/spoom/cli/cli_test.rb index ce23733c..95091a43 100644 --- a/test/spoom/cli/cli_test.rb +++ b/test/spoom/cli/cli_test.rb @@ -28,7 +28,6 @@ def test_display_help_long_option spoom bump # Bump Sorbet sigils from `false` to `true` when no errors spoom config # Manage Sorbet config spoom coverage # Collect metrics related to Sorbet coverage - spoom files # List all the files typechecked by Sorbet spoom help [COMMAND] # Describe available commands or one specific command spoom lsp # Send LSP requests to Sorbet spoom tc # Run Sorbet and parses its output @@ -41,131 +40,6 @@ def test_display_help_long_option OUT end - - def test_display_files_returns_1_if_no_file - result = @project.spoom("files --no-color") - assert_equal(<<~MSG, result.err) - Error: No file matching `sorbet/config` - MSG - assert_empty(result.out) - refute(result.status) - end - - def test_display_files_from_config - @project.write!("test/a.rb", "# typed: ignore") - @project.write!("test/b.rb", "# typed: false") - @project.write!("lib/c.rb", "# typed: true") - @project.write!("lib/d.rb", "# typed: strict") - @project.write!("lib/e.rb", "# typed: strong") - @project.write!("lib/f.rb", "# typed: __STDLIB_INTERNAL") - result = @project.spoom("files --no-color") - assert_equal(<<~MSG, result.out) - lib/ - c.rb (true) - d.rb (strict) - e.rb (strong) - f.rb (__STDLIB_INTERNAL) - test/ - a.rb (ignore) - b.rb (false) - MSG - end - - def test_display_files_from_config_with_ignored_files - @project.write!("test/a.rb", "# typed: ignore") - @project.write!("test/b.rb", "# typed: false") - @project.write!("lib/c.rb", "# typed: true") - @project.write!("lib/d.rb", "# typed: strict") - @project.write!("lib/e.rb", "# typed: strong") - @project.write!("lib/f.rb", "# typed: __STDLIB_INTERNAL") - @project.write_sorbet_config!(<<~CFG) - . - --ignore=test - CFG - result = @project.spoom("files --no-color") - assert_equal(<<~MSG, result.out) - lib/ - c.rb (true) - d.rb (strict) - e.rb (strong) - f.rb (__STDLIB_INTERNAL) - MSG - end - - def test_display_files_from_config_with_allowed_exts - @project.write!("test/a.rake", "# typed: ignore") - @project.write!("test/b.rbi", "# typed: false") - @project.write!("lib/c.rbi", "# typed: true") - @project.write!("lib/d.ru", "# typed: strict") - @project.write!("lib/e.rb", "# typed: strong") - @project.write!("lib/f.rb", "# typed: __STDLIB_INTERNAL") - @project.write_sorbet_config!(<<~CFG) - . - --allowed-extension=.rake - --allowed-extension=.ru - --allowed-extension=.rb - CFG - result = @project.spoom("files --no-color") - assert_equal(<<~MSG, result.out) - lib/ - d.ru (strict) - e.rb (strong) - f.rb (__STDLIB_INTERNAL) - test/ - a.rake (ignore) - MSG - end - - def test_display_files_with_path_option - project = new_project("test_files") - project.write!("lib/file1.rb", "# typed: true") - project.write!("lib/file2.rb", "# typed: true") - - result = @project.spoom("files --no-color --path #{project.absolute_path}") - assert_equal(<<~MSG, result.out) - lib/ - file1.rb (true) - file2.rb (true) - MSG - end - - def test_display_files_no_tree - @project.write!("test/a.rb", "# typed: ignore") - @project.write!("test/b.rb", "# typed: false") - @project.write!("lib/c.rb", "# typed: true") - @project.write!("lib/d.rb", "# typed: strict") - @project.write!("lib/e.rb", "# typed: strong") - @project.write!("lib/f.rb", "# typed: __STDLIB_INTERNAL") - result = @project.spoom("files --no-color --no-tree") - assert_equal(<<~MSG, result.out) - lib/c.rb - lib/d.rb - lib/e.rb - lib/f.rb - test/a.rb - test/b.rb - MSG - end - - def test_display_files_no_rbi - @project.write!("test/a.rbi", "# typed: ignore") - @project.write!("test/b.rbi", "# typed: false") - @project.write!("lib/c.rb", "# typed: true") - @project.write!("lib/d.rb", "# typed: strict") - @project.write!("lib/e.rbi", "# typed: strong") - @project.write!("lib/f.rbi", "# typed: __STDLIB_INTERNAL") - result = @project.spoom("files --no-color --no-rbi") - assert_equal(<<~MSG, result.out) - lib/ - c.rb (true) - d.rb (strict) - MSG - result = @project.spoom("files --no-color --no-tree --no-rbi") - assert_equal(<<~MSG, result.out) - lib/c.rb - lib/d.rb - MSG - end end end end From 84b34923208f3ac47a85dba3e04cc1ef8526cfe6 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 1 Mar 2024 13:54:16 -0500 Subject: [PATCH 2/3] Remove useless command `spoom config` Signed-off-by: Alexandre Terrasa --- README.md | 10 --- lib/spoom/cli.rb | 4 - test/spoom/cli/cli_test.rb | 1 - test/spoom/cli/config_test.rb | 155 ---------------------------------- 4 files changed, 170 deletions(-) delete mode 100644 test/spoom/cli/config_test.rb diff --git a/README.md b/README.md index 34a4dc47..2bdc67cb 100644 --- a/README.md +++ b/README.md @@ -46,16 +46,6 @@ See all the [Typing Coverage](#typing-coverage) CLI commands for more details. ### Command Line Interface -#### Sorbet configuration commands - -Spoom works with your `sorbet/config` file. No additional configuration is needed. - -Show Sorbet config options: - -``` -$ spoom config -``` - #### Errors sorting and filtering List all typechecking errors sorted by location: diff --git a/lib/spoom/cli.rb b/lib/spoom/cli.rb index ea62755b..00f32f5e 100644 --- a/lib/spoom/cli.rb +++ b/lib/spoom/cli.rb @@ -6,7 +6,6 @@ require_relative "cli/helper" require_relative "cli/bump" -require_relative "cli/config" require_relative "cli/lsp" require_relative "cli/coverage" require_relative "cli/run" @@ -25,9 +24,6 @@ class Main < Thor desc "bump", "Bump Sorbet sigils from `false` to `true` when no errors" subcommand "bump", Spoom::Cli::Bump - desc "config", "Manage Sorbet config" - subcommand "config", Spoom::Cli::Config - desc "coverage", "Collect metrics related to Sorbet coverage" subcommand "coverage", Spoom::Cli::Coverage diff --git a/test/spoom/cli/cli_test.rb b/test/spoom/cli/cli_test.rb index 95091a43..9ed32900 100644 --- a/test/spoom/cli/cli_test.rb +++ b/test/spoom/cli/cli_test.rb @@ -26,7 +26,6 @@ def test_display_help_long_option Commands: spoom --version # Show version spoom bump # Bump Sorbet sigils from `false` to `true` when no errors - spoom config # Manage Sorbet config spoom coverage # Collect metrics related to Sorbet coverage spoom help [COMMAND] # Describe available commands or one specific command spoom lsp # Send LSP requests to Sorbet diff --git a/test/spoom/cli/config_test.rb b/test/spoom/cli/config_test.rb deleted file mode 100644 index d98f662d..00000000 --- a/test/spoom/cli/config_test.rb +++ /dev/null @@ -1,155 +0,0 @@ -# typed: true -# frozen_string_literal: true - -require "test_with_project" - -module Spoom - module Cli - class ConfigTest < TestWithProject - def setup - @project.bundle_install! - end - - def test_return_error_if_no_sorbet_config - @project.remove!("sorbet/config") - result = @project.spoom("config --no-color") - assert_empty(result.out) - assert_equal("Error: not in a Sorbet project (`sorbet/config` not found)", result.err&.lines&.first&.chomp) - refute(result.status) - end - - def test_display_empty_config - @project.write_sorbet_config!("") - result = @project.spoom("config --no-color") - assert_equal(<<~MSG, result.out) - Found Sorbet config at `sorbet/config`. - - Paths typechecked: - * (default: .) - - Paths ignored: - * (default: none) - - Allowed extensions: - * .rb (default) - * .rbi (default) - MSG - end - - def test_display_simple_config - result = @project.spoom("config --no-color") - assert_equal(<<~MSG, result.out) - Found Sorbet config at `sorbet/config`. - - Paths typechecked: - * . - - Paths ignored: - * (default: none) - - Allowed extensions: - * .rb (default) - * .rbi (default) - MSG - end - - def test_display_multi_config - @project.write_sorbet_config!(<<~CFG) - lib - --dir=test - --dir - tasks - CFG - result = @project.spoom("config --no-color") - assert_equal(<<~MSG, result.out) - Found Sorbet config at `sorbet/config`. - - Paths typechecked: - * lib - * test - * tasks - - Paths ignored: - * (default: none) - - Allowed extensions: - * .rb (default) - * .rbi (default) - MSG - end - - def test_display_config_with_ignored_files - @project.write_sorbet_config!(<<~CFG) - lib/project.rb - --ignore=lib/main - --ignore - test - CFG - result = @project.spoom("config --no-color") - assert_equal(<<~MSG, result.out) - Found Sorbet config at `sorbet/config`. - - Paths typechecked: - * lib/project.rb - - Paths ignored: - * lib/main - * test - - Allowed extensions: - * .rb (default) - * .rbi (default) - MSG - end - - def test_display_config_with_allowed_extensions - @project.write_sorbet_config!(<<~CFG) - lib/project.rb - --ignore=lib/main - --ignore - test - --allowed-extension=.rb - --allowed-extension=.rbi - --allowed-extension=.rake - --allowed-extension=.ru - CFG - result = @project.spoom("config --no-color") - assert_equal(<<~MSG, result.out) - Found Sorbet config at `sorbet/config`. - - Paths typechecked: - * lib/project.rb - - Paths ignored: - * lib/main - * test - - Allowed extensions: - * .rb - * .rbi - * .rake - * .ru - MSG - end - - def test_config_with_path_option - project = new_project("test_config_with_path_option") - result = project.spoom("config -p #{@project.absolute_path} --no-color") - assert_equal(<<~MSG, @project.censor_project_path(result.out)) - Found Sorbet config at `/sorbet/config`. - - Paths typechecked: - * . - - Paths ignored: - * (default: none) - - Allowed extensions: - * .rb (default) - * .rbi (default) - MSG - project.destroy! - end - end - end -end From 4f8ddfa615defc94529c2df091f465f4c747cbe5 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Fri, 1 Mar 2024 14:14:44 -0500 Subject: [PATCH 3/3] Remove useless command `spoom lsp show` Signed-off-by: Alexandre Terrasa --- lib/spoom/cli/lsp.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/spoom/cli/lsp.rb b/lib/spoom/cli/lsp.rb index d993e215..6dd288ea 100644 --- a/lib/spoom/cli/lsp.rb +++ b/lib/spoom/cli/lsp.rb @@ -10,17 +10,6 @@ module Cli class LSP < Thor include Helper - default_task :show - - desc "interactive", "Interactive LSP mode" - def show - context_requiring_sorbet! - - lsp = lsp_client - # TODO: run interactive mode - puts lsp - end - desc "list", "List all known symbols" # TODO: options, filter, limit, kind etc.. filter rbi def list