Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linter for issue comments #3154

Merged
merged 18 commits into from
Aug 24, 2023
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The result will be saved as `bin/ferretdb`.
With `task` installed (see above), you may do the following:

1. Start the development environment with `task env-up`.
2. Run all tests in another terminal window with `task test`.
2. Run all tests in another terminal window with `task test` (see [below](#running-tests)).
3. Start FerretDB with `task run`.
This will start it in a development mode where all requests are handled by FerretDB, but also routed to MongoDB.
The differences in response are then logged and the FerretDB response is sent back to the client.
Expand Down
5 changes: 3 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ tasks:
- bin/go-consistent{{exeExt}} -pedantic ./cmd/... ./internal/... ./build/... ./ferretdb/...
- bin/go-sumtype{{exeExt}} ./...
- go vet -vettool=./bin/checkswitch{{exeExt}} ./...
- bin/task{{exeExt}} -d integration integration-lint
- bin/task{{exeExt}} -d tools tools-lint
- go vet -vettool=./bin/checkcomments{{exeExt}} ./...
- bin/task{{exeExt}} -d integration lint
- bin/task{{exeExt}} -d tools lint

security:
desc: "Run security scanners"
Expand Down
4 changes: 2 additions & 2 deletions cmd/envtool/tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func TestTestsShard(t *testing.T) {
require.NoError(t, err)
assert.Contains(t, tests, "TestQueryCompatLimit")

// TODO replace with a real test name is a subdirectory
// TODO enable once subdirectories are used
// https://github.com/FerretDB/engineering/issues/66
assert.Contains(t, tests, "TestSubDir")
// assert.Contains(t, tests, "TestSubDir")

t.Run("ShardTestsInvalidIndex", func(t *testing.T) {
t.Parallel()
Expand Down
4 changes: 3 additions & 1 deletion integration/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ tasks:
cmds:
- go generate -x ./...

integration-lint:
lint:
desc: "Run linters"
cmds:
- ../bin/golangci-lint{{exeExt}} run --config=.golangci.yml
- ../bin/golangci-lint{{exeExt}} run --config=.golangci-new.yml
- ../bin/go-consistent{{exeExt}} -pedantic ./...
- ../bin/go-sumtype{{exeExt}} ./...
- go vet -vettool=../bin/checkswitch{{exeExt}} ./...
- go vet -vettool=../bin/checkcomments{{exeExt}} ./...

integration-security:
cmds:
Expand Down
7 changes: 4 additions & 3 deletions integration/aggregate_documents_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ func TestAggregateCompatGroup(t *testing.T) {
func TestAggregateCompatGroupExpressionDottedFields(t *testing.T) {
t.Parallel()

// TODO Use all providers after fixing $sort problem: https://github.com/FerretDB/FerretDB/issues/2276.
// Use all providers after fixing $sort problem:
// TODO https://github.com/FerretDB/FerretDB/issues/2276
//
// Currently, providers Composites, DocumentsDeeplyNested, ArrayAndDocuments and Mixed
// cannot be used due to sorting difference.
Expand Down Expand Up @@ -1126,7 +1127,7 @@ func TestAggregateCompatGroupSum(t *testing.T) {
// TODO: handle $sum of doubles near max precision.
// https://github.com/FerretDB/FerretDB/issues/2300
Remove(shareddata.Doubles).
// TODO: https://github.com/FerretDB/FerretDB/issues/2616
// TODO https://github.com/FerretDB/FerretDB/issues/2616
Remove(shareddata.ArrayDocuments)

testCases := map[string]aggregateStagesCompatTestCase{
Expand Down Expand Up @@ -1531,7 +1532,7 @@ func TestAggregateCompatSortDotNotation(t *testing.T) {
t.Parallel()

providers := shareddata.AllProviders().
// TODO: https://github.com/FerretDB/FerretDB/issues/2617
// TODO https://github.com/FerretDB/FerretDB/issues/2617
Remove(shareddata.ArrayDocuments)

testCases := map[string]aggregateStagesCompatTestCase{
Expand Down
3 changes: 2 additions & 1 deletion integration/aggregate_stats_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func TestAggregateCompatCollStats(tt *testing.T) {
nonEmptyResults = true
}

// TODO Check the returned values when possible: https://github.com/FerretDB/FerretDB/issues/2349
// Check the returned values when possible
// TODO https://github.com/FerretDB/FerretDB/issues/2349
})
}

Expand Down
15 changes: 10 additions & 5 deletions integration/commands_administration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,9 @@ func TestCommandsAdministrationCollStats(tt *testing.T) {

// Values are returned as "numbers" that could be int32 or int64.
// FerretDB always returns int64 for simplicity.
// TODO Set better expected results https://github.com/FerretDB/FerretDB/issues/1771
//
// Set better expected results.
// TODO https://github.com/FerretDB/FerretDB/issues/1771
assert.Equal(t, collection.Database().Name()+"."+collection.Name(), must.NotFail(doc.Get("ns")))
assert.EqualValues(t, 6, must.NotFail(doc.Get("count"))) // // Number of documents in DocumentsStrings
assert.Equal(t, int32(1), must.NotFail(doc.Get("scaleFactor")))
Expand Down Expand Up @@ -742,7 +744,8 @@ func TestCommandsAdministrationCollStatsWithScale(tt *testing.T) {
err := collection.Database().RunCommand(ctx, command).Decode(&actual)
require.NoError(t, err)

// TODO Set better expected results https://github.com/FerretDB/FerretDB/issues/1771
// Set better expected results.
// TODO https://github.com/FerretDB/FerretDB/issues/1771
doc := ConvertDocument(t, actual)
assert.Equal(t, collection.Database().Name()+"."+collection.Name(), must.NotFail(doc.Get("ns")))
assert.EqualValues(t, 6, must.NotFail(doc.Get("count"))) // Number of documents in DocumentsStrings
Expand Down Expand Up @@ -862,7 +865,9 @@ func TestCommandsAdministrationDBStats(tt *testing.T) {

// Values are returned as "numbers" that could be int32 or int64.
// FerretDB always returns int64 for simplicity.
// TODO Set better expected results https://github.com/FerretDB/FerretDB/issues/1771
//
// Set better expected results.
// TODO https://github.com/FerretDB/FerretDB/issues/1771
doc := ConvertDocument(t, actual)
assert.Equal(t, collection.Database().Name(), doc.Remove("db"))
assert.EqualValues(t, 1, doc.Remove("collections"))
Expand Down Expand Up @@ -894,7 +899,7 @@ func TestCommandsAdministrationDBStatsEmpty(tt *testing.T) {

assert.Equal(t, float64(1), doc.Remove("ok"))
assert.Equal(t, collection.Database().Name(), doc.Remove("db"))
assert.EqualValues(t, float64(1), doc.Remove("scaleFactor")) // TODO use assert.Equal https://github.com/FerretDB/FerretDB/issues/727
assert.EqualValues(t, float64(1), doc.Remove("scaleFactor")) // https://github.com/FerretDB/FerretDB/issues/727

assert.InDelta(t, 1, doc.Remove("collections"), 1)
assert.InDelta(t, 35500, doc.Remove("dataSize"), 35500)
Expand Down Expand Up @@ -944,7 +949,7 @@ func TestCommandsAdministrationDBStatsEmptyWithScale(tt *testing.T) {

assert.Equal(t, float64(1), doc.Remove("ok"))
assert.Equal(t, collection.Database().Name(), doc.Remove("db"))
assert.EqualValues(t, float64(1000), doc.Remove("scaleFactor")) // TODO use assert.Equal https://github.com/FerretDB/FerretDB/issues/727
assert.EqualValues(t, float64(1000), doc.Remove("scaleFactor")) // TODO https://github.com/FerretDB/FerretDB/issues/727

assert.InDelta(t, 1, doc.Remove("collections"), 1)
assert.InDelta(t, 35500, doc.Remove("dataSize"), 35500)
Expand Down
4 changes: 3 additions & 1 deletion integration/count_command_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func testCountCommandCompat(t *testing.T, testCases map[string]countCommandCompa
t.Helper()

// Use shared setup because count queries can't modify data.
// TODO Use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
//
// Use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
ctx, targetCollections, compatCollections := setup.SetupCompat(t)

for name, tc := range testCases {
Expand Down
4 changes: 3 additions & 1 deletion integration/count_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func testCountCompat(t *testing.T, testCases map[string]countCompatTestCase) {
t.Helper()

// Use shared setup because find queries can't modify data.
// TODO Use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
//
// Use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
s := setup.SetupCompatWithOpts(t, &setup.SetupCompatOpts{
Providers: shareddata.AllProviders(),
AddNonExistentCollection: true,
Expand Down
4 changes: 3 additions & 1 deletion integration/distinct_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ func testDistinctCompat(tt *testing.T, testCases map[string]distinctCompatTestCa
tt.Helper()

// Use shared setup because distinct queries can't modify data.
// TODO Use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
//
// Use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
s := setup.SetupCompatWithOpts(tt, &setup.SetupCompatOpts{
Providers: shareddata.AllProviders().Remove(shareddata.Scalars), // Remove provider with the same values with different types
AddNonExistentCollection: true,
Expand Down
3 changes: 2 additions & 1 deletion integration/findandmodify_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ func TestFindAndModifyCompatUpdateRename(t *testing.T) {

// TestFindAndModifyCompatSort tests how various sort orders are handled.
//
// TODO Add more tests for sort: https://github.com/FerretDB/FerretDB/issues/2168
// Add more tests for sort.
// TODO https://github.com/FerretDB/FerretDB/issues/2168
func TestFindAndModifyCompatSort(t *testing.T) {
t.Parallel()

Expand Down
6 changes: 4 additions & 2 deletions integration/getmore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ func TestGetMoreBatchSizeCursor(t *testing.T) {
}

// next batch obtain from implicit call to `getMore` has the rest of the documents, not default batchSize
// TODO: 16MB batchSize limit https://github.com/FerretDB/FerretDB/issues/2824
// 16MB batchSize limit
// TODO https://github.com/FerretDB/FerretDB/issues/2824
ok := cursor.Next(ctx)
require.True(t, ok, "expected to have next document")
require.Equal(t, 118, cursor.RemainingBatchLength())
Expand All @@ -577,7 +578,8 @@ func TestGetMoreBatchSizeCursor(t *testing.T) {
require.Equal(t, 0, cursor.RemainingBatchLength())

// next batch obtain from implicit call to `getMore` has the rest of the documents, not 0 batchSize
// TODO: 16MB batchSize limit https://github.com/FerretDB/FerretDB/issues/2824
// 16MB batchSize limit
// TODO https://github.com/FerretDB/FerretDB/issues/2824
ok := cursor.Next(ctx)
require.True(t, ok, "expected to have next document")
require.Equal(t, 219, cursor.RemainingBatchLength())
Expand Down
3 changes: 2 additions & 1 deletion integration/query_array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func TestQueryArrayDotNotation(t *testing.T) {
skip string // optional, skip test with a specified reason
}{
"FieldPositionQueryRegex": {
// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/1540
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/1540
filter: bson.D{{"v.array.0", bson.D{{"$lt", primitive.Regex{Pattern: "^$"}}}}},
err: &mongo.CommandError{
Code: 2,
Expand Down
12 changes: 8 additions & 4 deletions integration/query_bitwise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ func TestQueryBitwiseAllClear(t *testing.T) {
t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Scalars)

// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/508
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/508
_, err := collection.DeleteOne(ctx, bson.D{{"_id", "binary"}})
require.NoError(t, err)
_, err = collection.DeleteOne(ctx, bson.D{{"_id", "binary-empty"}})
Expand Down Expand Up @@ -239,7 +240,8 @@ func TestQueryBitwiseAllSet(t *testing.T) {
t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Scalars)

// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/508
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/508
_, err := collection.DeleteOne(ctx, bson.D{{"_id", "binary"}})
require.NoError(t, err)
_, err = collection.DeleteOne(ctx, bson.D{{"_id", "binary-empty"}})
Expand Down Expand Up @@ -377,7 +379,8 @@ func TestQueryBitwiseAnyClear(t *testing.T) {
t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Scalars)

// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/508
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/508
_, err := collection.DeleteOne(ctx, bson.D{{"_id", "binary"}})
require.NoError(t, err)
_, err = collection.DeleteOne(ctx, bson.D{{"_id", "binary-empty"}})
Expand Down Expand Up @@ -555,7 +558,8 @@ func TestQueryBitwiseAnySet(t *testing.T) {
t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Scalars)

// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/508
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/508
_, err := collection.DeleteOne(ctx, bson.D{{"_id", "binary"}})
require.NoError(t, err)
_, err = collection.DeleteOne(ctx, bson.D{{"_id", "binary-empty"}})
Expand Down
4 changes: 3 additions & 1 deletion integration/query_command_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func testQueryCommandCompat(t *testing.T, testCases map[string]queryCommandCompa
t.Helper()

// Use shared setup because find queries can't modify data.
// TODO Use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
//
// Use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
ctx, targetCollections, compatCollections := setup.SetupCompat(t)

for name, tc := range testCases {
Expand Down
6 changes: 4 additions & 2 deletions integration/query_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func testQueryCompatWithProviders(t *testing.T, providers shareddata.Providers,
require.NotEmpty(t, providers)

// Use shared setup because find queries can't modify data.
// TODO Use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
//
// Use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
s := setup.SetupCompatWithOpts(t, &setup.SetupCompatOpts{
Providers: providers,
})
Expand Down Expand Up @@ -301,7 +303,7 @@ func TestQueryCompatSortDotNotation(t *testing.T) {
t.Parallel()

providers := shareddata.AllProviders().
// TODO: https://github.com/FerretDB/FerretDB/issues/2618
// TODO https://github.com/FerretDB/FerretDB/issues/2618
Remove(shareddata.ArrayDocuments)

testCases := map[string]queryCompatTestCase{
Expand Down
3 changes: 2 additions & 1 deletion integration/query_evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
)

func TestQueryEvaluationRegex(t *testing.T) {
// TODO: move to compat https://github.com/FerretDB/FerretDB/issues/1576
// Move to compat.
// TODO https://github.com/FerretDB/FerretDB/issues/1576

t.Parallel()
ctx, collection := setup.Setup(t, shareddata.Scalars)
Expand Down
3 changes: 2 additions & 1 deletion integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ var (

// SetupOpts represents setup options.
//
// TODO Add option to use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
// Add option to use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
type SetupOpts struct {
// Database to use. If empty, temporary test-specific database is created and dropped after test.
DatabaseName string
Expand Down
7 changes: 5 additions & 2 deletions integration/setup/setup_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ import (

// SetupCompatOpts represents setup options for compatibility test.
//
// TODO Add option to use read-only user. https://github.com/FerretDB/FerretDB/issues/1025
// Add option to use read-only user.
// TODO https://github.com/FerretDB/FerretDB/issues/1025
type SetupCompatOpts struct {
// Data providers.
Providers []shareddata.Provider

// If true, a non-existent collection will be added to the list of collections.
// This is useful to test the behavior when a collection is not found.
// TODO This flag is not needed, always add a non-existent collection https://github.com/FerretDB/FerretDB/issues/1545
//
// This flag is not needed, always add a non-existent collection.
// TODO https://github.com/FerretDB/FerretDB/issues/1545
AddNonExistentCollection bool

databaseName string
Expand Down
2 changes: 1 addition & 1 deletion integration/shareddata/faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newFaker() *faker {

// FieldName generates a random document field name.
func (f *faker) FieldName() string {
// TODO https://github.com/jaswdr/faker/issues/142
// See https://github.com/jaswdr/faker/issues/142.

// somewhat surprisingly, generating "better" field names generates duplicates too often
return fmt.Sprintf("field_%d", f.r.Int())
Expand Down
3 changes: 2 additions & 1 deletion internal/bson/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func (dt *dateTimeType) ReadFrom(r *bufio.Reader) error {
return lazyerrors.Errorf("bson.DateTime.ReadFrom (binary.Read): %w", err)
}

// TODO Use .UTC(): https://github.com/FerretDB/FerretDB/issues/43
// Use .UTC()
// TODO https://github.com/FerretDB/FerretDB/issues/43
*dt = dateTimeType(time.UnixMilli(ts))
return nil
}
Expand Down
2 changes: 0 additions & 2 deletions internal/clientconn/cursor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func init() {

// Registry stores cursors.
//
// TODO better cleanup (?), more metrics https://github.com/FerretDB/FerretDB/issues/2862
//
//nolint:vet // for readability
type Registry struct {
rw sync.RWMutex
Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/common/aggregations/stages/collstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ func newCollStats(stage *types.Document) (aggregations.Stage, error) {

var cs collStats

// TODO Return error on invalid type of count: https://github.com/FerretDB/FerretDB/issues/2336
// Return error on invalid type of count.
// TODO https://github.com/FerretDB/FerretDB/issues/2336
cs.count = fields.Has("count")

// TODO Implement latencyStats: https://github.com/FerretDB/FerretDB/issues/2341
// TODO https://github.com/FerretDB/FerretDB/issues/2341
cs.latencyStats = fields.Has("latencyStats")

// TODO Implement queryExecStats: https://github.com/FerretDB/FerretDB/issues/2341
// TODO https://github.com/FerretDB/FerretDB/issues/2341
cs.queryExecStats = fields.Has("queryExecStats")

if fields.Has("storageStats") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func ProjectDocument(doc, projection *types.Document, inclusion bool) (*types.Do

projectedWithoutID, err := projectDocumentWithoutID(doc, projection, inclusion)
if err != nil {
// TODO: https://github.com/FerretDB/FerretDB/issues/2633
// TODO https://github.com/FerretDB/FerretDB/issues/2633
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/common/aggregations/stages/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func newSort(stage *types.Document) (aggregations.Stage, error) {
)
}

// TODO: https://github.com/FerretDB/FerretDB/issues/2090
// TODO https://github.com/FerretDB/FerretDB/issues/2090

return &sort{
fields: fields,
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/common/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type DeleteParams struct {
type Delete struct {
Filter *types.Document `ferretdb:"q"`
Limited bool `ferretdb:"limit,zeroOrOneAsBool"`
// TODO: https://github.com/FerretDB/FerretDB/issues/2627
// TODO https://github.com/FerretDB/FerretDB/issues/2627
Comment string `ferretdb:"comment,opt"`

Collation *types.Document `ferretdb:"collation,unimplemented"`
Expand Down
Loading