arangolint

module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: MIT

README

arangolint

Go Reference Go Report Card Go Coverage

Opinionated linter for ArangoDB go driver v2.

Features

Enforce explicit AllowImplicit in transactions

Why? Because it forces you as a developer to evaluate the need of implicit collections in transactions.

Why should you? Because lazily adding collections to transactions can lead to deadlocks, and because the default is to allow it.

ctx := context.Background()
arangoClient := arangodb.NewClient(nil)
db, _ := arangoClient.GetDatabase(ctx, "name", nil)

// Bad
trx, _ := db.BeginTransaction(ctx, arangodb.TransactionCollections{}, nil) // want "missing AllowImplicit option"
trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{LockTimeout: 0}) // want "missing AllowImplicit option"

// Good
trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true})
trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: false})
trx, _ = db.BeginTransaction(ctx, arangodb.TransactionCollections{}, &arangodb.BeginTransactionOptions{AllowImplicit: true, LockTimeout: 0})

Limitations: this currently only works when transaction options are directly passed to BeginTransaction, not when using a variable.

Directories

Path Synopsis
cmd
arangolint command
Package main runs the analyzer.
Package main runs the analyzer.
pkg
analyzer
Package analyzer contains tools for analyzing arangodb usage.
Package analyzer contains tools for analyzing arangodb usage.
plugin
Package plugin is intended to be imported by a custom golangci-lint config as described here: https://golangci-lint.run/plugins/module-plugins/
Package plugin is intended to be imported by a custom golangci-lint config as described here: https://golangci-lint.run/plugins/module-plugins/

Jump to

Keyboard shortcuts

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