instance_id stringlengths 10 65 | repo stringlengths 5 59 | pr_number int64 1 313k | task_type stringclasses 1
value | base_commit stringlengths 40 40 | review_commit stringlengths 40 40 | title stringlengths 2 282 | body stringlengths 7 3k | patch stringlengths 202 204k | n_defects int64 1 72 | n_supported int64 1 65 | n_major int64 0 32 | defects stringlengths 140 18.8k | certifier_count int64 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
uber-go__fx__554 | uber-go/fx | 554 | defect | 23e5ae1ccc50f3ccb254a8ccb4c1e6e0762f9e90 | c08f8ecd0a9249e494ba6069711986484434e89d | Run provides after other options | This removes positional dependence of options like fx.Logger()
Fixes #552 | diff --git a/app.go b/app.go
index 4c0ab941ff..32f9ce6611 100644
--- a/app.go
+++ b/app.go
@@ -82,9 +82,7 @@ func (f optionFunc) apply(app *App) { f(app) }
// See the documentation for go.uber.org/dig for further details.
func Provide(constructors ...interface{}) Option {
return optionFunc(func(app *App) {
- for _... | 2 | 2 | 2 | [{"id": "G0", "claim": "The pull request's changed behaviour should come with tests (none exist at S1).", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "A regression test that validates all logging is uniform in the spy should be added.", "category": "tes... | null |
uber-go__fx__563 | uber-go/fx | 563 | defect | 0ebfe45f2de1ecdf1701689f39e1af0535e8adf1 | eff76e9574af6372c423f475cd4d543453316b59 | Detect Provide/Invoke on fx.Option | It's easy to accidentally do,
Module = fx.Provide(..)
app := fx.New(
fx.Provide(foo, bar, Module),
)
Currently this results in a cryptic error message:
can't provide fx.optionFunc: unable to collect return types of a constructor: must provide at least one non-error type
With this change, th... | diff --git a/app.go b/app.go
index 3d0c6b31c..2e5be493b 100644
--- a/app.go
+++ b/app.go
@@ -22,8 +22,10 @@ package fx
import (
"context"
+ "fmt"
"os"
"os/signal"
+ "strings"
"syscall"
"time"
@@ -81,9 +83,21 @@ func (f optionFunc) apply(app *App) { f(app) }
//
// See the documentation for go.uber.org/d... | 6 | 3 | 0 | [{"id": "G0", "claim": "The PR replaced the error-combining multierr.Append with a plain assignment; the reviewer asks whether errors from container.Provide can still be combined, since the intent was to combine them.", "category": "correctness", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G... | null |
uber-go__fx__569 | uber-go/fx | 569 | defect | 736e233de2b82865625c121f60039b82a8ac38f7 | b87f47a0896b5f57de92374036f2083135e54216 | Add fx.In and fx.Out | Modules should use this directly instead of relying on dig.In and dig.Out.
Resolves #558. | diff --git a/glide.lock b/glide.lock
index 19f8a632e..8718f66e3 100644
--- a/glide.lock
+++ b/glide.lock
@@ -1,19 +1,19 @@
-hash: 5653160caff03632c8436e548345bf0932f9f14172c0783ae2328fdeda1a1a03
-updated: 2017-06-21T14:31:57.234774-07:00
+hash: 04e2701a657e80069bfe993db8be1dbe820e08e1333485eb29aa0e05bc262926
+updated: ... | 12 | 10 | 1 | [{"id": "G0", "claim": "The In type should be a one-liner, `type In struct { dig.In }` (same for Out).", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The PR should add a test covering mixed use, e.g. types provided via dig.Out consumed through fx.In (and... | null |
uber-go__fx__571 | uber-go/fx | 571 | defect | 5a8109f8d0184ad8652203354292090d3ac7c385 | 579d3f57510bfc323aa410aa5bf04ec4433a41d3 | Inject: Support dig.In tags | This changes fx.Inject to respect dig.In struct tags on target structs.
That is, the following code is now valid.
var x struct{ Foo io.Reader `optional:"true"` }
fx.New(fx.Inject(&x))
Resolves #564. | diff --git a/inject.go b/inject.go
index 5163b958c..816b3d4c9 100644
--- a/inject.go
+++ b/inject.go
@@ -25,6 +25,8 @@ import (
"reflect"
)
+var _typeOfIn = reflect.TypeOf(In{})
+
// Inject fills the given struct with values from the dependency injection
// container on application start.
//
@@ -42,13 +44,23 @@... | 5 | 5 | 1 | [{"id": "G0", "claim": "The doc comments in Inject should say `fx.In` instead of `dig.In`, since the code generates an `fx.In` struct.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Inject fills unexported embedded fields (PkgPath is unreliable fo... | null |
uber-go__fx__573 | uber-go/fx | 573 | defect | 5a8109f8d0184ad8652203354292090d3ac7c385 | c70d29db1ff2e2ef7fdaea64b36af6b48ffed362 | Rename fx.Inject to fx.Extract | Resolves #572
I'd like to limit the use of the term "inject" and "injection" to pure-DI only, of which enabling is Fx's primary goal.
Bringing the "inject" terminology to this usecase is harmful because we want users to build an association with "inject" being the golden path, whereas `fx.Inject` is actually a ... | diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2f4dfbc3..24a8251ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
## v1.0.0-rc3 (unreleased)
-- No changes yet.
+- **[Breaking]** Rename `fx.Inject` to `fx.Extract` to avoid using the
+ term "inject" outside of the ideal usecase. `fx.Extract` is a ham... | 3 | 1 | 0 | [{"id": "G0", "claim": "The CHANGELOG entry this PR adds should not include justifications for the change, because they get wordy; it should just summarize the changes.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The reviewer asks whether the '... | null |
uber-go__fx__591 | uber-go/fx | 591 | defect | a125e08afbf81f9a6b72ad1e9fbec3c875d51095 | f672de8a1cc81d831275d5ee27d47dee686701de | Shorten vendored paths | The vendor experience for printing out the constructor paths it not
great, since it includes the parent package as well, making it rather
long. The important bit is what happens after the vendor, not the
duplication of the current repo.
Fixes #539 | diff --git a/internal/fxlog/fxlog_test.go b/internal/fxlog/fxlog_test.go
index 668426ce2..a82e9f94c 100644
--- a/internal/fxlog/fxlog_test.go
+++ b/internal/fxlog/fxlog_test.go
@@ -123,6 +123,15 @@ func TestPrint(t *testing.T) {
assert.Equal(t, "", sink.String())
})
+ t.Run("printStripsVendorPath", func(t *testi... | 3 | 3 | 2 | [{"id": "G0", "claim": "It would be better to keep the vendor path information in the logger output, because the shortening cannot tell a package vendored in the project from the same package taken from GOPATH or from another project's vendor directory (e.g. dig installed by glide vs fetched by go get), so a local pack... | null |
uber-go__fx__637 | uber-go/fx | 637 | defect | 6313a1034891f71e46c4b32065b81b0aa85404c7 | 63a4573078a5c6922676ae3fabbe0c543f3722f4 | fxtest: Fail test if app creation fails | Currently, the fxtest.New function succeeds even if the underlying
fx.New fails. The error is never checked directly, and instead we rely
on `app.Start()` to catch the error. Instead, fail the test in
fxtest.New if fx.New fails.
There's some test changes required by this change:
- The `StartFailure` test was ac... | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9199c4ba7..2d870b7be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,8 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
-
--... | 2 | 2 | 1 | [{"id": "G0", "claim": "Re-introduce the option that sends fx log output to the *testing.T, which the PR lost where it converted fxtest.New call sites to plain fx.New — via a small fx.Printer implementation in a test file or by moving fxtest's printer to a shared internal package.", "category": "correctness", "verdict"... | null |
uber-go__fx__642 | uber-go/fx | 642 | defect | e09774f322f23a03e815fe1cb90ba0019780fd57 | 41386b08bb5ace21709ab344f2c578b4cdd5fe26 | Fix goroutine leaks in fxtest.Lifecycle | `fxtest.Lifecycle` leaks goroutines in `RequireStart` and `RequireStop`. This PR fixes the leaks (without altering any behavior), and it adds a check for leaked goroutines to the unit test suite.
Fixes #626. | diff --git a/fxtest/fxtest.go b/fxtest/fxtest.go
index 8f7a1d110..73f385a06 100644
--- a/fxtest/fxtest.go
+++ b/fxtest/fxtest.go
@@ -35,7 +35,6 @@ type TB interface {
FailNow()
}
-
// App is a wrapper around fx.App that provides some testing helpers. By
// default, it uses the provided TB as the application's lo... | 4 | 3 | 1 | [{"id": "G0", "claim": "Sharing the context between RequireStart and RequireStop behaves differently than the production implementation (constructors shouldn't be able to rely on the context passed to Start being cancelled during Stop), so RequireStart and RequireStop should each create their own cancelable context ins... | null |
uber-go__fx__660 | uber-go/fx | 660 | defect | ed13fcd9db623d1c13015fd50e4e79397cc1aab5 | 7e1e34ea24a8e7f7c18a62287495430c2a0520f6 | Add Shutdowner to allow shutdown from a module | This adds a Shutdowner interface with a Shutdown method, providing it to all
Fx applications. This provides the ability to signal app shutdown from any Fx
module.
Note that a channel of signal receivers is used because [os/signal.Notify][1],
and incidentally [fx.App.Done()][2] may be called multiple times, so we ... | diff --git a/app.go b/app.go
index b380da6d24..e429f01a26 100644
--- a/app.go
+++ b/app.go
@@ -29,6 +29,7 @@ import (
"os/signal"
"reflect"
"strings"
+ "sync"
"syscall"
"time"
@@ -270,6 +271,8 @@ func (l nopLogger) Printf(string, ...interface{}) {
// execute one at a time, in reverse order, and must all co... | 22 | 19 | 0 | [{"id": "G0", "claim": "Done() should avoid the cost of the deferred Unlock and manually unlock after the append.", "category": "performance", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The Shutdowner doc comment should drop the word 'both' and capitalize 'Stop'.", "categor... | null |
uber-go__fx__789 | uber-go/fx | 789 | defect | c2cac4551d69572d13d193cf12cf1747ea66c48c | 76b41c933f52dc38e75c3d23f75f8cdecc5886b0 | fxevent: Log Started/Stopped on timeout | As reported in #782, `App.Run` had a bug so that
if an application using it failed to start up because of a timeout
no event would be logged to indicate this.
The system would silently exit with a non-zero status code.
This PR resolves this by ensuring that even for timeouts,
we log `Started` or `Stopped` events... | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79737130cb..9ea26fb573 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
-- ... | 1 | 1 | 0 | [{"id": "G0", "claim": "The new CHANGELOG '### Fixed' bullet has an extra space after '- ' and should be rewritten without it (suggestion: '- Fix `fxevent.Stopped` not being logged when `App.Stop` is called.').", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}] | null |
uber-go__fx__795 | uber-go/fx | 795 | defect | ab985ca7bd9e74cf7f1f6d824375aa7f1bffdb08 | e87a18b89b929c32fb4f4a09034baa2ac16dd0c1 | Implement fx.As Annotation | This implements `fx.As` Annotation, which lets you annotate a constructor's result types to be provided to the container as a different interface type.
For example,
```go
fx.Provide(
fx.Annotate(bytes.NewBuffer(...), fx.As(io.Writer))
)
```
Specifies that the return type of `bytes.NewBuffer` (`bytes.Buffer`... | diff --git a/annotated.go b/annotated.go
index 3c05bfcdc..c62b3b264 100644
--- a/annotated.go
+++ b/annotated.go
@@ -96,15 +96,19 @@ func (a Annotated) String() string {
// annotations is used for building out the info needed to generate struct
// with tags using reflection.
type annotations struct {
- fType reflect... | 20 | 16 | 2 | [{"id": "G0", "claim": "The three annotation boolean flags are tricky to keep track of across their permutations, and shirchen asks whether an enum could be used to support fewer cases.", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "genAnnotatedOutStruct... | null |
uber-go__fx__802 | uber-go/fx | 802 | defect | 26a4f4d4d9b8a35d146406f6e4a4bf6d318c6aec | 3052cf18fc928db93bdbc042e417f28dd73ec321 | fx.Annotate: Refactor and support fx.Supply | This changes how we implement fx.Annotate.
Rather than generating a constructor when fx.Annotate is called,
we now build an internal `fx.annotate` type--a more featureful
version of `fx.Annotated`.
We then intercept this `fx.annotated` type,
similar to how we intercept `fx.Annotated`,
and convert it into a constructor... | diff --git a/annotated.go b/annotated.go
index efa3772c10..d47277d965 100644
--- a/annotated.go
+++ b/annotated.go
@@ -93,43 +93,17 @@ func (a Annotated) String() string {
return fmt.Sprintf("fx.Annotated{%v}", strings.Join(fields, ", "))
}
-// annotations is used for building out the info needed to generate struc... | 4 | 3 | 1 | [{"id": "G0", "claim": "The `annotated` and `Annotated` cases in Supply's type switch have identical bodies and should be merged into one case (`case annotated, Annotated:`).", "category": "maintainability", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The doc comment above `pa... | null |
uber-go__fx__947 | uber-go/fx | 947 | defect | dafa38fdf1ddae1d7c959e2ae3953c47b3e99d6e | 43bba891dda19b9ec1eeb35d11c0251ac59f7890 | Allow fx.Module-specific custom loggers | Currently passing fx.WithLogger option to fx.Module does not work because fx currently does not support specifying module-level custom loggers.
Now fx.WithLogger can be passed to fx.Modules for specifying custom loggers for fx.Modules. Also added some test cases to test fx.Module-specific loggers.
Fixes #894 | diff --git a/app.go b/app.go
index 8d0132c62..dd29c3b37 100644
--- a/app.go
+++ b/app.go
@@ -193,9 +193,10 @@ type withLoggerOption struct {
func (l withLoggerOption) apply(m *module) {
if m.parent != nil {
- // loggers shouldn't differ based on Module.
- m.app.err = fmt.Errorf("fx.WithLogger Option should be pa... | 8 | 8 | 1 | [{"id": "G0", "claim": "Add a comment on constructAllCustomLoggers clarifying that it builds the custom loggers for all the modules in the tree.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Inline the logBuffer type assertion as `if buffer, ok :... | null |
uber-go__fx__953 | uber-go/fx | 953 | defect | dafa38fdf1ddae1d7c959e2ae3953c47b3e99d6e | 57efd539c5f9a1ec279f4eb53718912ae8965411 | Add support for context- and error-less annotated hook funcs | Similar to #952, this adds support for any `HookFunc`-compatible funcs as part of `fx.OnStart`/`fx.OnStop` annotations.
~Unrelated change: also changes bind addresses for tests to be localhost.~ Was done in #960 | diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 61ecf5b0de..e9b2cf37d3 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
- go: ["1.17.x", "1.18.x", "1.19.x"]
+ g... | 2 | 2 | 0 | [{"id": "G0", "claim": "The new error message should say the optional hook return may only be \"an\" error to avoid confusion between a single error and multiple errors.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "In TestHookAnnotationFunctionF... | null |
uber-go__fx__982 | uber-go/fx | 982 | defect | 0de8ec7a6ee689ecf6d57e9456c30d53590d6b0f | abd5de5e9e64deeb610b9f7e7fc16d213ac6d1b1 | Allow setting Zap logger level | This extends the `fxevent.ZapLogger` struct to add two new methods: `UseLogLevel` and `UseErrorLevel`.
`UseLogLevel` sets the level of all non-error messages emitted by Fx.
`UseErrorLevel` sets the level of all error messages emitted by Fx.
When these are not set, the log levels are kept identical to what the... | diff --git a/fxevent/zap.go b/fxevent/zap.go
index 9fb7e477b..fdac00cb7 100644
--- a/fxevent/zap.go
+++ b/fxevent/zap.go
@@ -24,51 +24,102 @@ import (
"strings"
"go.uber.org/zap"
+ "go.uber.org/zap/zapcore"
)
// ZapLogger is an Fx event logger that logs events to Zap.
type ZapLogger struct {
Logger *zap.Lo... | 5 | 5 | 1 | [{"id": "G0", "claim": "Clamping a user-set ErrorLevel up to zapcore.ErrorLevel is weird behavior; the PR should use a private pointer field plus a UseErrorLevel setter (and optionally a UseLogLevel setter) so the code can tell whether the field was set instead of guessing from the level value.", "category": "design", ... | null |
uber-go__fx__984 | uber-go/fx | 984 | defect | 09bba9b2f5beb2110db0172c19e118a7edbf25eb | 58c2d591330c16eb9e59be9026b7232b0ca3b645 | Refactor Done() to use a broadcasted Signal type for future features. | This creates a new public struct type `ShutdownSignal` and moves broadcast of operating system signals to a standalone type in it's own source file. This allows for the cleaner expansion of signaling features.
| diff --git a/app.go b/app.go
index 0f51531ea..291b79112 100644
--- a/app.go
+++ b/app.go
@@ -26,11 +26,9 @@ import (
"errors"
"fmt"
"os"
- "os/signal"
"reflect"
"sort"
"strings"
- "sync"
"time"
"go.uber.org/dig"
@@ -286,10 +284,9 @@ type App struct {
// Decides how we react to errors when building t... | 15 | 13 | 0 | [{"id": "G0", "claim": "The Signal type should not be exported, and should instead be named ShutdownSignal (per the maintainer's follow-up).", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The naked return in broadcast should be replaced with an explicit ... | null |
uber-go__fx__989 | uber-go/fx | 989 | defect | 01d1893f02baf958446c36e306805aa78720486e | 1e6cf8a8858d92826b5beb3c3359409195d9f698 | Provides ExitCode Shutdowner Option; and Wait method to receive it. | This PR provides an option for those who take dependencies on the `Shutdowner` interface to call the `Shutdown` method with an `ExitCode` option, in addition it add a `Wait` method to the application to allow for main programs to wait for the application to be shutdown and to exit with a given exit code.
Please not... | diff --git a/annotated_test.go b/annotated_test.go
index f7ebc8ea7..538953255 100644
--- a/annotated_test.go
+++ b/annotated_test.go
@@ -1038,7 +1038,8 @@ func assertApp(
invoked *bool,
) {
t.Helper()
- ctx := context.Background()
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
assert.... | 17 | 16 | 1 | [{"id": "G0", "claim": "Move the \"Note: The channel Done returns...\" paragraph to the bottom of the Done doc comment in app.go.", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "Remove the extra blank line added right after the opening brace of shu... | null |
uber-go__fx__990 | uber-go/fx | 990 | defect | dfa20606070cc53dc05a0d0fbded1ca02e0d2c33 | de5acec5cd898e0be6043e74e4786a3ac2cc8fc3 | Add fx.From annotation | open a new PR for https://github.com/uber-go/fx/pull/938,
because long time no progress update. 😭 | diff --git a/annotated.go b/annotated.go
index fda45725e..5ce4d244c 100644
--- a/annotated.go
+++ b/annotated.go
@@ -1176,12 +1176,181 @@ func extractResultFields(types []reflect.Type) ([]reflect.StructField, func(int,
}
}
+type fromAnnotation struct {
+ targets []interface{}
+ types []reflect.Type
+}
+
+var _ A... | 10 | 9 | 1 | [{"id": "G0", "claim": "The opening sentence of the From doc comment should be reworded to \"From is an Annotation that annotates the parameter(s) for a function (i.e. a constructor) to be accepted from other provided types. It is very much the opposite of fx.As(...)\".", "category": "documentation", "verdict": "suppor... | null |
uber-go__fx__994 | uber-go/fx | 994 | defect | c9b24f847c314a5fcfcec8a91d9e550d30ed0391 | a7ebbcc92ebeef1502aa1b702c9c28a855f0d0f3 | Stricter Control over Starting/Stopping Lifecycle | Currently, there is nothing preventing somebody from making calls to `app.Start` and `app.Stop` when it doesn't make sense, for example calling `app.Start` or `app.Stop` twice, or trying to run the application twice concurrently. Because of this lack of control, it's possible for users to cause race conditions and pani... | diff --git a/app_test.go b/app_test.go
index d99a58afd..9c47ad218 100644
--- a/app_test.go
+++ b/app_test.go
@@ -1281,6 +1281,26 @@ func TestAppStart(t *testing.T) {
err := app.Start(context.Background()).Error()
assert.Contains(t, err, "OnStart hook added by go.uber.org/fx_test.TestAppStart.func10.1 failed: goro... | 2 | 2 | 0 | [{"id": "G0", "claim": "Consider renaming the `notRunning` app state constant to `stopped`.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The stop error message could be more informative by printing the current state of `l.state` instead of jus... | null |
uber-go__goleak__110 | uber-go/goleak | 110 | defect | f995fdb5a4f35b501e1037fcb553f5fab2711340 | 2f2c1d521dba507437c429c7e475e2345642592d | internal/stack: Use control flow for state | In anticipation of parsing more information from stack traces make the
stack trace parsing logic more manageable by moving it from a state
machine into a layout closer to a recursive descent parser.
That is, instead of a central loop that reads input line-by-line
and needs to manage its various states:
current, r... | diff --git a/go.mod b/go.mod
index 926ce59..af70901 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module go.uber.org/goleak
-go 1.18
+go 1.20
require github.com/stretchr/testify v1.8.0
diff --git a/internal/stack/scan.go b/internal/stack/scan.go
new file mode 100644
index 0000000..ab531ad
--- /dev/null
+++ b... | 5 | 4 | 0 | [{"id": "G0", "claim": "The test should also show that Text returns the same token after Unscan by asserting scanner.Text() equals \"bar\" immediately after the Unscan call.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "getStacks should leave a comment... | null |
uber-go__goleak__111 | uber-go/goleak | 111 | defect | f995fdb5a4f35b501e1037fcb553f5fab2711340 | a04e12375594f09a6c3b73d75391187f3657927c | stack: Parse all functions | Adds support to the stack parser for reading the full list of functions
for a stack trace.
NOTE:
This includes the function that created the stack trace;
it's the bottom of the stack.
We don't maintain the order of the functions
since that's not something we need at this time.
The functions are all placed in a set.
... | diff --git a/go.mod b/go.mod
index 926ce59..af70901 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module go.uber.org/goleak
-go 1.18
+go 1.20
require github.com/stretchr/testify v1.8.0
diff --git a/internal/stack/scan.go b/internal/stack/scan.go
new file mode 100644
index 0000000..ab531ad
--- /dev/null
+++ b... | 3 | 3 | 0 | [{"id": "G0", "claim": "The new comment saying the function name is 'usually' followed by a file:line should be made definite — the reviewer asks whether the non-matching cases can be enumerated or whether it is just defensive against unknown cases.", "category": "design", "verdict": "supported", "priority": "P2", "sco... | null |
uber-go__goleak__120 | uber-go/goleak | 120 | defect | 31095c657c34bba405a8d480db27989aa5f60b9c | a96f254bb27b1645ce45589aca65e648e281fa1a | gracefully handle elided frames | When parsing stacks we frequently encounter elided frames. The actual stack line looks something like `...23 frames elided...`, which is passed to `parseFuncName`, which of course is not parsable as a function name. As a result, whenever this happens we get a useless panic like the following:
```
panic: Failed to p... | diff --git a/internal/stack/stacks.go b/internal/stack/stacks.go
index 241a9b8..ff52805 100644
--- a/internal/stack/stacks.go
+++ b/internal/stack/stacks.go
@@ -25,6 +25,7 @@ import (
"errors"
"fmt"
"io"
+ "regexp"
"runtime"
"strconv"
"strings"
@@ -32,6 +33,9 @@ import (
const _defaultBufferSize = 64 * 1... | 2 | 2 | 1 | [{"id": "G0", "claim": "Rather than running a regex match on every line of a stack trace (which could get slow for larger stacks), use a cheap strings.HasPrefix/HasSuffix check for the specific prefix and suffix, and only fall back to the regex afterwards.", "category": "performance", "verdict": "supported", "priority"... | null |
uber-go__goleak__136 | uber-go/goleak | 136 | defect | 4ff5fa6529eed4e9aa192f44dae5e3dbc05902a8 | 9f0d509518d4d5d0b70dcdfbe6877db6c23d4a1e | Add IgnoreCreatedBy (#135) | Was looking for exactly that today.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Added the ability to track and display the function that created each goroutine in stack traces.
- Introduced a new filter option to ignore goroutines based ... | diff --git a/internal/stack/stacks.go b/internal/stack/stacks.go
index 1d31288..3d9d9a1 100644
--- a/internal/stack/stacks.go
+++ b/internal/stack/stacks.go
@@ -37,6 +37,9 @@ type Stack struct {
id int
state string // e.g. 'running', 'chan receive'
+ // The function that spawned the goroutine.
+ createdBy stri... | 1 | 1 | 0 | [{"id": "G1", "claim": "The golangci-lint failure in CI must be resolved before the pull request can merge.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "pre_existing"}] | null |
uber-go__goleak__25 | uber-go/goleak | 25 | defect | d13b03e061d1517cc2bf84902c76fc134dafc1d9 | a3bb4bdb51598c822108beebaa516cb99f24d0d8 | Ignore t.Parallel goroutines, they represent queued tests | When t.Parallel is used, tests are queued to run after all serially
executed tests are run. This causes issues if the serial test tries to
verify goroutines.
Fixes #16 | diff --git a/leaks_test.go b/leaks_test.go
index 15c370c..22b7697 100644
--- a/leaks_test.go
+++ b/leaks_test.go
@@ -82,3 +82,13 @@ func TestVerifyNoLeaks(t *testing.T) {
require.NotEmpty(t, ft.errors, "Expect errors from VerifyNoLeaks on leaked goroutine")
bg.unblock()
}
+
+func TestVerifyParallel(t *testing.T) {... | 1 | 1 | 0 | [{"id": "G0", "claim": "Edit the explanatory comment above the switch in isTestStack to include t.Parallel, so it documents the newly added testing.(*T).Parallel case.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__goleak__35 | uber-go/goleak | 35 | defect | 3b0196519f167e6dec046a95449f0b5d0ec986fa | 93afd49adedf00fdbe37372da202bb06fd976248 | Add latest versions to Travis, support 1.10+ only | * Fix golint + go vet to work with latest version
* Fix correctly detected bug where `fmt.Sprint` was not used correctly. | diff --git a/.travis.yml b/.travis.yml
index abd6f2a..d9c587a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,16 +4,15 @@ go_import_path: go.uber.org/goleak
go:
# TODO(prashant): Enable once we have fixed Linux issues with old versions.
- #- 1.6
- #- 1.7
- #- 1.8
- - 1.9.2
+ - 1.10.x
+ - 1.11.x
+ - 1.12.x... | 1 | 1 | 0 | [{"id": "G0", "claim": "The '# TODO(prashant): Enable once we have fixed Linux issues with old versions.' comment in .travis.yml is no longer needed now that the pull request drops the old Go versions, and should be removed.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}... | null |
uber-go__goleak__7 | uber-go/goleak | 7 | defect | a15fd2bd98dba83117bc4386f8d29e510dd42f77 | 9df9d3abd70dc99ded0b5831f8a4be7103c6039c | Add VerifyTestMain function for easy test integration | This allows callers to add a simple `TestMain` function which calls out
to `goleak.VerifyTestMain`. Update README to include new usage. | diff --git a/README.md b/README.md
index 0f5dbdf..85a9f52 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ at the end of every test package by creating a `TestMain` function in your packa
```go
func TestMain(m *testing.M) {
- goleak.VerifyPackage(m)
+ goleak.VerifyTestMain(m)
}
```
diff --git a/testmain... | 1 | 1 | 0 | [{"id": "G0", "claim": "Add a space after the ':' in the 'goleak: Errors on successful test run:' message printed to stderr.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}] | null |
uber-go__goleak__78 | uber-go/goleak | 78 | defect | 2dfebe88ddf19de216c4ab15a1189fc640b1ea9f | 89fc1e6deda9421f56ee0155579246b902cab30b | Add Cleanup option | This adds Cleanup option which can be passed to VerifyTestMain and
VerifyNone. This takes in a function that will be executed at the
end of the leak verification.
Internal Ref: GO-888
Fix #63 | diff --git a/leaks.go b/leaks.go
index ace2e2b..81d09b5 100644
--- a/leaks.go
+++ b/leaks.go
@@ -55,6 +55,9 @@ func Find(options ...Option) error {
cur := stack.Current().ID()
opts := buildOpts(options...)
+ if opts.teardown != nil {
+ return fmt.Errorf("Cleanup can only be passed to VerifyNone or VerifyTestMain... | 8 | 8 | 1 | [{"id": "G0", "claim": "Use errors.New instead of fmt.Errorf for the constant error string in Find, since no formatting is needed.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new test that Find rejects the Cleanup option should be run as ... | null |
uber-go__mock__114 | uber-go/mock | 114 | defect | 892b665398ecece7c7a900d2a2f2fa3dac07e4c4 | 01d7f5409d65d416b1195cd1c63c2bee52d30d2d | feat: add Regex() matcher | Closes #113
Let me know if it's something you'd be interested in having - happy to make some tweaks if required | diff --git a/gomock/matchers.go b/gomock/matchers.go
index 079eae93..b795fa46 100644
--- a/gomock/matchers.go
+++ b/gomock/matchers.go
@@ -17,6 +17,7 @@ package gomock
import (
"fmt"
"reflect"
+ "regexp"
"strings"
)
@@ -168,6 +169,33 @@ func (n notMatcher) String() string {
return "not(" + n.m.String() + ")... | 7 | 7 | 1 | [{"id": "G0", "claim": "If the feature is added, the regular expression should be compiled into a regexp.Regexp once (at construction) instead of being compiled during every check.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "If the feature is add... | null |
uber-go__mock__127 | uber-go/mock | 127 | defect | 7bf3d91b8933d4f07cd6d612000968c161233c8f | 7d44f56df9b047efbc3777b8811b970294c104f6 | Fixed -mockNames not propagating to Recorder and ReturnCall types | When you are trying to mock multiple interfaces with the same name and similar methods (for example user.Service Create, post.Service Create, etc..) there is collision in Recorder and ReturnCall types, the -mockNames parameter only changes the main interface name, with the changes proposed in this PR the correct mockNa... | diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go
index d7d00858..b325b46b 100644
--- a/mockgen/mockgen.go
+++ b/mockgen/mockgen.go
@@ -519,10 +519,10 @@ func (g *generator) GenerateMockMethods(mockType string, intf *model.Interface,
g.p("")
_ = g.GenerateMockMethod(mockType, m, pkgOverride, shortTp)
g.p(""... | 2 | 2 | 2 | [{"id": "G0", "claim": "Keep *model.Interface plumbed through GenerateMockRecorderMethod and GenerateMockReturnCall, using g.MockName(intf.Name) instead of intf.Name, to preserve the richer representation for future code generation changes.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "int... | null |
uber-go__mock__200 | uber-go/mock | 200 | defect | 70a5e8c8f892fdd0f2381df782079f7da9fd1962 | af4e543075d4485039993b5d39711a89086af0e1 | add interfaces flag with unit test | This is a proposal for `-interfaces` flag using source mode. Using this flag it is possible to list only required interfaces to be mocked in source mode. Currently, source mode mocks all interfaces which -source file contains.
Thanks @KastenMike for raising this!
Fixes https://github.com/golang/mock/issues/660 | diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go
index 5d57868e..9903a2a1 100644
--- a/mockgen/mockgen.go
+++ b/mockgen/mockgen.go
@@ -71,6 +71,7 @@ var (
debugParser = flag.Bool("debug_parser", false, "Print out parser results only.")
showVersion = flag.Bool("version", false, "Print version.")
+ interfaces ... | 6 | 5 | 3 | [{"id": "G0", "claim": "The interface-filtering block added in main() should probably live in sourceMode, like the existing exclude-interfaces parsing (p.excludeNamesSet = parseExcludeInterfaces(*excludeInterfaces)) does.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "... | null |
uber-go__mock__220 | uber-go/mock | 220 | defect | b8222fa1a7f155a0ee347c3d5ceb1a0a27dd1610 | e36794b0ef332ee4d5896efe3035b9e6f1daa044 | Package Mode: Use aliases when used in source | v0.5.0 included #207, which replaced reflect mode with package mode. One issue with package mode that came up (ref: #216) was that generated mocks for interfaces that referred to alias types were referring to the aliases' underlying names instead.
e.g.,
some package:
```go
package somgpkg
import "somepkg/inter... | diff --git a/mockgen/internal/tests/alias/interfaces.go b/mockgen/internal/tests/alias/interfaces.go
new file mode 100644
index 00000000..699dadcd
--- /dev/null
+++ b/mockgen/internal/tests/alias/interfaces.go
@@ -0,0 +1,47 @@
+package alias
+
+//go:generate mockgen -typed -package=mock -destination=mock/interfaces.go ... | 1 | 1 | 0 | [{"id": "G0", "claim": "Use the TODO(author or issue) convention to mark the TODO comment about removing the alias-replacement logic once mock is Go1.23+ only.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}] | null |
uber-go__mock__273 | uber-go/mock | 273 | defect | 6a0445c87f2d82e304033c553dadd34d2a1a8120 | 030b99f15023b52c90e354963a4f9dd3cb3e8e3f | Unify package and archive modes | - Use the same code for `package` and `archive` modes (the `package` parsing implementation)
- Delete `archive` parsing implementation added in #258
- ~~Bump `golang.org/x/tools` to v0.26.0 to support archives v2 and unblock go1.25 support~~ (already landed #276)
Closes #272 | diff --git a/go.mod b/go.mod
index e5f84bdf..85468185 100644
--- a/go.mod
+++ b/go.mod
@@ -4,14 +4,14 @@ go 1.23
require (
github.com/stretchr/testify v1.9.0
- golang.org/x/mod v0.18.0
- golang.org/x/tools v0.22.0
+ golang.org/x/mod v0.21.0
+ golang.org/x/tools v0.26.0
)
require (
github.com/davecgh/go-spew ... | 2 | 1 | 1 | [{"id": "G0", "claim": "golang.org/x/tools should be upgraded to v0.36.0 instead of v0.26.0.", "category": "maintainability", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The behavioral changes in archive mode (now erroring out on type constraints and handling type aliases expl... | null |
uber-go__mock__295 | uber-go/mock | 295 | defect | df174454f5ed8a62cd92fd725e5d289fdabf5595 | f82b608ad494085ed3bb58a3da6f6c9a45006f99 | [Mockgen] Archive mode make interfaces optional | This diff adds logic to archive mode:
- Keep interfaces optional as in the [original Archive mode PR.](https://github.com/golang/mock/pull/633)
- We already have logic to discover interfaces. This diff reuses the logic with some constraints & updates the initial arg checker to make interfaces optional.
- Rest of the... | diff --git a/bazel/MODULE.bazel b/bazel/MODULE.bazel
index fae7718..f5a7d56 100644
--- a/bazel/MODULE.bazel
+++ b/bazel/MODULE.bazel
@@ -1,7 +1,7 @@
module(name = "bazel_gomock")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
-bazel_dep(name = "rules_go", version = "0.57.0", repo_name = "io_bazel_rules_go")
+b... | 5 | 5 | 2 | [{"id": "G0", "claim": "Rather than adding a large archive-mode branch into the shared test-table loop for one case, the coverage should be moved into a separate sub-test or a smaller test package so the whole parsed structure can be asserted.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": ... | null |
uber-go__mock__60 | uber-go/mock | 60 | defect | 50aba741b25f5844c3864db094993d094b761824 | 1a30c4870db92eede0d9ad2d45c5e12754efb161 | feat: add Cond matcher | `Cond` is a matcher allowing to rely on custom logic for complex matching scenarios.
It happened quite a few times that I had to leverage on the `DoAndReturn` to perform complex matching use cases, passing `gomock.Any()` as a matcher.
This would have allowed me to reduce a lot of complexity.
| diff --git a/gomock/matchers.go b/gomock/matchers.go
index c1edac57..a9c9629b 100644
--- a/gomock/matchers.go
+++ b/gomock/matchers.go
@@ -97,6 +97,18 @@ func (anyMatcher) String() string {
return "is anything"
}
+type fnMatcher struct {
+ fn func(x any) bool
+}
+
+func (f fnMatcher) Matches(x any) bool {
+ return... | 5 | 3 | 0 | [{"id": "G0", "claim": "fnMatcher should be a redefinition of the func type rather than a struct, since it does not need to be a struct.", "category": "design", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "fnMatcher's String() should return wording consistent with the other mat... | null |
uber-go__mock__78 | uber-go/mock | 78 | defect | 837f20ad6bc3c8d1ad2128760cd812f2c95ef699 | bd33a982fdb971421c9f537e17e68d129c5af209 | Allow type-safe calls to be used in InOrder | This modifies `InOrder` to receive variadic `any` instead of `*Call`, allowing users to use this function with type-safe generated Calls.
This implementation uses a type assertion to check if the provided arguments are `*Call`s or reflection to get the `*Call` when the arguments wrap one (generated code). If neither... | diff --git a/gomock/call.go b/gomock/call.go
index b8a06acc..5e13dc5f 100644
--- a/gomock/call.go
+++ b/gomock/call.go
@@ -435,12 +435,40 @@ func (c *Call) call() []func([]any) []any {
}
// InOrder declares that the given calls should occur in order.
-func InOrder(calls ...*Call) {
+// Ignores every argument that i... | 3 | 1 | 1 | [{"id": "G0", "claim": "InOrder should panic (notify immediately) instead of silently ignoring an argument that isn't a *Call or wraps one, since a wrong call would otherwise be very hard to debug.", "category": "design", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Consider ... | null |
uber-go__nilaway__10 | uber-go/nilaway | 10 | defect | 143877213b897c063e7136b6833911fadb61c9ff | 6990af94b8d597f64b39dd5f260ca84758fb2947 | Replace config.IsTestEnvironment with a configuration | This PR replaces the global variable `config.IsTestEnvironment` with a user-configuration option `pretty-print` (default `true`). Then in our `TestMain` setup function we set this flag to be false for testing purposes.
Depends on #9 | diff --git a/config/config.go b/config/config.go
index 77395e10..6372f3b3 100644
--- a/config/config.go
+++ b/config/config.go
@@ -27,6 +27,8 @@ import (
// Config is the struct that stores the user-configurable options for NilAway.
type Config struct {
+ // PrettyPrint indicates whether the error messages should b... | 1 | 1 | 0 | [{"id": "G0", "claim": "Add a test that specifically verifies that setting the pretty-print flag has some effect, even though it is disabled for the majority of the test suite.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__nilaway__193 | uber-go/nilaway | 193 | defect | a82d5b455dcca6f9b1fe47c757db9aa02cb4c096 | d6d74bb995a74f1ddaf53f0c77cc396484930149 | Fix NilAway FPs on channel sends/receives | See issue #192 for a more detailed discussion on handling channels in NilAway. To make this PR more self-contained, below is a partial copy of the discussion there:
See the following behaviors regarding nil / closed channels (taken from [this SO post](https://stackoverflow.com/questions/43616434/closed-channel-vs-ni... | diff --git a/annotation/consume_trigger.go b/annotation/consume_trigger.go
index 3898616e..421b01e8 100644
--- a/annotation/consume_trigger.go
+++ b/annotation/consume_trigger.go
@@ -1615,45 +1615,6 @@ func (g GlobalVarAssignDeepPrestring) String() string {
return sb.String()
}
-// ChanAccess is when a channel is ... | 2 | 2 | 0 | [{"id": "G0", "claim": "Replace \"can not\" with \"cannot\" in the new backpropAcrossSend comment.", "category": "documentation", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "Replace \"can not\" with \"cannot\" in the new AddComputation channel-receive comment.", "category": ... | null |
uber-go__nilaway__234 | uber-go/nilaway | 234 | defect | 8c8bb2970c6249c17ee26c048c461f0333c1ba7f | 13a1f91982ac417049615c17de25bc8aa57f31d2 | Implement the plugin interface for golangci-lint | Since golangci-lint v1.57.0, it offers a new [Module Plugin System](https://golangci-lint.run/plugins/module-plugins/), which is a lot more robust and easier to use than the plain Go plugin system. This unlocks the possibility of running NilAway in golangci-lint as a private linter.
This PR implements the require in... | diff --git a/README.md b/README.md
index 807ae4b8..45640753 100644
--- a/README.md
+++ b/README.md
@@ -32,13 +32,6 @@ overhead.
NilAway is implemented using the standard [go/analysis][go-analysis], making it easy to integrate with existing analyzer
drivers (i.e., [golangci-lint][golangci-lint], [nogo][nogo], or [runn... | 1 | 1 | 0 | [{"id": "G0", "claim": "Rephrase the README sentence \"NilAway, in its current form, still reports a fair number of false positives. This makes NilAway fail to be merged with golangci-lint...\" to the suggested wording \"NilAway, in its current form, can report false positives. This unfortunately hinders its immediate ... | null |
uber-go__nilaway__24 | uber-go/nilaway | 24 | defect | 3ca8ea59d598c5c0777bdf4e7c13f1aa073aa55c | 81a7f400f6e017e2e8a58cc9a7c8372a20c6ab0a | [Follow-up of PR #8 ] Support function contract nonnil->nonnil for full infer mode | Follow up of PR #8 , support function contract(nonnil->nonnil) in full infer mode.
This revision supports contract(nonnil -> nonnil). There are two major steps:
1. Duplicate param and return sites at every call of the function with a contract so a param or return site will have its unique nilability. We duplicate... | diff --git a/annotation/consume_trigger.go b/annotation/consume_trigger.go
index d12098b7..984115f3 100644
--- a/annotation/consume_trigger.go
+++ b/annotation/consume_trigger.go
@@ -19,6 +19,7 @@ import (
"go/ast"
"go/token"
"go/types"
+ "strings"
"go.uber.org/nilaway/util"
)
@@ -355,7 +356,11 @@ func (g Gl... | 21 | 16 | 1 | [{"id": "G0", "claim": "The error-message regexp in the fooReturn test is not detailed enough to tell that the diagnostic comes from the barReturn2() invocation rather than the barReturn1() one (e.g. by matching `a2`), and the author agrees a follow-up issue is needed until variable names appear in messages.", "categor... | null |
uber-go__nilaway__240 | uber-go/nilaway | 240 | defect | fe712a8ce97ff52c2bc7125709c903f42d2f2c75 | 52223357fbd8b91e2e9180b125096721337ddb63 | Implement fact export for manually-written and inferred function contracts | This PR implements the fact export for manually-written and inferred function contracts. Specifically it enhances the `functioncontracts` sub-analyzer, which imports contracts from upstream packages, parses/infers the contracts for the local package, combine the contract map and return it. It now also exports the contr... | diff --git a/assertion/function/analyzer.go b/assertion/function/analyzer.go
index 08f71d41..602e7137 100644
--- a/assertion/function/analyzer.go
+++ b/assertion/function/analyzer.go
@@ -281,9 +281,9 @@ func duplicateFullTriggersFromContractedFunctionsToCallers(
for ctrtFunc, calls := range callsByCtrtFunc {
r := ... | 1 | 1 | 0 | [{"id": "G0", "claim": "Reword the first line of the new comment on the imported-contracts merge loop to “The existing contracts imported from upstream packages are about upstream functions,” as given in the attached suggestion block.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "in... | null |
uber-go__nilaway__252 | uber-go/nilaway | 252 | defect | 885be9df8ef40abe6472450af1fefa6a60e9121d | 0cbd8973927c1b49ce2b01fe57f44804f6a01992 | Add more test cases for calling no-return functions | This PR adds more test cases to test NilAway's ability to handle no-return functions (such as `os.Exit`, `runtime.Goexit`, `testing.T.SkipNow` etc.). | diff --git a/assertion/function/preprocess/cfg.go b/assertion/function/preprocess/cfg.go
index d8a99c38..b92776a6 100644
--- a/assertion/function/preprocess/cfg.go
+++ b/assertion/function/preprocess/cfg.go
@@ -66,6 +66,11 @@ func (p *Preprocessor) CFG(graph *cfg.CFG, funcDecl *ast.FuncDecl) *cfg.CFG {
p.restructur... | 2 | 1 | 0 | [{"id": "G0", "claim": "The preprocessor should set a no-return call block's successors to point at the return block rather than nil, or otherwise mirror what the upstream drivers do.", "category": "design", "verdict": "opposed", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Instead of hacking postpr... | null |
uber-go__nilaway__264 | uber-go/nilaway | 264 | defect | e90288479601315af13b7fdd3ccd6b50c53a8e7c | 6049cf453845e8db3f32dfd905caf322569fd947 | Support for "always safe" for error returning and ok-form functions | This PR adds support for "always safe" case for rich check effect functions, namely error returning functions and ok-form functions.
The support for always safe tracking is currently limited to:
1. directly determinable cases of "non-nil" return
```
(a) return &S{}, errors.New(...) // supported
(... | diff --git a/accumulation/analyzer.go b/accumulation/analyzer.go
index e112b04c..96237006 100644
--- a/accumulation/analyzer.go
+++ b/accumulation/analyzer.go
@@ -183,7 +183,16 @@ func checkErrors(triggers []annotation.FullTrigger, annMap annotation.Map, diagn
},
)
+ // Delete all "always safe" special handlers,... | 2 | 2 | 0 | [{"id": "G0", "claim": "Use slices.DeleteFunc to modify the pkgFullTriggers slice in-place instead of building a separate filtered slice.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Remove the now-redundant comment \"expr is not trackable, bu... | null |
uber-go__nilaway__304 | uber-go/nilaway | 304 | defect | ba14292918d814eeaea4de62da2ad0daae92f8b0 | 0c301418086542dd8e1e7361af4866c04594e682 | Handle custom iterator funcs | We added handling for `iter.Seq` and `iter.Seq2` in NilAway such that at least it does not crash (though we assume the return values are always non-nil until better support is added).
However, Go 1.23 actually introduces more powerful iter-over-func feature, where any of the following func types can be used in rang... | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c7add9ea..8e22a7be 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
- go-version: 1.23.x
+ go-version: 1.24.x
... | 6 | 4 | 2 | [{"id": "G0", "claim": "util/typeshelper/typeshelper_test.go is missing the required license header at the top of the file, which the goheader lint check reports as a failure.", "category": "maintainability", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "util/typeshelper/types... | null |
uber-go__nilaway__322 | uber-go/nilaway | 322 | defect | 2b29af14b0e7142cf2765d4d4863f58565e1185e | 46d82c49bc800eab33beaaa5c2cbff6593ba439b | Conditionally export the nolint ranges when available | In #320 we added support for cross-package nolint suppression by storing the nolint ranges as facts.
However, we are storing the facts even if there are no `//nolint` suppressions in the package. Functionally it is fine since having an empty `[]Range` is OK. However, it would introduce unnecessary codec / storage co... | diff --git a/diagnostic/nolint.go b/diagnostic/nolint.go
index 7f459364..5d821f95 100644
--- a/diagnostic/nolint.go
+++ b/diagnostic/nolint.go
@@ -87,8 +87,10 @@ func run(pass *analysis.Pass) ([]Range, error) {
upstreamRanges = append(upstreamRanges, upstreamNoLintRanges.Ranges...)
}
- // Export local nolint ran... | 1 | 1 | 1 | [{"id": "G0", "claim": "The export condition is inverted — `if len(ranges) == 0` exports nolint package facts only when there are no ranges, so empty facts keep being exported and real ranges are not, the opposite of the PR's stated intention, leaving the downstream internal panic (issue #321) unresolved.", "category":... | null |
uber-go__nilaway__344 | uber-go/nilaway | 344 | defect | d2274102dc2eab9f77cef849a5470a6ebf983125 | 98c4a6aac68c0e9925ab4d24f5298993b9e9cc12 | Add NilAway support for analyzing templ files | This PR adds initial support for https://github.com/a-h/templ generated Go files.
Specifically, templ-generated files contain heavy uses of function literals, where NilAway does not have mature-enough support for it (it is still experimental). To stop the gap temporarily, we "inline" the function literals.
A unit... | diff --git a/assertion/function/preprocess/cfg.go b/assertion/function/preprocess/cfg.go
index f58ff4f0..3f1aa322 100644
--- a/assertion/function/preprocess/cfg.go
+++ b/assertion/function/preprocess/cfg.go
@@ -95,6 +95,22 @@ func (p *Preprocessor) CFG(graph *cfg.CFG, funcDecl *ast.FuncDecl) *cfg.CFG {
markRangeState... | 1 | 1 | 1 | [{"id": "G0", "claim": "The require.Equal assertion in TestDocContains was commented out by mistake and should be restored.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}] | null |
uber-go__nilaway__36 | uber-go/nilaway | 36 | defect | 1aea433df5adac32df03ad13da8e5b6c34a940db | ba40bd8cc8ed7357da3152e7504ff9e32a9c4ce2 | [Follow-up of PR #24] Support function contract nonnil->nonnil for no infer mode | Follow up of PR #24 , support no infer mode for function contract nonnil->nonnil. This is the final PR of the stack.
For no infer mode, we annotate param and result at every call site of the contracted function. We duplicate param and return sites so they would not conflict with each other (which is done in #24 ). T... | diff --git a/accumulation/analyzer.go b/accumulation/analyzer.go
index 517d03a6..312012fc 100644
--- a/accumulation/analyzer.go
+++ b/accumulation/analyzer.go
@@ -201,7 +201,9 @@ func checkErrors(triggers []annotation.FullTrigger, annMap annotation.Map) []ann
var triggered []annotation.FullTrigger
for _, trigger ... | 1 | 1 | 0 | [{"id": "G0", "claim": "Use the exported CreatedFromDuplication field directly instead of keeping the Duplicated() wrapper method, since the encapsulation is unnecessary here.", "category": "design", "verdict": "supported", "priority": "P3", "scope": "introduced"}] | null |
uber-go__nilaway__409 | uber-go/nilaway | 409 | defect | 937701de96c7fef4f0112141ced29251d791f79a | 450be685c5962f928f6eaa40bb5b28b5b8f08d45 | Add test exclusion flag | This PR adds a top-level flag for excluding reporting of nil flows that involve test files. | diff --git a/config/config.go b/config/config.go
index 24655fe3..e78f6184 100644
--- a/config/config.go
+++ b/config/config.go
@@ -38,6 +38,8 @@ type Config struct {
ExperimentalAnonymousFuncEnable bool
// PrintFullFilePath incidates whether to print full filenames in the output.
PrintFullFilePath bool
+ // Exclu... | 1 | 1 | 0 | [{"id": "G0", "claim": "The body of involvesTestFile in diagnostic/engine.go should be simplified to a single return: strings.HasSuffix(c.position.Filename, \"_test.go\") || c.flow.involvesTestFile().", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__nilaway__47 | uber-go/nilaway | 47 | defect | 6b5d588e97aa719fc89271cda1c8aa7a804874bf | 85eae45684b579bf967458735334e34e5b36aa43 | Support for handling interface fields in affiliations analysis | This PR adds support for tracking an interface field of a struct as an affiliation site. The interface field could be embedded or declared as a normal field.
[closes #43 #44 ] | diff --git a/assertion/affiliation/affiliation.go b/assertion/affiliation/affiliation.go
index 658162f8..c1d99884 100644
--- a/assertion/affiliation/affiliation.go
+++ b/assertion/affiliation/affiliation.go
@@ -178,48 +178,51 @@ func (a *Affiliation) computeTriggersForCastingSites(pass *analysis.Pass, upstre
}
... | 6 | 4 | 0 | [{"id": "G0", "claim": "The added `parsedExpr[0].GetDeep() == nil` condition is redundant since IsDeep() implies GetDeep() != nil (the NilAway error it silences is a wontfix false positive), and getting rid of IsDeep() should happen in separate PRs.", "category": "correctness", "verdict": "supported", "priority": "P3",... | null |
uber-go__nilaway__49 | uber-go/nilaway | 49 | defect | 6b5d588e97aa719fc89271cda1c8aa7a804874bf | 1fdb28cd14fd505de836304ab3f53cecfd770c63 | Support for pkg.Const as a stable expression | NilAway already regards locally defined constants as stable expressions. However, it does not extend that behavior to constants defined in other packages accessed via selector expression `pkg.Const`. This PR adds support for the same by augmenting the logic of stable expressions.
[Closes #48] | diff --git a/assertion/function/assertiontree/root_assertion_node.go b/assertion/function/assertiontree/root_assertion_node.go
index 3b81f2a2..22a4c571 100644
--- a/assertion/function/assertiontree/root_assertion_node.go
+++ b/assertion/function/assertiontree/root_assertion_node.go
@@ -1175,8 +1175,16 @@ func (r *RootA... | 3 | 3 | 0 | [{"id": "G0", "claim": "Move the test constants out of the `maps` test package into a new dedicated package (suggested name `consts`).", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Add a global variable and corresponding test cases showing that a global... | null |
uber-go__nilaway__60 | uber-go/nilaway | 60 | defect | c0cacdd6294ea978416a1cd94ca8d49615c076e3 | 1d23b7de9ebbf73d012596264ca8e6293c667bbf | Fix false positive due to local variable deep assign | NilAway puts a restriction on deep nilable assignment to local variables. This can result in false positives, if the dereferences are properly guarded. This PR lifts this restriction and allows deep nilability into local variables, thereby addressing the false positives.
[closes #59]
[depends on #82 ] | diff --git a/annotation/consume_trigger.go b/annotation/consume_trigger.go
index 161eb51c..09b5e594 100644
--- a/annotation/consume_trigger.go
+++ b/annotation/consume_trigger.go
@@ -60,13 +60,14 @@ type ConsumingAnnotationTrigger interface {
// This implies loss of information about the assignment. This method is us... | 1 | 1 | 0 | [{"id": "G0", "claim": "The doc comment on LocalVarAnnotationKey says it allows the lookup of a global variable's annotations; it should say a local variable's annotations.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__nilaway__88 | uber-go/nilaway | 88 | defect | c0cacdd6294ea978416a1cd94ca8d49615c076e3 | 3e71eac48df33606b67848f1e9cafef8055d78bc | Track interprocedural deep nilability | This PR addresses false negatives related to interprocedural deep nilability by adding support for the same.
[closes #61]
[depends on #60] | diff --git a/annotation/consume_trigger.go b/annotation/consume_trigger.go
index 161eb51c..637e159b 100644
--- a/annotation/consume_trigger.go
+++ b/annotation/consume_trigger.go
@@ -60,13 +60,14 @@ type ConsumingAnnotationTrigger interface {
// This implies loss of information about the assignment. This method is us... | 4 | 3 | 0 | [{"id": "G0", "claim": "The String() methods of the new Prestring types should use fmt.Sprintf instead of strings.Builder for readability.", "category": "maintainability", "verdict": "opposed", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The IsNamedReturn flag and RetName field of UseAsReturnDeepPr... | null |
uber-go__ratelimit__19 | uber-go/ratelimit | 19 | defect | c15da02342779cb6dc027fc95ee2277787698f36 | 325e26475a0b307f5bf5f954d72a5c4c09fa827b | Fix import path for atomic test dependency | Fixes #18
Adds a change log. | diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..57a882b
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,17 @@
+# Changelog
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project ad... | 2 | 2 | 2 | [{"id": "G0", "claim": "The CHANGELOG incorrectly lists a \"1.0.0 - 2016-09-09\" release under a repo that has never released anything, so that entry (and the thinking behind it) should be backed out.", "category": "documentation", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": ... | null |
uber-go__ratelimit__31 | uber-go/ratelimit | 31 | defect | ecb970a6a3b3b0a49f74254576f1e939a1950aa4 | b2612c82eed9765dd0881ea1ceba7d9102dfe239 | Switch from glide to Go Modules | Per discussion not keeping glide for backwards compatibility,
go modules should be enough.
Also fixed a bad import in tests, came up during testing. | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 819e97c..7d12ac1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versio... | 2 | 2 | 0 | [{"id": "G0", "claim": "The CHANGELOG entry should end with a period, as suggested.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The go.mod requirement should be upgraded to testify v1.7.0 since a new release was just cut.", "category": "maintai... | null |
uber-go__ratelimit__34 | uber-go/ratelimit | 34 | defect | 2cc0b02b8bdafca3b7c27b6850c4bd6d3188b942 | d49575a760df3d931b8331dd8cd722d1be792698 | Fix linting issues. | Now that we have linting(#33), we should make sure linting passes. | diff --git a/internal/clock/clock.go b/internal/clock/clock.go
index 17569d8..d241dd5 100644
--- a/internal/clock/clock.go
+++ b/internal/clock/clock.go
@@ -119,8 +119,10 @@ type Timer struct {
mock *Mock // mock clock
}
+// Next returns next tick time.
func (t *Timer) Next() time.Time { return t.next }
+//... | 1 | 1 | 1 | [{"id": "G0", "claim": "The padding field must not be removed, as it is crucial to maintain performance properties of this rate limiter in case of collocation with other frequently accessed memory.", "category": "performance", "verdict": "supported", "priority": "P1", "scope": "introduced"}] | null |
uber-go__ratelimit__85 | uber-go/ratelimit | 85 | defect | 979a121132b82b513f54b5044309c386f843ba04 | 877859c5409699291e8430ef6416d838507daa3d | New atomic-based implementation squeezed into int64 | Hi everyone,
It's been a few years since we introduced the atomic-based rate limiter. Since then, after numerous changes to the runtime scheduler, mutex-based implementation has become much more stable.
So I found a way to improve atomic-based implementation further and squeeze its state into one `int64`. The new im... | diff --git a/.gitignore b/.gitignore
index aa346ac..23bd489 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,5 +2,10 @@
/vendor
cover.html
cover.out
+profile.out
+stat.csv
+stat.txt
+stat.html
*.swp
+.idea
diff --git a/Makefile b/Makefile
index 5bab5d7..7eb6d24 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,18 @@ ... | 13 | 8 | 0 | [{"id": "G0", "claim": "The benchmarking tooling changes (Makefile targets, benchstat/benchart) should be put up as a separate PR landed before this one, to keep the history clean and separate.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The ... | null |
uber-go__tally__1 | uber-go/tally | 1 | defect | 576c111992c76fad4ef50b63fa5a4fd90f65ba08 | 913884ea71d5f7d603c99b57dcbefd322eac9fcd | make the root scope responsible for periodic reporting. make better m… | This adds special logic to NewScope that creates a registry of scopes/subscopes and attaches a timer loop that will dump the stats from the scopes to the StatsReporter.
I decided to update the example to illustrate how this api is to be used, and to detach it from the cactus library (real implementations for statsd sh... | diff --git a/example/main.go b/example/main.go
new file mode 100644
index 00000000..3ae2d175
--- /dev/null
+++ b/example/main.go
@@ -0,0 +1,74 @@
+// Copyright (c) 2016 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated docume... | 5 | 3 | 1 | [{"id": "G0", "claim": "It is unclear where the unexported scope interface is used.", "category": "design", "verdict": "opposed", "priority": "P3", "scope": "pre_existing"}, {"id": "G1", "claim": "A Scope should be closable (a scope.Close() method) so its reporting goroutine does not leak once the scope is no longer ne... | null |
uber-go__tally__120 | uber-go/tally | 120 | defect | 5431c04afc0bad76ce91ca3d549abb469abd2a10 | 5e2a8d33e5acbac7131bcee00e0f1ce12acc4a4c | m3: Reduce allocations when emitting metrics | Similar to #116, emitting metrics requires allocations as TUDPTransport
does not implement TRichTransport, so we end up allocating to convert
`string` to `[]byte`.
Add a new benchmark BenchmarkEmitMetrics to measure the impact. This
change brings down allocations significantly:
```
benchmark old ... | diff --git a/m3/reporter_benchmark_test.go b/m3/reporter_benchmark_test.go
index cfad69c7..9cf01c39 100644
--- a/m3/reporter_benchmark_test.go
+++ b/m3/reporter_benchmark_test.go
@@ -21,8 +21,11 @@
package m3
import (
+ "fmt"
"testing"
"time"
+
+ "github.com/uber-go/tally"
)
const (
@@ -50,6 +53,30 @@ func ... | 2 | 2 | 0 | [{"id": "G0", "claim": "Put the TRichTransport interface-assertion var next to the TUDPTransport type declaration instead of in the test file.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introduced"}, {"id": "G1", "claim": "The ReadByte implementation could be simpler: check err... | null |
uber-go__tally__121 | uber-go/tally | 121 | defect | 5431c04afc0bad76ce91ca3d549abb469abd2a10 | ad3ae1d53768122cf32e49d2b9172fc3bd993574 | Optimize Scope.cacheReport | Optimize the cacheReport path for all Scopes.
Results for the added benchmark (master v HEAD):
```
benchmark old ns/op new ns/op delta
BenchmarkScopeReporting/size1-4 79.6 42.0 -47.24%
BenchmarkScopeReporting/size10-4 201 ... | diff --git a/scope.go b/scope.go
index 40092fe7..d2d6ff24 100644
--- a/scope.go
+++ b/scope.go
@@ -27,6 +27,10 @@ import (
"time"
)
+const (
+ defaultInitialSliceSize = 16
+)
+
var (
// NoopScope is a scope that does nothing
NoopScope, _ = NewRootScope(ScopeOptions{Reporter: NullStatsReporter}, 0)
@@ -72,10 +... | 5 | 4 | 0 | [{"id": "G0", "claim": "The four per-metric locks all sit on a single cache line, so having four locks may be overkill compared to one lock without benchmarks proving it superior.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "pre_existing"}, {"id": "G1", "claim": "timersSlice is decla... | null |
uber-go__tally__133 | uber-go/tally | 133 | defect | 798e6594bd9466947d80e8c18252d45e6b37d398 | c1e00e07cfb1040a0ee77225ef831068702b9888 | subscoping: Defer tag merging | **Commits should be reviewed individually.**
This improves the performance of creating subscopes with new tags by
deferring merged map creation.
We currently create the merged map of tags first, and then calculate the
key which we use to determine if we have a cached subscope.
With this change, we calculate ... | diff --git a/key_gen.go b/key_gen.go
index e7d916c3..b81f8f7d 100644
--- a/key_gen.go
+++ b/key_gen.go
@@ -54,12 +54,22 @@ func KeyForPrefixedStringMap(
prefix string,
stringMap map[string]string,
) string {
+ return keyForPrefixedStringMaps(prefix, stringMap)
+}
+
+// keyForPrefixedStringMaps generates a unique k... | 4 | 4 | 0 | [{"id": "G0", "claim": "It would be even more performant to keep slices of tags (key/value pairs) and merge those with the user-provided tag map on scope creation.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Typo in the comment: \"precdence\" sho... | null |
uber-go__tally__135 | uber-go/tally | 135 | defect | 5673c5ab33efed62aebcf0066ca5926650db4d2f | 3e23a6e19dc34bc9610698c2c6ce64fc856e9bc8 | Allow Prometheus reporter listen on unix domain socket address | This PR will allow prometheus reporter listen on unix domain socket address. This is very useful when running under a situation when port conflicts occur often.
Currently, if specify a UDS address like `unix:/tmp/tally-metrics.sock` as listening address, reporter would fail to start as `http.ListenAndServe()` used b... | diff --git a/prometheus/config.go b/prometheus/config.go
index ce4c1a0e..303a20ee 100644
--- a/prometheus/config.go
+++ b/prometheus/config.go
@@ -23,6 +23,7 @@ package prometheus
import (
"fmt"
"log"
+ "net"
"net/http"
"os"
"strings"
@@ -36,6 +37,10 @@ type Configuration struct {
// HTTP handler path "/me... | 1 | 1 | 0 | [{"id": "G0", "claim": "Rename the short variable names `nwk` and `lsn` in prometheus/config.go to the long-form names `network` and `listener`.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__tally__156 | uber-go/tally | 156 | defect | b7bc80a1e6e81f4b9239fb9048ae46e99430014e | 7ac9340a27eab4ea90488a8ace8c848c7e0124f3 | Share allocated tags among cached metrics | This change:
1. Introduces string interning for allocated metrics, including names and tag keys/values
2. Shares tags among metrics where possible
3. Introduces tag caching
4. Reduces histogram bucket allocations by reporting using closures instead of heap-allocating the buckets themselves | diff --git a/histogram.go b/histogram.go
index caefed2c..24d7598a 100644
--- a/histogram.go
+++ b/histogram.go
@@ -72,7 +72,7 @@ func (v ValueBuckets) String() string {
// AsValues implements Buckets.
func (v ValueBuckets) AsValues() []float64 {
- return []float64(v)
+ return v
}
// AsDurations implements Bucke... | 1 | 1 | 0 | [{"id": "G0", "claim": "Cached tag entries are never expired or evicted, so unless tags are assumed not to change over the reporter's lifetime the tag cache grows without bound (e.g. for metrics tagged with UUIDs).", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__tally__16 | uber-go/tally | 16 | defect | 2750b4ae690cbeb294016efe18ceaeb80c4ce17c | 7a05a2b712c8d4a769190eb982a614c7d17974e6 | Add prometheus backend support | Adds a new reporter that supports the prometheus registry backend.
| diff --git a/glide.lock b/glide.lock
index b0345b25..86ae315d 100644
--- a/glide.lock
+++ b/glide.lock
@@ -1,12 +1,41 @@
-hash: 31fe24e56ca2f9d4b7adf1e039cda071aea42db95c0cfb7e81654456bfabefb6
-updated: 2016-10-21T14:09:29.39810001-07:00
+hash: 6f924ebe8f8cf2fc4ef2df8dff6ec1fb0ab38ee329c28e33e3c9d9d1ad6e50e5
+updated: ... | 9 | 8 | 3 | [{"id": "G0", "claim": "The already-registered error should follow Go naming conventions, i.e. `errAlreadyRegistered = errors.New(\"metric already registered\")` instead of `errorAlreadyRegistered = fmt.Errorf(\"Metric already registered\")`.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "i... | null |
uber-go__tally__167 | uber-go/tally | 167 | defect | 858a70a463705c87bfc90588bc951fb9eec7a30b | 35e42fdf5afda683034afaa8b84d6b89d4d41620 | [modules][deps] Move to Go modules, unfork Prometheus | This upgrades the Prometheus lib to address fnv-1a hash collisions, which also requires upgrading to Go modules. | diff --git a/glide.lock b/glide.lock
deleted file mode 100644
index 05853b28..00000000
--- a/glide.lock
+++ /dev/null
@@ -1,76 +0,0 @@
-hash: bfadfc85c3b6bf803090b34bbbcc4b9e16165226e8b4c194658b8ba105c3438b
-updated: 2021-02-11T15:18:03.188401-05:00
-imports:
-- name: github.com/beorn7/perks
- version: 4c0e84591b9aa9e... | 1 | 1 | 1 | [{"id": "G0", "claim": "The module path in the new go.mod should be `github.com/uber-go/tally/v4` instead of `github.com/uber-go/tally`.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}] | null |
uber-go__tally__172 | uber-go/tally | 172 | defect | 137973e539cd3589f904c23d0b3a28c579fd0ae4 | bb148187e8dd65bb0a8fb86b19202269c1c07422 | sanitizing tags after cache lookup to reduce allocations and other optimizations | Tagged scopes sanitize the tags and create an instance of the scope and cache that scope. Sanitization involves allocating a map.
The change is to lookup from the cache using the tags before sanitization and add to the cache after tag sanitization. Both keys (pre and post sanitization) are added to cache so that mu... | diff --git a/key_gen.go b/key_gen.go
index 9030e1c9..07a4f3f0 100644
--- a/key_gen.go
+++ b/key_gen.go
@@ -23,6 +23,7 @@ package tally
import (
"bytes"
"sort"
+ "unsafe"
)
const (
@@ -38,7 +39,28 @@ var (
type keyGenerationPool struct {
bufferPool *ObjectPool
- stringsPool *ObjectPool
+ stringsPool *Stri... | 6 | 6 | 0 | [{"id": "G0", "claim": "Instead of the object pool for the tag-key string slices, use stack-allocated slices (trying it out to see if the code becomes simpler and saves the pool interaction).", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "Use a stac... | null |
uber-go__tally__189 | uber-go/tally | 189 | defect | 86b6b098e1bf983a455c56d0a00a6b90c18a3425 | 7cbaf29eacc800ff2b6c04183c2fd5fc40d11d03 | Report Tag cache size as part of internal metrics | This helps service owners know if they are causing Tally to use too much memory | diff --git a/internal/cache/tag_cache.go b/internal/cache/tag_cache.go
index b5f6cfcf..8eb37720 100644
--- a/internal/cache/tag_cache.go
+++ b/internal/cache/tag_cache.go
@@ -67,6 +67,13 @@ func (c *TagCache) Set(key uint64, tslice []m3thrift.MetricTag) []m3thrift.Metri
return tslice
}
+// Len returns the size of ... | 3 | 3 | 1 | [{"id": "G0", "claim": "Revert the autoformatter's re-flowed function calls in m3/reporter.go back to the previous, more readable layout, and don't split a call over multiple lines without putting each parameter on its own line.", "category": "maintainability", "verdict": "supported", "priority": "P3", "scope": "introd... | null |
uber-go__tally__203 | uber-go/tally | 203 | defect | bd2846e6da95c6d959ef3bd47cab07f2d514380c | 6c7200b8eef5905c0563e8f01edd6469574e7eff | fix broken internal metrics names and make them optional | This addresses https://github.com/uber-go/tally/issues/198 | diff --git a/scope.go b/scope.go
index 7888fc48..074942c0 100644
--- a/scope.go
+++ b/scope.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2022 Uber Technologies, Inc.
+// Copyright (c) 2023 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and assoc... | 4 | 1 | 1 | [{"id": "G0", "claim": "A default internal-metrics option should eventually be set when the option is left unset (the new Unset value means internal metrics reporting silently stays off unless the caller opts in).", "category": "design", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "cl... | null |
uber-go__tally__205 | uber-go/tally | 205 | defect | 086df4378f776fbf318b8513c242faebdd2d66a7 | 4d8bb9b62fb74668815e66c70992dab199dd724b | Fix for bad prometheus metrics name | This resolves https://github.com/uber-go/tally/issues/198 and improves usability of the internal metrics toggle and mirrors the change in the v3 branch. | diff --git a/m3/reporter_integration_test.go b/m3/reporter_integration_test.go
index 8238d01e..4ccfe586 100644
--- a/m3/reporter_integration_test.go
+++ b/m3/reporter_integration_test.go
@@ -110,7 +110,7 @@ func testProcessFlushOnExit(t *testing.T, i int) {
require.Equal(t, 1, len(server.Service.getBatches()))
requ... | 1 | 1 | 0 | [{"id": "G0", "claim": "The internal metrics cardinality names are sanitized on every flush in reportInternalMetrics instead of being sanitized once.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__tally__212 | uber-go/tally | 212 | defect | 007e844c400c1a16420fe6019d12f010acb11f73 | 188705870a6504971b6890c605a490908f442aa2 | fixing race condition in ForEachScope | This fixes an issue in ForEachScope() where a subscopeBucket could be updated during snapshot. | diff --git a/scope_registry.go b/scope_registry.go
index fa643497..c52514db 100644
--- a/scope_registry.go
+++ b/scope_registry.go
@@ -125,11 +125,11 @@ func (r *scopeRegistry) CachedReport() {
func (r *scopeRegistry) ForEachScope(f func(*scope)) {
for _, subscopeBucket := range r.subscopes {
+ subscopeBucket.mu.... | 3 | 2 | 1 | [{"id": "G0", "claim": "The new test should be expressed in terms of ForEachScope, since that is where the actual bug is, ideally keeping both a ForEachScope test and a Snapshot test.", "category": "testing", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "ForEachScope's unlocke... | null |
uber-go__tally__214 | uber-go/tally | 214 | defect | af61906a670c4422606808c0d7724a91b3b293de | 4da08b332b544c84409fd942d4d13fad97adbdf1 | Add goleak checking to tests | This adds goleak testing across all tests in package tally and fixes goroutine leaks in scope related tests. | diff --git a/go.mod b/go.mod
index 39fc33a3..426028ab 100644
--- a/go.mod
+++ b/go.mod
@@ -7,9 +7,10 @@ require (
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_model v0.2.0
- github.com/stretchr/testify v1.4.0
+ github.com/stretchr/testify v1.8.0
github.co... | 4 | 4 | 1 | [{"id": "G0", "claim": "The goroutine started by TestForEachScopeConcurrent (and the analogous one in TestSnapshotConcurrent) must be guaranteed to exit before the test completes, e.g. via a done channel closed by the goroutine and waited on, since the quit send/recv only synchronizes the receive itself and the gorouti... | null |
uber-go__tally__221 | uber-go/tally | 221 | defect | 880f28565f70db34b0d7e47a5d4d80c6a3bfceeb | 7b66ce170140d439af8d9421aa6e3908771d245e | [bug] Ensure that parent scopes do not return closed subscopes | This changes subscoping behavior to check the closed-ness of a cached subscope (if found) within the registry, and if it is closed, report and remove it immediately so that a new subscope can be created. The previous eventually-consistent behavior is also still intact: closed subscopes will either be pruned preemptivel... | diff --git a/generate.go b/generate.go
new file mode 100644
index 00000000..43d2efd5
--- /dev/null
+++ b/generate.go
@@ -0,0 +1,7 @@
+package tally
+
+import (
+ _ "github.com/golang/mock/mockgen/model"
+)
+
+//go:generate mockgen -package tallymock -destination tallymock/stats_reporter.go -imports github.com/uber-go/t... | 2 | 2 | 0 | [{"id": "G0", "claim": "Move the duplicated tag-sanitization and key-derivation lines out of the if/else block in Subscope so the else branch can be dropped.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The test comments should no longer menti... | null |
uber-go__tally__246 | uber-go/tally | 246 | defect | 83f98613e9934792c42c3d1c2694688d5bc9dccb | 57ca96d2c0a1ec666ca9eb5ef6a50256a91a228e | do not allocate gauge if cardinality metrics are turned off | Changes:
- Cached gauges will not be allocated if omitCardinalityMetrics is set to true | diff --git a/scope_registry.go b/scope_registry.go
index d1481da..fc1b50b 100644
--- a/scope_registry.go
+++ b/scope_registry.go
@@ -103,7 +103,7 @@ func newScopeRegistryWithShardCount(
}
r.subscopes[i].s[scopeRegistryKey(root.prefix, root.tags)] = root
}
- if r.root.cachedReporter != nil {
+ if r.root.cachedRe... | 1 | 1 | 1 | [{"id": "G0", "claim": "Add a unit test covering the new behavior of not allocating the cardinality gauge when cardinality metrics are turned off.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}] | null |
uber-go__tally__266 | uber-go/tally | 266 | defect | 22fe011f5ff0b7e55dc9d2210f405ca6a72765d3 | d3bc234794f92b2fb9d37677172bf4559ee90c4f | Fix duration buckets overflow | Fix for #264
This PR addresses an overflow issue in `ExponentialDurationBuckets`, which can cause negative durations due to integer wrap-around when converting large values into `time.Duration`.
### Problem
Under the hood, `time.Duration` is represented as an `int64` nanosecond value. When the exponential scaling... | diff --git a/histogram.go b/histogram.go
index 41491d9..fcbf3f2 100644
--- a/histogram.go
+++ b/histogram.go
@@ -368,7 +368,7 @@ func ExponentialDurationBuckets(start time.Duration, factor float64, n int) (Dur
curr := start
for i := range buckets {
buckets[i] = curr
- curr = time.Duration(float64(curr) * factor... | 6 | 3 | 1 | [{"id": "G0", "claim": "The bounds check should be done on all the bucket ctors (linear/exponential/etc); at S1 LinearDurationBuckets still sums start + i*width with no overflow protection, unlike the exponential duration ctor the PR patched.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope... | null |
uber-go__tally__32 | uber-go/tally | 32 | defect | 58c90d19d305abc44b0c81bd6c8343468cae4c3f | e2f764e9b6ac15c5d6b93a55684f5375b7c068b3 | Add zero allocation Stopwatch for both timer and histograms | It's still a little slower than the default `start := time.Now(); timer.Record(time.Since(start))` but it doesn't cause any allocations any longer.
```
$ go test -v -run none -bench BenchmarkTimerStopwatch -benchmem
BenchmarkTimerStopwatch-4 30000000 51.3 ns/op 0 B/op 0 al... | diff --git a/stats.go b/stats.go
index d6c7361c..7d4b2fad 100644
--- a/stats.go
+++ b/stats.go
@@ -172,10 +172,6 @@ func newTimer(
return t
}
-func (t *timer) Start() Stopwatch {
- return timerStopwatch{start: globalClock.Now(), timer: t}
-}
-
func (t *timer) Record(interval time.Duration) {
if t.cachedTimer !=... | 2 | 1 | 0 | [{"id": "G0", "claim": "The exported Stopwatch struct fields should be made unexported to encapsulate implementation details.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The RecordStopwatch method name seems specific to the Stopwatch use case; the aut... | null |
uber-go__tally__33 | uber-go/tally | 33 | defect | 58c90d19d305abc44b0c81bd6c8343468cae4c3f | 1bcf082247f5e09e768418fd8786bccd133f6ecb | Fix possible flush after close semantics for scope | There was the possibility a reporter might have `Flush` or any of the other report methods called on it after it had been closed itself. This change fixes that possibility by holding a status lock during each report loop run.
cc @xichen2020 | diff --git a/scope.go b/scope.go
index 1caf3b59..c3fd9328 100644
--- a/scope.go
+++ b/scope.go
@@ -66,7 +66,7 @@ type scope struct {
defaultBuckets Buckets
registry *scopeRegistry
- quit chan struct{}
+ status *scopeStatus
cm sync.RWMutex
gm sync.RWMutex
@@ -79,6 +79,12 @@ type scope struct {
histog... | 1 | 1 | 0 | [{"id": "G0", "claim": "The scope's status field could be declared as `scopeStatus` instead of `*scopeStatus` to reduce a level of indirection.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__tally__35 | uber-go/tally | 35 | defect | 34be4a565ce6286a0ba91a54a81be3f6181ca2e2 | 2941c8a52d530de3f619cf425e692fee1d95be0f | Use a unique ID for metrics returned from Snapshot | This PR addresses #34 by introducing a new function `uniqueID` which will create a unique ID for a metric using it fully qualified name and tags. This ID is then used as the key for the maps created `Snapshot` so that metrics with the same fully qualified names but different tags will not overwrite one another. | diff --git a/scope.go b/scope.go
index 80983bcf..f611569b 100644
--- a/scope.go
+++ b/scope.go
@@ -21,8 +21,10 @@
package tally
import (
+ "bytes"
"fmt"
"io"
+ "sort"
"sync"
"time"
@@ -34,6 +36,12 @@ var (
NoopScope, _ = NewRootScope(ScopeOptions{Reporter: NullStatsReporter}, 0)
// DefaultSeparator is... | 10 | 9 | 0 | [{"id": "G0", "claim": "Pass the already-computed `name` to `uniqueID` so it does not need to call `fullyQualifiedName` a second time.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The buffer-sizing comment should read `Size of ...` rather than sta... | null |
uber-go__tally__50 | uber-go/tally | 50 | defect | 88e9c75b0cfc84139ad1bae3b7f123786cfd0770 | 7bf8352bbbde71f7d06e697276ca4320747bb13b | Ability to sanitise metric identifiers | Added the ability for users to sanitise metrics.
Benchmark results:
#### Master
```
❯ go test -bench=NewMetric ./m3
BenchmarkNewMetric-4 10000000 183 ns/op
PASS
ok github.com/uber-go/tally/m3 2.364s
```
#### PR
```
❯ go test -bench=NewMetric ./m3
BenchmarkNewMetric-4 10... | diff --git a/m3/config.go b/m3/config.go
index 86e690cc..2a90a120 100644
--- a/m3/config.go
+++ b/m3/config.go
@@ -45,6 +45,9 @@ type Configuration struct {
// IncludeHost is whether or not to include host tag.
IncludeHost bool `yaml:"includeHost"`
+
+ // SanitizeMetrics is whether or not metric identifiers (name... | 4 | 3 | 2 | [{"id": "G0", "claim": "The sanitisation setting should be a pluggable public SanitiseFn/Sanitiser API with out-of-the-box sanitizers and separate name/key/value sanitisers, exposed via the root tally package's ScopeOptions rather than a boolean flag on the M3 reporter config.", "category": "design", "verdict": "suppor... | null |
uber-go__tally__51 | uber-go/tally | 51 | defect | ae42cdc5e44f46f9d99d508b70bd525e627bb7e7 | 6e9f7de8ba962dd80d7e59e65999000e026066ee | Americanise sanitise | - s/sanitise/sanitize
/cc @robskillington @jeromefroe | diff --git a/m3/sanitise.go b/m3/sanitise.go
index 4cc7b719..856f6ad1 100644
--- a/m3/sanitise.go
+++ b/m3/sanitise.go
@@ -25,8 +25,8 @@ import (
)
var (
- // DefaultSanitiserOpts are the options for the default M3 Sanitiser
- DefaultSanitiserOpts = tally.SanitiseOptions{
+ // DefaultSanitizerOpts are the options f... | 1 | 1 | 0 | [{"id": "G0", "claim": "The file m3/sanitise.go should also be renamed (to m3/sanitize.go) as part of the Americanisation, since the PR already renamed the other sanitise files.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__tally__54 | uber-go/tally | 54 | defect | 2605c407d7d219644d03a3680ad7df4779017782 | d0abde7f4b897bfb36b94c2266aaecc3f1434962 | Implement InstrumentedCall | go-common's metric interface includes this functionality. It would be great to include it in tally as well since it simplifies application code, we don't need to explicitly handle timers and error cases every time we want to include metrics | diff --git a/scope.go b/scope.go
index cbd06027..e847c55a 100644
--- a/scope.go
+++ b/scope.go
@@ -499,6 +499,16 @@ func (s *scope) Snapshot() Snapshot {
return snap
}
+// InstrumentedCall returns an InstrumentedCall with the given name
+func (s *scope) InstrumentedCall(name string) InstrumentedCall {
+ return &in... | 10 | 9 | 4 | [{"id": "G0", "claim": "Create the counters and timer at instantiation of the InstrumentedCall to avoid map lookups when incrementing/recording, and keep the same counter name tagged with result_type:error / result_type:success so an error/success ratio can be computed.", "category": "design", "verdict": "supported", "... | null |
uber-go__tally__55 | uber-go/tally | 55 | defect | 3dd04ef56cd35c17745bbb2716a87e795ce74589 | 793e36561d297957597c478c0961cfeb4af58380 | Refactor InstrumentedCall to Call in instrument package | To reduce public API surface area from the base `tally` package. | diff --git a/instrument.go b/instrument/call.go
similarity index 61%
rename from instrument.go
rename to instrument/call.go
index df8b6ef5..2fd84aad 100644
--- a/instrument.go
+++ b/instrument/call.go
@@ -18,34 +18,34 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-... | 4 | 4 | 0 | [{"id": "G0", "claim": "The doc comment on NewCall should say that it returns a Call instead of vaguely saying it returns an instrumented call (\"nit: NewCall returns a Call ...\").", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The Call doc comme... | null |
uber-go__zap__1011 | uber-go/zap | 1,011 | defect | a0e238043847ecbd9e4c6e433a922d4fd0382ef7 | 7255fee7eaeaaea4f39561d593c341168356f86e | JSON: Fix complex64 encoding precision | Converting `complex64` to `complex128` meant that
the real and imaginary components of the `complex64` value
were encoded as `float64` values which,
similar to #1002, encoded them with incorrect precision.
Fix this by adding a precision parameter during encoding to specify
the precision with which the components... | diff --git a/CHANGELOG.md b/CHANGELOG.md
index b077ab08b..6e2b014ce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
-* No changes yet.
... | 1 | 1 | 0 | [{"id": "G0", "claim": "The change may take a performance hit because float32/complex64 payloads are no longer all 64-bit (possible alignment/cache-locality cost in pooled buffers), and benchmarks should be run to understand the impact.", "category": "performance", "verdict": "supported", "priority": "P2", "scope": "in... | null |
uber-go__zap__1039 | uber-go/zap | 1,039 | defect | 10b1fe4a64fb4d879fb091383db84fb5a4381329 | ba0bbf8fdfe740678f1e070080d6ff36ae13140a | feat: add support for custom ReflectType encoder | Hi Team!
This fixes #1034 | diff --git a/zapcore/encoder.go b/zapcore/encoder.go
index ad8712aba..e06b68155 100644
--- a/zapcore/encoder.go
+++ b/zapcore/encoder.go
@@ -22,6 +22,7 @@ package zapcore
import (
"encoding/json"
+ "io"
"time"
"go.uber.org/zap/buffer"
@@ -331,6 +332,9 @@ type EncoderConfig struct {
// Unlike the other prim... | 8 | 8 | 3 | [{"id": "G0", "claim": "The NewReflectedEncoder field's struct tags should be `-` for both json and yaml because a func value cannot be JSON/YAML encoded.", "category": "correctness", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "The default NewReflectedEncoder should be assig... | null |
uber-go__zap__1079 | uber-go/zap | 1,079 | defect | 212dcb966b47f20c741c821bf5f89f127a8ca7b9 | 308dfc3dbfcf063a36198ca338c9f12c7e115ddc | Add WithOptions to SugaredLogger | Closes #1072.
I added a simple test for this feature. One thought to add more comprehensive tests would be to replace the following line in the [`withSugar`](https://github.com/uber-go/zap/blob/212dcb966b47f20c741c821bf5f89f127a8ca7b9/common_test.go#L43) function in `common_test.go`:
```
withLogger(t, e, opts, fun... | diff --git a/sugar.go b/sugar.go
index 0b9651981..3b593533f 100644
--- a/sugar.go
+++ b/sugar.go
@@ -61,6 +61,16 @@ func (s *SugaredLogger) Named(name string) *SugaredLogger {
return &SugaredLogger{base: s.base.Named(name)}
}
+// WithOptions clones the base Logger, applies the supplied Options, wraps
+// the resul... | 1 | 1 | 0 | [{"id": "G0", "claim": "The WithOptions doc comment reports too much of the implementation and should be simplified to say it clones the current SugaredLogger, applies the supplied Options, and returns the result.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__zap__1088 | uber-go/zap | 1,088 | defect | 75dacb47ccd67c3c1fd765ac43a71b7005f0ae51 | 68e4105ef8649e3398c062b2eb97f14e7bb5a6e9 | Add WithFatalHook/CheckedEntry.After to replace OnFatal/CheckedEntry.Should | Fixes #1086
## Changes
- Deterministic calculate the POSIX return code for Fatal method | diff --git a/internal/exit/exit.go b/internal/exit/exit.go
index dfc5b05fe..187fe5bfe 100644
--- a/internal/exit/exit.go
+++ b/internal/exit/exit.go
@@ -24,24 +24,32 @@ package exit
import "os"
-var real = func() { os.Exit(1) }
+var _exit = os.Exit
// Exit normally terminates the process by calling os.Exit(1). ... | 4 | 2 | 0 | [{"id": "G0", "claim": "The goroutine and channel in TestLoggerWithFatalHook are unnecessary because logger.Fatal will not panic when the write action is overridden, so the test should be simplified.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim":... | null |
uber-go__zap__1105 | uber-go/zap | 1,105 | defect | 41970cf6c4376c920ee63fe1fa853e793e0b91b8 | 310a1d88dea82fa160465a5535b2de53c5cd1230 | Add Must(*Logger, error) *Logger function | Resolves #640. | diff --git a/example_test.go b/example_test.go
index aecf41246..327e3ef39 100644
--- a/example_test.go
+++ b/example_test.go
@@ -91,10 +91,7 @@ func Example_basicConfiguration() {
if err := json.Unmarshal(rawJSON, &cfg); err != nil {
panic(err)
}
- logger, err := cfg.Build()
- if err != nil {
- panic(err)
- }
+... | 1 | 1 | 1 | [{"id": "G0", "claim": "Add a quick test to cover the panic branch in Must.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}] | null |
uber-go__zap__1149 | uber-go/zap | 1,149 | defect | bdd673d714c1278fd09836d7cf57ed60fa072bf4 | 76f9a9eef88de148328c94bb36036b6732bb51f9 | Wrap Open error and update TestOpen to check for fs.ErrNotExist | This is a prefactor for Windows support (#621).
`TestOpen` currently relies on a hardcoded error "no such file or
directory" if a file is not found. However, this error message is
OS-specific. We can now rely on `errors.Is(err, fs.ErrNotExist)`
if we wrap errors using `%w` instead of `%v`. | diff --git a/writer.go b/writer.go
index 00eba4ed7..504974968 100644
--- a/writer.go
+++ b/writer.go
@@ -70,7 +70,7 @@ func open(paths []string) ([]zapcore.WriteSyncer, func(), error) {
for _, path := range paths {
sink, err := newSink(path)
if err != nil {
- openErr = multierr.Append(openErr, fmt.Errorf("cou... | 4 | 4 | 0 | [{"id": "G0", "claim": "The error message should be changed to \"open sink %q: %w\" to conform to the Uber style guide's error wrapping rules.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The three nearly exclusive code paths in TestOpen shoul... | null |
uber-go__zap__1155 | uber-go/zap | 1,155 | defect | 1e46f5e6d5d0714ba826e0b7ccdbbad9eab79311 | 2101cabe17fc0752b08e4110b8c0d89ec916f50e | Add Stringers field constructor for array of objects implementing fmt.Stringer method | Add a new Zap field constructor that encodes an array of zero or more
objects which implement fmt.Stringer interface into a Zap array.
Usage:
// type Request struct{ ... }
// func (a Request) String() string
//
// var requests []Request = ...
// logger.Info("sending requests", zap.Stringers("requests", reque... | diff --git a/array_go118.go b/array_go118.go
index db36ec37f..71d205231 100644
--- a/array_go118.go
+++ b/array_go118.go
@@ -23,7 +23,11 @@
package zap
-import "go.uber.org/zap/zapcore"
+import (
+ "fmt"
+
+ "go.uber.org/zap/zapcore"
+)
// Objects constructs a field with the given key, holding a list of the
//... | 5 | 3 | 0 | [{"id": "G0", "claim": "Some sort of benchmark should be added to show the benefit of this, since the only way before was to use zap.Any.", "category": "testing", "verdict": "uncertain", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "A test for a []fmt.Stringer should also be added, since that should ... | null |
uber-go__zap__1159 | uber-go/zap | 1,159 | defect | 1ae5819539453056267ba3033697df2b231e8af8 | 37d72b92b7b6b48f7e8c79b3c463bc94c496ef48 | Open absolute paths as files, limited Windows support | Ref #994, #1000
Alternate approach to #999, this approach brings absolute path support to Windows.
It does so by checking for absolute paths and handling them using the file factory directly.
To test different paths without trying to actually open them (UNC paths hit the network), this change also
prefactors th... | diff --git a/sink.go b/sink.go
index df46fa87a..8a86bc7b7 100644
--- a/sink.go
+++ b/sink.go
@@ -34,23 +34,7 @@ import (
const schemeFile = "file"
-var (
- _sinkMutex sync.RWMutex
- _sinkFactories map[string]func(*url.URL) (Sink, error) // keyed by scheme
-)
-
-func init() {
- resetSinkRegistry()
-}
-
-func re... | 2 | 2 | 0 | [{"id": "G0", "claim": "The sinkRegistry type definition should be moved closer to its constructor (right above newSinkRegistry) instead of sitting far from it.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "newSinkRegistry() should be defined inside eac... | null |
uber-go__zap__1185 | uber-go/zap | 1,185 | defect | 9137e0e8425dfe68a311dc4f84908f17531c616e | 03bdfb2ee3ff0156475620bde33be14c1a3af53f | SugaredLogger: Turn error into zap.Error | Resolves #1184.
Please let me know what you think! Thanks. | diff --git a/sugar.go b/sugar.go
index e42b694ed..61076c985 100644
--- a/sugar.go
+++ b/sugar.go
@@ -31,6 +31,7 @@ import (
const (
_oddNumberErrMsg = "Ignored key without a value."
_nonStringKeyErrMsg = "Ignored key-value pairs with non-string keys."
+ _multipleErrMsg = "Multiple errors without a key."
)
... | 2 | 2 | 0 | [{"id": "G0", "claim": "nit: combine the field declarations in sweetenFields (fields, invalid, seenError) into a single var block.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "nit: combine the common test-case declarations (err, context, extra... | null |
uber-go__zap__1246 | uber-go/zap | 1,246 | defect | 85c4932ce3ea76b6babe3e0a3d79da10ef295b8d | 27add2efafed942e84c8b7e4b6a1b425b678ebfa | [Feature] Add experiment `zapslog` package to integrate with slog | Ref https://github.com/uber-go/zap/discussions/1179
This PR provides a implementation of `slog.Handler` in a separate experiment `exp/zapslog` module as suggested by @abhinav. | diff --git a/exp/zapslog/doc.go b/exp/zapslog/doc.go
new file mode 100644
index 000000000..df550d07d
--- /dev/null
+++ b/exp/zapslog/doc.go
@@ -0,0 +1,29 @@
+// Copyright (c) 2023 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associ... | 7 | 7 | 1 | [{"id": "G0", "claim": "The //go:build zapslog build tag should be removed from example_test.go and slog.go because it prevents the tests (and the package) from building and running by default.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The example s... | null |
uber-go__zap__1262 | uber-go/zap | 1,262 | defect | 05c4b6cdbcaff09d2cbcd80398e37653c4833fee | cb7832fc5727ff96dddf939e57c0d65910fbe278 | internal: Add and use a generic pool instead of using sync.Pool directly | This replaces discretely-typed `sync.Pool` wrappers with a generic wrapper so that pools have a strongly-typed API rather than doing callsite type assertions. | diff --git a/buffer/pool.go b/buffer/pool.go
index 8fb3e202c..846323360 100644
--- a/buffer/pool.go
+++ b/buffer/pool.go
@@ -20,25 +20,29 @@
package buffer
-import "sync"
+import (
+ "go.uber.org/zap/internal/pool"
+)
// A Pool is a type-safe wrapper around a sync.Pool.
type Pool struct {
- p *sync.Pool
+ p *p... | 8 | 8 | 2 | [{"id": "G0", "claim": "Consider deleting the Constructor newtype; a plain func() T alias is shorter and has no runtime artifact.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "staticcheck likely will not detect SA6002 for the custom generic pool, so int... | null |
uber-go__zap__1273 | uber-go/zap | 1,273 | defect | 845ca51d5b8d9fed9fe14f35ab13b6b160d5762d | e8473121a0e641319abbcc3169f933f53eb26a58 | Add Name() function to Logger struct | Related to https://github.com/uber-go/zap/issues/1200
This PR add `Name()` function to Logger struct which will return the Logger's Name.
By default, Logger's name is empty if not set so for Unnamed Logger it will return empty string.
Please let me know which file test that I should include for testing this func... | diff --git a/logger.go b/logger.go
index cd44030d1..3148391b7 100644
--- a/logger.go
+++ b/logger.go
@@ -281,6 +281,12 @@ func (log *Logger) Core() zapcore.Core {
return log.core
}
+// Name returns the Logger's underlying name.
+// Return empty string for unnamed Logger.
+func (log *Logger) Name() string {
+ retur... | 2 | 2 | 1 | [{"id": "G0", "claim": "The doc comment of the new Name() function should be reworded to \"Name returns the Logger's underlying name, or an empty string if the logger is unnamed.\"", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The new Name() func... | null |
uber-go__zap__1323 | uber-go/zap | 1,323 | defect | 613271a78f64d735b1bb72e31b43fb452e3ebcdc | 2841de4659c463f5d95df3887b900698fddeabd0 | RFC: Use golangci-lint for linting | This is more of a proposal than just a PR.
Zap has been maintaining its own bespoke linter setup for a while
and it's starting to show its age.
For example, the upgrade in #1289 can't go through
without either making a change which we disagree with,
or configuring revive separately to ignore that linter check.
... | diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 60a5d9b34..e8d10ba41 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -19,17 +19,15 @@ jobs:
go: ["1.20.x", "1.21.x"]
include:
- go: 1.21.x
- latest: true
steps:
- name: Checkout... | 4 | 2 | 0 | [{"id": "G0", "claim": "The linter set should be pinned explicitly instead of relying on golangci-lint's defaults, which can change with updates and introduce false positives or drop linters, with staticcheck and unused definitely enabled.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scop... | null |
uber-go__zap__1339 | uber-go/zap | 1,339 | defect | 75a5534fd64736041ce237c9f20ab65d920941d9 | 220fbb108ecf412653f8fcec0d1a33be8a59b19f | feat(zapslog): implement stack trace handling | fix: https://github.com/uber-go/zap/issues/1329
As discussed in the issue, replacing the `HandlersOptions` with functional options, i also renamed `addSource` to `addCaller` to properly match the `zap` semantic. | diff --git a/exp/zapslog/options.go b/exp/zapslog/options.go
new file mode 100644
index 000000000..604fc4ef5
--- /dev/null
+++ b/exp/zapslog/options.go
@@ -0,0 +1,74 @@
+// Copyright (c) 2016 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this softwar... | 7 | 6 | 3 | [{"id": "G0", "claim": "Exporting TakeStacktrace from the main Zap package is undesirable even as a temporary unsupported export -- at most it should be deprecated and marked temporary -- and the stacktrace logic should instead live in an internal package that exp/zapslog uses.", "category": "design", "verdict": "suppo... | null |
uber-go__zap__1349 | uber-go/zap | 1,349 | defect | 2b359631a1fabe7800806ae2b830a32f8bace57e | 43b64d5828864429212f852247a75da7ebe8d6a4 | Replace benbjohnson/clock with custom MockClock | This drops the dependency on benbjohnson/clock as it's no longer maintained.
It replaces it with a hand-rolled mock clock implementation.
The core of the functionality of MockClock is provided by the following:
- waiter: a function waiting to be executed
- runAt: schedules a function to be executed when time pr... | diff --git a/benchmarks/go.mod b/benchmarks/go.mod
index 8024e66b2..acd36a71d 100644
--- a/benchmarks/go.mod
+++ b/benchmarks/go.mod
@@ -16,7 +16,6 @@ require (
)
require (
- github.com/benbjohnson/clock v1.3.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-stack/stack v1.8.1 // indire... | 6 | 5 | 0 | [{"id": "G0", "claim": "The NewTicker documentation should mention that Stop won't work on the returned ticker.", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The Add loop should not duplicate the call to PopLTE; it should restructure as an infini... | null |
uber-go__zap__1369 | uber-go/zap | 1,369 | defect | 54430cb4e09b9ff3870230c9ca001f3dcb5ef7c2 | e15b7f3221f0554896a6ba861954ce61ad79d561 | zapcore: Ignore nil Entry.Time in encoders | Per the comment on `Encoder.EncodeEntry`, any fields that are empty including fields on the `Entry` type should be omitted. Omit the `Time` field when we have empty time.
This also aligns with slog.Handler contract.
Refs #1334
Discovered by #1335 | diff --git a/exp/zapslog/handler_test.go b/exp/zapslog/handler_test.go
index 68339df62..6fcd73cfe 100644
--- a/exp/zapslog/handler_test.go
+++ b/exp/zapslog/handler_test.go
@@ -23,13 +23,17 @@
package zapslog
import (
+ "bytes"
+ "encoding/json"
"log/slog"
"testing"
+ "testing/slogtest"
"time"
"github.com... | 2 | 2 | 2 | [{"id": "G0", "claim": "Delete the skipped TestSlogtest (t.Skip until #1334 is fixed) from this PR and track the pending work in a GitHub issue instead of landing it disabled on master.", "category": "testing", "verdict": "supported", "priority": "P1", "scope": "introduced"}, {"id": "G1", "claim": "Add a test similar t... | null |
uber-go__zap__1378 | uber-go/zap | 1,378 | defect | 87577d85d58b6d92d0158967df29303d04d30e36 | f2c45ca52cc3c1ae346713b22179a2d47005d9ad | Extend WithLazy() method to SugaredLogger | Hey there! Resolves #1377
Notes:
- I reused all tests from the `With()` method to work with both `With()` and `WithLazy()`
- To highlight the differences between `With()` and `WithLazy()`, I added a test similar to [this one](https://github.com/uber-go/zap/pull/1319/files#diff-55a2db70576eb079880167200221ea3787a01... | diff --git a/sugar.go b/sugar.go
index 00ac5fe3a..dce9341db 100644
--- a/sugar.go
+++ b/sugar.go
@@ -115,6 +115,21 @@ func (s *SugaredLogger) With(args ...interface{}) *SugaredLogger {
return &SugaredLogger{base: s.base.With(s.sweetenFields(args)...)}
}
+// WithLazy adds a variadic number of fields to the logging ... | 2 | 1 | 0 | [{"id": "G0", "claim": "The second test case's name should be \"lazy with captures arguments at time of Logging\", suspecting a typo copied from the original zap.Logger PR.", "category": "correctness", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": "The capture tests should also... | null |
uber-go__zap__1408 | uber-go/zap | 1,408 | defect | 27b96e378909082d0bf2f0c5802a9f648150fe98 | 104e04f3c1340f50f6b93dbee5b1680d12278742 | zapslog: fix all with slogtest, support inline group, ignore empty group. | This change adds a test based on testing/slogtest
that verifies compliance with the slog handler contract
(a draft of this was available in #1335),
and fixes all resulting issues.
The two remaining issues were:
- `Group("", attrs)` should inline the new fields
instead of creating a group with an empty name.... | diff --git a/exp/zapslog/handler.go b/exp/zapslog/handler.go
index 982d9bccd..84f43539e 100644
--- a/exp/zapslog/handler.go
+++ b/exp/zapslog/handler.go
@@ -39,6 +39,7 @@ type Handler struct {
addCaller bool
addStackAt slog.Level
callerSkip int
+ holdGroup string // holds latest group.
}
// NewHandler build... | 2 | 2 | 2 | [{"id": "G0", "claim": "The handler must not mutate its own holdGroup state inside Handle and WithAttrs, because two concurrent Handle calls would include the group namespace in only one of them; instead a flag local to the call should be used, and the group should be unset only in the child handler returned by WithAtt... | null |
uber-go__zap__1444 | uber-go/zap | 1,444 | defect | 8a805fa71066f3dc8d1fcb8e9fb36d580c4de3f6 | 4ec8a0011788ffc649908e4ad77a284415f44a71 | remove redundant capitalizations in unmarshalText | unmarshalText currently checks for almost all of the levels as
the configured string values as well as their capitalized versions.
But we call unmarshalText with bytes.ToLower() when we actually parse
the levels, so we do not need to check for the capitalized versions
separately since this is redundant.
Previo... | diff --git a/zapcore/level.go b/zapcore/level.go
index 751cf0b98..40126a340 100644
--- a/zapcore/level.go
+++ b/zapcore/level.go
@@ -183,7 +183,7 @@ func (l *Level) unmarshalText(text []byte) bool {
*l = DebugLevel
case "info", "INFO", "": // make the zero value useful
*l = InfoLevel
- case "warn", "warning", "... | 1 | 1 | 0 | [{"id": "G0", "claim": "The capitalized level literals in unmarshalText are redundant because callers already lowercase the text, so they (and M002's newly added \"WARNING\" case) should be removed.", "category": "maintainability", "verdict": "supported", "priority": "P2", "scope": "introduced"}] | null |
uber-go__zap__1452 | uber-go/zap | 1,452 | defect | 8dcd0205a07f7ce959149aaf9152569d040a2f59 | fd64def07454d1ab8648972f69951c1db2effaa0 | zaptest: add ability to filter observer logs by logger name | This is useful for assertions on logs in a particular named path, currently this is only possible through calls to Filter but it is more verbose.
Added a FilterLoggerName function that plays nicely with the other filters:
zapLogs.FilterLoggerName("my.logger").FilterMessage("hello") | diff --git a/zaptest/observer/observer.go b/zaptest/observer/observer.go
index f77f1308b..8f29ee39e 100644
--- a/zaptest/observer/observer.go
+++ b/zaptest/observer/observer.go
@@ -91,6 +91,13 @@ func (o *ObservedLogs) FilterMessage(msg string) *ObservedLogs {
})
}
+// FilterLoggerName filters entries to those tha... | 1 | 1 | 0 | [{"id": "G0", "claim": "The FilterLoggerName doc comment should read \"filters entries to those logged through logger with the specified logger name\" instead of \"filters entries to those that have the specified logger name\".", "category": "documentation", "verdict": "supported", "priority": "P2", "scope": "introduce... | null |
uber-go__zap__1519 | uber-go/zap | 1,519 | defect | 7c80d7b53df6ed592d333998cbbfcd99ff52f3c2 | 6270ad6e2a5338e545aba3c4276aa3c4dcff109e | Update lazy logger not to materialize unless it's being written to | Lazy logger is frequently used to delay (expensive) logger initialization unless we actually write to it.
This works for a pattern like:
```golang
logger := logger.With(.../*fields)
err := foo()
if err != nil {
logger.Info("foo: %w, err)
}
```
Another common pattern, though, is
```golang
logger := l... | diff --git a/zapcore/lazy_with.go b/zapcore/lazy_with.go
index c0d63a0f5..aa672066d 100644
--- a/zapcore/lazy_with.go
+++ b/zapcore/lazy_with.go
@@ -23,7 +23,8 @@ package zapcore
import "sync"
type lazyWithCore struct {
- core Core
+ core Core
+ originalCore Core
sync.Once
fields []Field
}
@@ -32,8 +... | 3 | 2 | 0 | [{"id": "G0", "claim": "NewLazyWith should only set `originalCore` (leaving `core` unset with a comment that it is allocated in `initOnce`), and `initOnce` should do `d.core = d.originalCore.With(d.fields)`.", "category": "design", "verdict": "supported", "priority": "P2", "scope": "introduced"}, {"id": "G1", "claim": ... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.