Skip to content

Add a show command that prints annotated source in the terminal #1270

Description

@sferik

go tool cover and llvm-cov show both print annotated source in the terminal, and it is the fastest way to answer "what is missing in this file" without leaving the shell or forwarding a port off a CI box.

simplecov coverage <path> already resolves a path against SimpleCov.root and prints its totals. simplecov show <path> would print the source itself, with hit counts in the gutter and misses called out:

$ simplecov show lib/simplecov/cli/diff.rb
   38    1  def call(baseline)
   39    1    rows = compare(current, load(baseline))
   40    0    return EXIT_FAILURE if rows.empty?
              ^ missed

--uncovered-only collapses it to the ranges alone:

$ simplecov show --uncovered-only lib/simplecov/cli/diff.rb
lib/simplecov/cli/diff.rb:40,52-58,71

That second form is worth more than it looks. It is greppable, it fits in a commit message, and it is the right thing to hand a coding agent asked to write the missing tests, which is a workflow a lot of people now have and which the HTML report serves badly. Branch and method misses annotate the same way when those criteria are enabled, and the colors should follow the same NO_COLOR and TTY rules SimpleCov::Color already applies.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions