The linter for Cadence. Find programming errors, bugs, stylistic errors and suspicious constructs.
go build ./cmd/lint
To analyze all contracts of an account, specify the network and address.
This requires you have the Flow CLI installed and configured (run flow init
).
For example:
./lint -network mainnet -address 0x1654653399040a61
To analyze a transaction, specify the network and transaction ID.
This requires you have the Flow CLI installed and configured (run flow init
).
For example:
./lint -network mainnet -transaction 44fd8475eeded90d74e7594b10cf456b0866c78221e7f230fcfd4ba1155c542f
By default, all available analyzers are run.
To list all available analyzers, run:
./lint -help
For example, to only run the reference-to-optional
and the external-mutation
analyzers, run:
./lint -network mainnet -address 0x1654653399040a61 \
-analyze reference-to-optional \
-analyze external-mutation
To analyze all contracts in a directory, specify the path.
For example:
./lint -directory contracts
The files must be named with the .cdc
extension and by their location ID of the program:
- Contracts in accounts have the format
A.<address>.<name>
, e.g.A.e467b9dd11fa00df.FlowStorageFees
, whereaddress
: Address in hex format, e.g.e467b9dd11fa00df
name
: The name of the contract, e.gFlowStorageFees
- Transactions have the format
t.<ID>
, whereid
: The ID of the transaction (its hash)
- Scripts have the format
s.<ID>
, whereid
: The ID of the script (its hash)
To analyze all contracts in a CSV file, specify the path to the file.
For example:
./lint -csv contracts.csv
The CSV file must be in the following format:
- Header:
location,code
- Columns:
location
: The location ID of the program- Contracts in accounts have the format
A.<address>.<name>
, e.g.A.e467b9dd11fa00df.FlowStorageFees
, whereaddress
: Address in hex format, e.g.e467b9dd11fa00df
name
: The name of the contract, e.gFlowStorageFees
- Transactions have the format
t.<ID>
, whereid
: The ID of the transaction (its hash)
- Scripts have the format
s.<ID>
, whereid
: The ID of the script (its hash)
- Contracts in accounts have the format
code
: The code of the contract, e.g.pub contract Test {}
Full example:
location,code
t.0000000000000000,"
import 0x1
transaction {
prepare(signer: AuthAccount) {
Test.hello()
}
}
"
A.0000000000000001.Test,"
pub contract Test {
pub fun hello() {
log(""Hello, world!"")
}
}
"