All Projects → grodowski → Undercover

grodowski / Undercover

Licence: mit
Actionable code coverage - detects untested code blocks in recent changes

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Undercover

Editorconfig Checker
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 119 (-79.27%)
Mutual labels:  linter, hacktoberfest, code-quality
Interrogate
Explain yourself! Interrogate a codebase for docstring coverage.
Stars: ✭ 245 (-57.32%)
Mutual labels:  hacktoberfest, coverage, code-quality
Reviewdog
🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+691.11%)
Mutual labels:  linter, cli, code-quality
Wemake Python Styleguide
The strictest and most opinionated python linter ever!
Stars: ✭ 1,714 (+198.61%)
Mutual labels:  linter, hacktoberfest, code-quality
Isort
A Python utility / library to sort imports.
Stars: ✭ 4,377 (+662.54%)
Mutual labels:  linter, cli, hacktoberfest
Ola
The Open Lighting Architecture - The Travel Adaptor for the Lighting Industry
Stars: ✭ 424 (-26.13%)
Mutual labels:  cli, hacktoberfest
Npkill
List any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space.
Stars: ✭ 5,325 (+827.7%)
Mutual labels:  cli, hacktoberfest
Bubbletea
A powerful little TUI framework 🏗
Stars: ✭ 7,886 (+1273.87%)
Mutual labels:  cli, hacktoberfest
Bubbles
TUI components for Bubble Tea 🍡
Stars: ✭ 467 (-18.64%)
Mutual labels:  cli, hacktoberfest
Clusterlint
A best practices checker for Kubernetes clusters. 🤠
Stars: ✭ 409 (-28.75%)
Mutual labels:  linter, hacktoberfest
Simplecov
Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
Stars: ✭ 4,362 (+659.93%)
Mutual labels:  coverage, code-quality
Preact Cli
😺 Your next Preact PWA starts in 30 seconds.
Stars: ✭ 4,510 (+685.71%)
Mutual labels:  cli, hacktoberfest
Cli Microsoft365
Manage Microsoft 365 and SharePoint Framework projects on any platform
Stars: ✭ 420 (-26.83%)
Mutual labels:  cli, hacktoberfest
Sonar Kotlin
SonarQube plugin for Kotlin
Stars: ✭ 412 (-28.22%)
Mutual labels:  linter, code-quality
Ritchie Cli
Ritchie CLI is an open-source tool that allows to create, store and share any kind of automation, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡
Stars: ✭ 437 (-23.87%)
Mutual labels:  cli, hacktoberfest
Phpinsights
🔰 Instant PHP quality checks from your console
Stars: ✭ 4,442 (+673.87%)
Mutual labels:  cli, hacktoberfest
Got
Got: Simple golang package and CLI tool to download large files faster 🏃 than cURL and Wget!
Stars: ✭ 469 (-18.29%)
Mutual labels:  cli, hacktoberfest
Xonsh
🐚 Python-powered, cross-platform, Unix-gazing shell
Stars: ✭ 5,327 (+828.05%)
Mutual labels:  cli, hacktoberfest
Ferret
Declarative web scraping
Stars: ✭ 4,837 (+742.68%)
Mutual labels:  cli, hacktoberfest
Topydo
A powerful todo list application for the console, using the todo.txt format.
Stars: ✭ 511 (-10.98%)
Mutual labels:  cli, hacktoberfest

undercover 👮‍♂️

Like RuboCop but for code coverage. Inspects files in a git diff and warns on changed methods, classes and blocks which need to be tested. Use it locally or as part of an automated build to shorten your code coverage feedback loop!

A sample output of undercover ran before a commit may look like this:

screenshot warning

And like this, given that specs were added:

screenshot success

Build Status Maintainability

Installation

Add this line to your application's Gemfile:

gem 'undercover'

And then execute:

$ bundle

Or install it yourself as:

$ gem install undercover

Setting up required LCOV reporting

To make your specs or tests compatible with undercover by providing an LCOV report, please add simplecov and simplecov-lcov to your test setup.

# Gemfile
group :test do
  gem 'simplecov'
  gem 'simplecov-lcov'
end

# the very top of spec_helper.rb
require 'simplecov'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
SimpleCov.start do
  add_filter(/^\/spec\//) # For RSpec
  add_filter(/^\/test\//) # For Minitest
  enable_coverage(:branch) # Report branch coverage to trigger branch-level undercover warnings
end

require 'undercover'

# ...

Then run your test suite once through to generate the initial coverage/lcov/*.lcov file before you can run the undercover command

Usage

Invoked with no arguments, Undercover will flag all untested methods and classes from the current diff:

undercover

Use the -c --compare ref flag to specify a git ref (commit hash, branch name, tag) to compare against. This is a recommended usage for CI/CD build environments, as undercover will exit 1 if there are any warnings.

undercover --compare origin/master

Check out docs/ for CI configuration examples:

Merging coverage results (sample gist) is required for parallel tests before processing with undercover.

Code review integrations

A few options exist to provide automated comments from undercover in Pull Request reviews, which is the most streamlined way to add Undercover to your development workflow.

Configuration

CLI Options

Options can be passed when running the command from the command line:

undercover -h
Usage: undercover [options]
    -l, --lcov path                  LCOV report file path
    -p, --path path                  Project directory
    -g, --git-dir dir                Override `.git` with a custom directory
    -c, --compare ref                Generate coverage warnings for all changes after `ref`
    -h, --help                       Prints this help
        --version                    Show version

Configuration File

A configuration file named .undercover can be created at the top level of a project's directory containing the same set of options for the CLI. Example file:

-l path/to/different.lcov
-c origin/master

The options set in the file can be overriden by passing arguments when invoking the executable.

Options assume that the program is run from the top level of the project directory.

Why?

I wanted to create a tool to help others and myself ensure that tests are written for all the recent code changes. This should be useful for any ruby project, but especially those large or legacy codebases that lack testing (and we can't or don't want to invest in full test coverage).

The goal was to provide automated warnings, that are:

  • relevant, so scoped to the actual code changes
  • timely, so we don't end up writing tests long after the implementation
  • actionable, so we can fix them before the code is committed or reaches production

For more background, please read the blog post.

Development

After checking out the repo, run bundle to install dependencies. Then, run rake to run the tests and RuboCop. You can also run pry -r 'undercover' for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/grodowski/undercover.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].