Skip to content
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

Delete some useless commands #520

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +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
```

#### 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:
Expand Down
24 changes: 0 additions & 24 deletions lib/spoom/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Expand All @@ -37,26 +33,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}"
Expand Down
11 changes: 0 additions & 11 deletions lib/spoom/cli/lsp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
127 changes: 0 additions & 127 deletions test/spoom/cli/cli_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ 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 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
Expand All @@ -41,131 +39,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
155 changes: 0 additions & 155 deletions test/spoom/cli/config_test.rb

This file was deleted.

Loading