models

package
v2.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReportAgenticJSONFileName string = "go-mutesting-agentic.json"

ReportAgenticJSONFileName File name for the LLM-optimised escaped-mutant report

View Source
var ReportFileName string = "report.json"

ReportFileName File name for json report

View Source
var ReportGitLabJSONFileName string = "go-mutesting-gitlab.json"

ReportGitLabJSONFileName File name for the GitLab Code Quality report

View Source
var ReportHTMLFileName string = "go-mutesting-report.html"

ReportHTMLFileName File name for html report

View Source
var ReportSummaryJSONFileName string = "go-mutesting-summary.json"

ReportSummaryJSONFileName File name for the compact stats-only JSON summary

Functions

This section is empty.

Types

type Mutant

type Mutant struct {
	Mutator       Mutator `json:"mutator"`
	Diff          string  `json:"diff"`
	ProcessOutput string  `json:"processOutput,omitempty"`
}

Mutant is the result of one mutation attempt.

type Mutator

type Mutator struct {
	MutatorName        string `json:"mutatorName"`
	OriginalSourceCode string `json:"originalSourceCode"`
	MutatedSourceCode  string `json:"mutatedSourceCode"`
	OriginalFilePath   string `json:"originalFilePath"`
	OriginalStartLine  int64  `json:"originalStartLine"`
}

Mutator describes what was mutated.

type MutatorStats

type MutatorStats struct {
	Name    string `json:"name"`
	Killed  int64  `json:"killed"`
	Escaped int64  `json:"escaped"`
	Skipped int64  `json:"skipped"`
	Total   int64  `json:"total"`
}

MutatorStats holds per-mutator kill/escape counts for tested mutants only. Not-covered mutants are excluded from all counts here.

type Options

type Options struct {
	General struct {
		Debug                bool   `long:"debug" description:"Debug log output"`
		DoNotRemoveTmpFolder bool   `long:"do-not-remove-tmp-folder" description:"Do not remove the tmp folder where all mutations are saved to"`
		Help                 bool   `long:"help" description:"Show this help message"`
		Noop                 bool   `long:"noop" description:"Run the test suite once without any mutations first; exit with an error if it fails"`
		DryRun               bool   `` /* 241-byte string literal not displayed */
		NoDiffs              bool   `` /* 152-byte string literal not displayed */
		OutputStatuses       string `` /* 225-byte string literal not displayed */
		Quiet                bool   `` /* 166-byte string literal not displayed */
		Verbose              bool   `long:"verbose" description:"Verbose log output"`
		Workers              int    `` /* 138-byte string literal not displayed */
		Config               string `long:"config" description:"Path to config file"`
		HTMLOutput           bool   `long:"html-output" description:"Generates a go-mutesting-report.html file after testing is complete"`
	} `group:"General options"`

	Files struct {
		Blacklist []string `long:"blacklist" description:"List of files containing MD5 checksums (one per line) of mutations to ignore."`
		ListFiles bool     `long:"list-files" description:"List found files"`
		PrintAST  bool     `long:"print-ast" description:"Print the ASTs of all given files and exit"`
	} `group:"File options"`

	Mutator struct {
		DisableMutators []string `` /* 157-byte string literal not displayed */
		ListMutators    bool     `long:"list-mutators" description:"List all available mutators (including disabled)"`
	} `group:"Mutator options"`

	Filter struct {
		Match string `long:"match" description:"Only functions are mutated that confirm to the arguments regex"`
	} `group:"Filter options"`

	Exec struct {
		Exec               string  `long:"exec" description:"Execute this command for every mutation (by default the built-in exec command is used)"`
		NoExec             bool    `long:"no-exec" description:"Skip the built-in exec command and just generate the mutations"`
		Timeout            uint    `long:"exec-timeout" description:"Sets a timeout for the command execution (in seconds)" default:"10"`
		RunMutantID        string  `` /* 219-byte string literal not displayed */
		Coverage           bool    `` /* 126-byte string literal not displayed */
		PerTest            bool    `` /* 171-byte string literal not displayed */
		TestFlags          string  `` /* 167-byte string literal not displayed */
		TimeoutCoefficient float64 `` /* 192-byte string literal not displayed */
	} `group:"Exec options"`

	// GitDiff limits mutation to lines changed since a git base ref.
	// Pair with --ignore-msi-with-no-mutations for clean CI on unchanged packages.
	GitDiff struct {
		Lines bool   `long:"git-diff-lines" description:"Only mutate lines changed since the git diff base"`
		Base  string `` /* 145-byte string literal not displayed */
	} `group:"Git diff options"`

	Logger struct {
		GitHub      bool `long:"logger-github" description:"Emit escaped mutants as GitHub Actions ::warning annotations"`
		GitLab      bool `` /* 136-byte string literal not displayed */
		SummaryJSON bool `long:"logger-summary-json" description:"Write a compact stats-only JSON to go-mutesting-summary.json"`
		AgenticJSON bool `` /* 135-byte string literal not displayed */
	} `group:"Logger options"`

	// Baseline tracks known-surviving mutants so CI only fails on new regressions.
	// When the baseline file does not exist, the check is skipped (opt-in).
	Baseline struct {
		File   string `long:"baseline" description:"Path to baseline file of known-surviving mutants" default:"go-mutesting-baseline.json"`
		Update bool   `long:"update-baseline" description:"Write current escaped mutants to the baseline file then exit 0"`
	} `group:"Baseline options"`

	Test struct {
		Recursive bool `long:"test-recursive" description:"Defines if the executer should test recursively"`
	} `group:"Test options"`

	// Quality gates: fail with exit code 4 when metrics fall below thresholds.
	// -1 is the "not set" sentinel so that --min-msi 0 is distinguishable from
	// "flag not provided", and CLI always takes precedence over config file.
	Score struct {
		MinMsi                   float64 `long:"min-msi" description:"Minimum required MSI (0-100). Exit code 4 when not met." default:"-1"`
		MinCoveredMsi            float64 `long:"min-covered-msi" description:"Minimum required covered-MSI (0-100). Exit code 4 when not met." default:"-1"`
		IgnoreMsiWithNoMutations bool    `` /* 155-byte string literal not displayed */
		FailOnEscaped            bool    `long:"fail-on-escaped" description:"Exit code 4 if any mutant escapes, without requiring --min-msi"`
	} `group:"Score options"`

	Remaining struct {
		Targets []string `description:"Packages, directories and files even with patterns (by default the current directory)"`
	} `positional-args:"true" required:"true"`

	Config struct {
		SkipFileWithoutTest  bool     `yaml:"skip_without_test"`
		SkipFileWithBuildTag bool     `yaml:"skip_with_build_tags"`
		JSONOutput           bool     `yaml:"json_output"`
		HTMLOutput           bool     `yaml:"html_output"`
		SilentMode           bool     `yaml:"silent_mode"`
		ExcludeDirs          []string `yaml:"exclude_dirs"`
		MinMsi               float64  `yaml:"min_msi"`
		MinCoveredMsi        float64  `yaml:"min_covered_msi"`
		DisableMutators      []string `yaml:"disable_mutators"`
		EnableMutators       []string `yaml:"enable_mutators"`
		IgnoreSourceLines    []string `yaml:"ignore_source_lines"`
	}
}

Options Main config structure

type Report

type Report struct {
	Stats        Stats          `json:"stats"`
	MutatorStats []MutatorStats `json:"mutatorStats,omitempty"`
	Escaped      []Mutant       `json:"escaped"`
	Killed       []Mutant       `json:"killed"`
	Skipped      []Mutant       `json:"skipped,omitempty"`
	Errored      []Mutant       `json:"errored"`
	NotCovered   []Mutant       `json:"notCovered,omitempty"`
	// HasCoverage is true when a coverage profile was loaded before mutation.
	// It distinguishes "coverage was run and all code is covered" (NotCoveredCount==0
	// but CoveredCodeMsi is meaningful) from "coverage was never run".
	HasCoverage bool `json:"-"`
}

Report holds the complete mutation testing result.

func (*Report) Calculate

func (report *Report) Calculate()

Calculate computes derived metrics and per-mutator breakdowns.

func (*Report) CoveredMsiScore

func (report *Report) CoveredMsiScore() float64

CoveredMsiScore returns killed / (total - notCovered). Returns 0 when coverage was never enabled (HasCoverage==false). When coverage IS enabled and NotCoveredCount==0, every mutant is covered and CoveredMsiScore equals MsiScore.

func (*Report) MsiScore

func (report *Report) MsiScore() float64

MsiScore returns killed / total (skipped and errors count as killed).

func (*Report) TotalCount

func (report *Report) TotalCount() int64

TotalCount returns all mutants: killed, escaped, errored, skipped, and not-covered.

type Stats

type Stats struct {
	TotalMutantsCount int64   `json:"totalMutantsCount"`
	KilledCount       int64   `json:"killedCount"`
	NotCoveredCount   int64   `json:"notCoveredCount"`
	EscapedCount      int64   `json:"escapedCount"`
	ErrorCount        int64   `json:"errorCount"`
	SkippedCount      int64   `json:"skippedCount"`
	Msi               float64 `json:"msi"`
	CoveredCodeMsi    float64 `json:"coveredCodeMsi"`
	DuplicatedCount   int64   `json:"-"`
}

Stats holds aggregate mutation metrics.

Jump to

Keyboard shortcuts

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