Drive higher confidence in making changes by detecting large blocks of untested functionality


go-coverage

Increase code coverage of Go projects

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap

About The Project

The key challenge with large code bases with low test coverage is to prioritize which sections of code to test first.

The standard coverage tools tell about the code coverage percentage and what is covered and uncovered however it doesn't give an input on which functions to cover first and what will be the impact of covering them.

This tool addresses the challenge by providing the sorted list of functions to cover and the impact associated with covering it.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

You'll need Go installed to use this tool. Here is the installation instructions for Go.

Installation

Via go get

go get -u github.com/gojek/go-coverage

Usage

Prerequisites

Generate the coverage profile for your Go codebase, usually done via

go test ./... -coverprofile=coverage.out

Get lines uncovered greater than 10

go-coverage -f coverage.out --line-filter 10

Get trimmed file names

go-coverage -f coverage.out --line-filter 10 --trim
+-------------------------+-------------------------------------+-----------------+--------+
|          FILE           |              FUNCTION               | UNCOVERED LINES | IMPACT |
+-------------------------+-------------------------------------+-----------------+--------+
| ...ice/config/config.go | RadiusForClosestDriverByServicetype |              26 |    1.9 |
| ...ice/config/config.go | RadiusForServicetype                |              26 |    1.9 |
| ...ice/config/config.go | AliceDriverLimit                    |              26 |    1.9 |
| ...ice/config/config.go | ConsumerDriverLimitByServicetype    |              26 |    1.9 |
| .../service/handlers.go | findDriver                          |              19 |    1.4 |
| ...ice/extern/driver.go | driverAllocationStatusFromAPI       |              19 |    1.4 |
| .../service/handlers.go | updateDriverVehicleTags             |              18 |    1.3 |
| ...ice/config/config.go | ConsumerDriverLimit                 |              14 |    1.0 |
| ...vice/service/cron.go | startCrons                          |              14 |    1.0 |
| ...ice/config/config.go | RadiusForVehicleType                |              13 |    0.9 |
| ...ice/config/config.go | matchVehicleType                    |              12 |    0.9 |
| ...rvice/service/api.go | startServer                         |              11 |    0.8 |
+-------------------------+-------------------------------------+-----------------+--------+

Exclude file name pattern

go-coverage -f coverage.out --exclude ".*config.*" --line-filter 10 --trim
+-------------------------+-------------------------------+-----------------+--------+
|          FILE           |           FUNCTION            | UNCOVERED LINES | IMPACT |
+-------------------------+-------------------------------+-----------------+--------+
| .../service/handlers.go | findDriver                    |              19 |    1.4 |
| ...ice/extern/driver.go | driverAllocationStatusFromAPI |              19 |    1.4 |
| .../service/handlers.go | updateDriverVehicleTags       |              18 |    1.3 |
| ...vice/service/cron.go | startCrons                    |              14 |    1.0 |
| ...rvice/service/api.go | startServer                   |              11 |    0.8 |
+-------------------------+-------------------------------+-----------------+--------+

Roadmap

  • Support generation of HTML
  • Integrate with gitlab
Owner
Gojek
SuperApp from Southeast Asia
Gojek
Similar Resources

Download an upload large files to Google Drive (API v3)

gdriver gdriver is a command-line tool, written in Go, used for uploading and downloading large personal files from Google Drive (API v3). The tool pr

Nov 30, 2022

apicompat checks recent changes to a Go project for backwards incompatible changes

Introduction apicompat is a tool to check for the introduction of backwards incompatible changes. apicompat: Guarantees that all consumers of a librar

Dec 24, 2022

ChangeTower is intended to help you watch changes in webpages and get notified of any changes written in Go

ChangeTower is intended to help you watch changes in webpages and get notified of any changes written in Go

Nov 17, 2022

gosx-notifier is a Go framework for sending desktop notifications to OSX 10.8 or higher

gosx-notifier is a Go framework for sending desktop notifications to OSX 10.8 or higher

gosx-notifier A Go lib for sending desktop notifications to OSX Mountain Lion's (10.8 or higher REQUIRED) Notification Center. Update 4/3/2014 On OSX

Dec 28, 2022

Bubbly is an open-source platform that gives you confidence in your continuous release process.

Bubbly is an open-source platform that gives you confidence in your continuous release process.

Bubbly Bubbly - Release Readiness in a Bubble Bubbly emerged from a need that many lean software teams practicing Continuous Integration and Delivery

Nov 29, 2022

Higher level abstraction for Sarama.

Higher level abstraction for Sarama.

kafka-do v0.1.5 kafka-do What Higher level abstraction for Sarama. Why We want to be able to write our kafka applications without making the same thin

Sep 30, 2021

Higher Order Functions using Golang Generics (Hack Days 2022)

hoff: Higher Order Functions (and Friends) Golang 1.18+ implementations of common methods/data structures using Go Generics Requirements Go 1.18 or ne

Jan 4, 2023

Drone Plugin for detecting credentials or other sensitive data in your repository

A plugin to detect hard-coded secrets and sensitive data in your source code files. Building Build the plugin binary: scripts/build.sh Build the plug

Apr 21, 2022

Go library for detecting and expanding the user's home directory without cgo.

go-homedir This is a Go library for detecting the user's home directory without the use of cgo, so the library can be used in cross-compilation enviro

Jan 5, 2023

:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions

Package assert Package assert is a Basic Assertion library used along side native go testing Installation Use go get. go get github.com/go-playground/

Jan 6, 2023

A tool to dump and restore Prometheus data blocks.

A tool to dump and restore Prometheus data blocks.

promdump promdump dumps the head and persistent blocks of Prometheus. It supports filtering the persistent blocks by time range. Why This Tool When de

Dec 16, 2022

Geth client which picks the most profitable blocks to mine using a greedy algorithm

Greeden-Geth Greeden-Geth is a protocol-agnostic client which uses a greedy algorithm to pick the most profitable blocks to submit to the network out

Nov 16, 2022

Flashbots utilities in Go: Blocks & Transactions API, and tools to spot bundle and block irregularities

Utilities for Flashbots Go API client for the mev-blocks API for information about Flashbots blocks and transactions Detect bundle errors: (a) out of

Nov 26, 2022

Tanzu Framework provides a set of building blocks to build atop of the Tanzu platform and leverages Carvel packaging

Tanzu Framework provides a set of building blocks to build atop of the Tanzu platform and leverages Carvel packaging and plugins to provide users with a much stronger, more integrated experience than the loose coupling and stand-alone commands of the previous generation of tools.

Dec 16, 2022

Package buildinfo provides basic building blocks and instructions to easily add build and release information to your app.

Package buildinfo provides basic building blocks and instructions to easily add build and release information to your app.

Package buildinfo provides basic building blocks and instructions to easily add build and release information to your app. This is done by replacing variables in main during build with ldflags.

Nov 14, 2021

Log4Shell: a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values

Log4Shell: a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values

Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your ex

Dec 26, 2022

Log4Shell is a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values.

Log4Shell Mitigation Log4Shell is a middleware plugin for Traefik which blocks JNDI attacks based on HTTP header values. Related to the Log4J CVE: htt

Dec 20, 2022

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.

Arista Go library areflect Helper functions to work with the reflect package. Contains ForceExport(), which bypasses the check in reflect.Value that p

Dec 14, 2022
Comments
  • go install doesn't work

    go install doesn't work

    newer programs (such as this tool) should be installed by the command: go install github.com/gojek/go-coverage@latest instead of the go get -u variant

    But if i do that, there is something wrong: go: downloading github.com/gojek/go-coverage v0.0.1 go install: github.com/gojek/go-coverage@latest: github.com/gojek/[email protected]: parsing go.mod: module declares its path as: github.com/gojekfarm/go-coverage but was required as: github.com/gojek/go-coverage

    Great idea for that tool BTW :-)

  • Only include functions with lines considered on the report

    Only include functions with lines considered on the report

    This change avoids to add functions that have no lines on the coverage report, needed for reports filtered by line, as in a PR changes coverage report.

    Currently it is reporting 1 line missing coverage of every function not present on the report. This could be seen for example with this report, which was filtered to only the first two blocks of code:

    mode: atomic
    github.com/gojek/go-coverage/go_coverage.go:22.13,58.38 2 0
    github.com/gojek/go-coverage/go_coverage.go:99.2,100.16 2 0
    

    Currently it returns:

    +-------------------------+--------------------+-----------------+--------+
    |          FILE           |      FUNCTION      | UNCOVERED LINES | IMPACT |
    +-------------------------+--------------------+-----------------+--------+
    | ...erage/go_coverage.go | main               |               4 |   26.7 |
    | ...erage/go_coverage.go | getTrimmedFileName |               1 |    6.7 |
    | ...erage/go_coverage.go | fmtFuncInfo        |               1 |    6.7 |
    | ...erage/go_coverage.go | printBat           |               1 |    6.7 |
    | ...erage/go_coverage.go | calculateCoverage  |               1 |    6.7 |
    | ...erage/go_coverage.go | printTable         |               1 |    6.7 |
    | ...erage/go_coverage.go | getFunctionInfos   |               1 |    6.7 |
    | ...erage/go_coverage.go | trimString         |               1 |    6.7 |
    | ...erage/go_coverage.go | findFuncs          |               1 |    6.7 |
    | ...erage/go_coverage.go | Visit              |               1 |    6.7 |
    | ...erage/go_coverage.go | coverage           |               1 |    6.7 |
    | ...erage/go_coverage.go | findFile           |               1 |    6.7 |
    +-------------------------+--------------------+-----------------+--------+
    

    With this changes will return only the functions present on the report :

    +-------------------------+----------+-----------------+--------+
    |          FILE           | FUNCTION | UNCOVERED LINES | IMPACT |
    +-------------------------+----------+-----------------+--------+
    | ...erage/go_coverage.go | main     |               4 |  100.0 |
    +-------------------------+----------+-----------------+--------+
    
  • have option not to use full path

    have option not to use full path

    It would be nice if there was an option, like --trim, not to use the full path. in the coverage file itself, files are not shown as a filepath, but as a URI. github.com/company/software/dir/package/somefunc.go instead of: /Users/marcelloh/data/company/software/dir//package/somefunc.go

    The reason is, that I might use it in a presentation towards the customer, and it doesn't look professional when my name is in there. Or perhaps you can just start at the current dir (and remove everything in front of that.

This testing tool surrounds go-ethereum with cannon to catch the blocks of retesteth going into go-ethereum and test cannon with them

Siege This testing tool surrounds go-ethereum with cannon to catch the blocks of retesteth going into go-ethereum and test cannon with them. Usage Sta

Mar 15, 2022
A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

About chromedp Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go without external dependencies

Jan 4, 2023
A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

About chromedp Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go without external dependencies

Dec 28, 2022
Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Jan 6, 2023
Command-line tool to organize large directories of media files recursively by date, detecting duplicates.

go-media-organizer Command-line tool written in Go to organise all media files in a directory recursively by date, detecting duplicates.

Jan 6, 2022
Middleware for Blocking IP ranges by inserting CIDR Blocks and searching IPs through those blocks

firewall Middleware for Blocking IP ranges by inserting CIDR Blocks and searching IPs through those blocks. Features Easy to use Efficient and Fast Co

Oct 9, 2022
"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Yandex Files

Website | Documentation | Download | Contributing | Changelog | Installation | Forum Rclone Rclone ("rsync for cloud storage") is a command-line progr

Jan 9, 2023