Analyzers
SQL
The SQL Analyzer helps you write good SQL and catch errors and bad SQL before it hits your database.
This section covers configuration specific to the SQL
analyzer. Please make sure to read the general configuration guide first.
Configuration - .deepsource.toml
name
- Type: String
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
enabled
- Type: Boolean
- Presence: optional
- Description: Toggle whether this analyzer should be run.
- Example:
meta
- Type: Table
- Presence: optional
- Description: Analyzer specific metadata to tweak its behavior. These values are used to customize the checkers.
- Example:
Available meta
fields
max_line_length
- Type: Integer
- Presence: optional
- Description: The maximum length of a line to allow without raising a violation
- Available Value: Any positive integer value.
- Default Value: 80
- Example:
tab_space_size
- Type: Integer
- Presence: optional
- Description: The number of spaces to consider equal to one tab.
- Available Value: Any positive integer value.
- Default Value: 4
- Example:
indent_unit
- Type: String
- Presence: optional
- Description: Whether to use tabs or spaces to add new indents.
- Available Values:
tab
andspace
- Default Value: “space”
- Example:
comma_style
- Type: String
- Presence: optional
- Description: The comma style to enforce.
- Available Values:
trailing
andleading
- Default Value: “trailing”
- Example:
capitalisation_policy
- Type: String
- Presence: optional
- Description: The capitalization policy to enforce.
- Available Value:
consistent
,upper
,lower
andcapitalise
. - Default Value: “consistent”
- Example:
allow_scalar
- Type: Boolean
- Presence: optional
- Description: If
true
then there would be no issues if there is only one element in theSELECT
clause e.g.SELECT 1 + 2 FROM blah
. It will still fail if there are multiple columns. - Available Values:
true
andfalse
- Default Value: true
- Example:
single_table_references
- Type: String
- Presence: optional
- Description: The expectation for references in single-table
SELECT
. - Available Values:
qualified
,unqualified
andconsistent
- Default Value: “consistent”
- Example:
The meta options are optional and should be provided only if you want the value to be something other than the default value. If no value is passed for a meta field, the analyzer will automatically consider the default value.