qual

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Build Status codecov Maintainability

qual - Quality assessment at source code level

Quick start

go get github.com/gregoryv/qual

Add a unit test to your project

func Test_CodeQuality(t *testing.T) {
    qual.Standard(t)
}

or if you are really brave, do

func Test_CodeQuality(t *testing.T) {
    qual.High(t)
}

The predefined tests measure

  • code complexity
  • line width

where the qual.Standard test only checks your package and qual.High also includes vendored code.

Scope

This package helps to improve code readability. Note, it's not measuring the quality of features in your solution. Those are better measured with benchmarks and user experience. The quality of the source code helps developers pass on their intent of their solution to other developers. We do this in various ways

  • documenting
  • tests and examples and most importantly
  • writing readable code

If we can write readable code, documentation can be minimized and that is always good, since developers tend to prefer writing code over documentation.

Documentation

Overview

Package qual implements tests and helpers for writing highly readable code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CyclomaticComplexity

func CyclomaticComplexity(max int, includeVendor bool, t T)

CyclomaticComplexity fails if max is exceeded in any go files of this project.

func FuncHeight added in v0.4.0

func FuncHeight(maxLines int, includeVendor bool, t T)

FuncHeight fails if any func body exceeds maxLines. All lines are considered, source and comments.

func Gofumpt added in v0.5.0

func Gofumpt(t T)

Gofumpt uses gofumpt -l . command to check if files have been formatted.

func High

func High(t T)

High is the same as Standard, only it includes all vendor source as well.

func Standard

func Standard(t T)

Standard tests a set of metrics which might be considered necessary for production code. This is very opinionated, but the values are based on community insights from various sources.

Types

type LineLength

type LineLength struct {
	MaxChars         int
	TabSize          int
	IncludeVendor    bool
	IncludeGenerated bool
	// Set to true if lines with urls should be considered
	IncludeURLs bool
	// contains filtered or unexported fields
}

func (*LineLength) Test added in v0.5.0

func (l *LineLength) Test(t T)

LineLength fails if any go file contains lines exceeding maxChars. All lines are considered, source and comments.

type T

type T interface {
	Helper()
	Error(...interface{})
	Errorf(string, ...interface{})
}

Directories

Path Synopsis
internal
find
Package find implements search funcs for finding files by name or content
Package find implements search funcs for finding files by name or content

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL