Check Code
Published 15 January 2025
Description
The check -code
command runs static code analysis over your SQL migrations from filesystem:
Locations.
See Code Analysis for more information.
Usage examples
flyway check -code
Parameters
Optional
Parameter | Namespace | Description |
---|---|---|
rulesLocation |
check | Where Flyway looks for rules. |
rulesConfig |
check | Where to locate the SQLFluff configuration file. |
rulesDialect |
check | Specifies the SQL dialect for analysis. |
scope |
check | Specifies the scope of migration files to include in code analysis |
majorRules |
check | List of rules considered to be major. |
majorTolerance |
check | The number of major rules violations to be tolerated before throwing an error. |
minorRules |
check | List of rules considered to be minor. |
minorTolerance |
check | The number of minor rules violations to be tolerated before throwing an error. |
regexEnabled |
check | Enable or disable the Regex Engine for code analysis. |
sqlfluffEnabled |
check | Enable or disable the SQLFluff Engine for code analysis. |
code.failOnError |
check | Whether to fail based on the violation severity level. |
reportFilename |
(root) | The output path of the generated report. |
workingDirectory |
(root) | The directory to consider the current working directory. All relative paths will be considered relative to this. |
{environment parameters} | (root) | Environment configuration for the source and/or target environments. |
Universal commandline parameters are listed here.
Note:
- The following parameters are now deprecated -
majorRules/majorTolerance/minorRules/minorTolerance
. Consider usingfailOnError
instead. - Static code analysis will not interrupt the execution of subsequent Flyway verb operations if they are chained. This means that even if
failOnError
is enabled, Flyway will continue processing the remaining verb operations. For this reason, it is recommended to run subsequent Flyway verbs separately.
JSON output format
{
"htmlReport": "report.html",
"jsonReport": "report.json",
"individualResults": [
{
message: null,
stackTrace: null,
results: [
{
filepath: "C:\\flywayProject\migrations\V001__AddTable.sql",
violations: [
"line_no:": 5,
"line_pos": 10,
"description": "violation description",
"code": "violation code"
]
},
],
timestamp: "2022-07-22T08-08-33Z",
database: "testdb",
operation: "code",
flywayVersion: undefined,
warnings: undefined,
}
]
}
Error codes
This command can produce the following error codes: