### Why are the changes in this PR needed?
The DAP debugger currently truncates variable values to a hardcoded
limit of 100 characters, with no way for callers to configure it.
Long values cannot be inspected or copied whole from a debugger UI.
### What are the changes in this PR?
- Add a new `SetMaxVariableLength` Debugger option (in both
`v1/debug` and the top-level `debug` package)
- A value of 0 disables truncation; the default stays 100 characters
for backward compatibility
- Plumb the limit through `variableManager` and `namedVar`, so it
applies to top-level and nested (object/array/set) variables alike
- Relax `truncatedString` to return the original string unchanged
when the limit is <= 0
- Add `TestTruncatedString` and `TestVariableValueLengthLimit`
covering the default limit, unlimited (0), negative, custom limits,
and boundary cases
### Notes
- `go build ./...` and `go test ./v1/debug/...` both pass
- Default behavior is unchanged; the new option is opt-in
- This PR was developed with AI assistance (Claude Code)
### Further comments
Refs #8890
---------
Signed-off-by: summy wu <summy.wu81@gmail.com>
Coverage Range records the source span of each expression instead of
just row.
Additive API Changes:
- cover.Position.Col field
- cover.Range.Compare function
- ast.Location End() function
- ast.Location HasFile() function
covered_lines / not_covered_lines count unique rows across ranges, same
numbers as before.
I have also broken down the cover package a bit to aid future work.
Fixes https://github.com/open-policy-agent/opa/issues/8748
---------
Signed-off-by: Charlie Egan <charlie_egan@apple.com>
- Bump golangci-lint -> 2.6.2
- Fix all `deprecatedComment` "notices should be in a dedicated paragraph, separated from the rest" reports
- Enable `appendCombine` and fix all "appendCombine: can combine chain of X appends into one" notices
- Enable `preferFprint` and fix the few reported issues
- Fix various issues reported only once or twice, like `zeroByteRepeat`
Signed-off-by: Anders Eknert <anders.eknert@apple.com>
Following up on #7566, and now applying the more exciting
modernizations. fmt.Appendf was new to me! But especially
the contains checks are so much better IMHO. I have reviewed
all changes myself and did a few manual changes where it
became obvious that things could be improved a little further.
(the modernize analyzer still has some issues running against
OPA, and I have manually worked around those for the time being)
Signed-off-by: Anders Eknert <anders@styra.com>
Brace yourselves! For there are many touched files here. No changes
in semantics however.
Spent a long time trying out the various optional rules gocritic
provides, and settled for a few of them. There are more I really
like, but that would take many hours to address across the codebase.
Perhaps others find gocritic too pedantic? If so, we can merge the
fixes without enabling the rule.
Signed-off-by: Anders Eknert <anders@styra.com>
And update code to conform to the rule.
- Replace unnecessary fmt.Sprintf with string concatenation
- Replace fmt.Sprint with more efficient strconv.Itoa
- Replace static fmt.Errorf calls with more efficient errors.New
Thanks @srenatus for pushing me down this rabbit hole!
Signed-off-by: Anders Eknert <anders@styra.com>