cilium/cilium · error

%s: %.2f%%

Error message

%s: %.2f%%

What it means

colorAbsoluteValue in tools/complexity-diff formats a complexity metric for a program and returns an error when the percentage p exceeds ErrorThresholdLinearMetrics. The message '%s: %.2f%%' embeds the program name and the offending percentage. It signals that a linear complexity delta crossed the hard error threshold, failing the CI complexity-diff check.

Source

Thrown at tools/complexity-diff/main.go:271

}

func colorRelativeChange(program string, i int, p float64) (string, error) {
	s := fmt.Sprintf("%+d (%.2f\\\\%%) for %s", i, p, program)
	if p == 0 {
		return texNoColor(s), nil
	}

	if p < 0 {
		return texGreen(s), nil
	}

	return texRed(s), nil
}

func colorAbsoluteValue(program string, i int, p float64) (string, error) {
	s := fmt.Sprintf("%d (%.2f\\\\%%) for %s", i, p, program)
	if p > ErrorThresholdLinearMetrics {
		return texRed(s), fmt.Errorf("%s: %.2f%%", program, p)
	}
	if p > WarningThresholdLinearMetrics {
		return texOrange(s), nil
	}

	return texNoColor(s), nil
}

func colorAbsoluteValueExponential(program string, i int, p float64) (string, error) {
	s := fmt.Sprintf("%d (%.2f\\\\%%) for %s", i, p, program)
	if p > ErrorThresholdExponentialMetrics {
		return texRed(s), fmt.Errorf("%s: %.2f%%", program, p)
	}
	if p > WarningThresholdExponentialMetrics {
		return texOrange(s), nil
	}

	return texNoColor(s), nil

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Reduce the complexity of the flagged function in the changed code (split it into smaller functions, remove branches).
  2. Re-baseline the complexity snapshot if the increase is intentional and accepted by the team.
  3. Adjust ErrorThresholdLinearMetrics in tools/complexity-diff/main.go if the current cutoff is too strict for the project.

Example fix

// before
if p > ErrorThresholdLinearMetrics {
	return texRed(s), fmt.Errorf("%s: %.2f%%", program, p)
}
// after
// refactor the hot function, e.g.:
// func process(input) { ... 20 branches ... }
// becomes processValidate(input), processTransform(input), processCommit(input)
// so the reported percentage drops below the threshold
Defensive patterns

Strategy: validation

Validate before calling

if p > ErrorThresholdLinearMetrics {
	fmt.Printf("complexity gate will fail: %s at %.2f%%\n", program, p)
	os.Exit(1)
}

Try / catch

s, err := colorAbsoluteValue(prog, i, p)
if err != nil {
	var thErr *ThresholdError
	if errors.As(err, &thErr) {
		fmt.Fprintf(os.Stderr, "complexity threshold exceeded: %v\n", err)
	}
	return err
}

Prevention

When it happens

Trigger: fmt.Errorf("%s: %.2f%%", program, p) fires only when p > ErrorThresholdLinearMetrics inside colorAbsoluteValue, i.e. the computed absolute percentage change for a function in the compared program exceeds the error threshold for linear metrics.

Common situations: A code change adds significant cyclomatic complexity to a function in one of the analyzed programs; CI runs complexity-diff against a baseline and the absolute increase crosses the configured error cutoff.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/2ee0438dfe962305. Report an issue: GitHub.