Allow SQLFluff configuration file to be used from standard Super Linter location (#2361)

This commit is contained in:
Barry Pollard 2022-01-20 15:02:30 +00:00 committed by GitHub
parent 591688d57d
commit 3d54fce1f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 301 additions and 1 deletions

148
.github/linters/.sqlfluffini vendored Normal file
View file

@ -0,0 +1,148 @@
## This .sqlfluffini file can be used to configure the SQLFluff linter when
## used via the GitHub Super Linter. Copy it to the .github/linters folder of
## your repo, and uncomment the necessary lines to configure the Super Linter.
##
## IMPORTANT NOTE: The GitHub Super Linter configuration file for SQLFluff
## supersedes any local configuration files you might have in within your
## codebase. For this reason it should only be used when you want the same
## configuration for your entire code base. If you need different configuration
## in different folders you must leave this config commented out, and instead
## manage all your config files within your code base rather than in the
## .github/linters folder
##
[sqlfluff]
## verbose is an integer (0-2) indicating the level of log output
#verbose = 0
## Turn off color formatting of output
#nocolor = False
## Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
## Or run 'sqlfluff dialects'
#dialect = ansi
## One of [raw|jinja|python|placeholder]
#templater = jinja
## Comma separated list of rules to check, or None for all
#rules = None
## Comma separated list of rules to exclude, or None
#exclude_rules = None
## The depth to recursively parse to (0 for unlimited)
#recurse = 0
## Below controls SQLFluff output, see max_line_length for SQL output
#output_line_length = 80
## Number of passes to run before admitting defeat
#runaway_limit = 10
## Ignore linting errors in templated sections
#ignore_templated_areas = True
## can either be autodetect or a valid encoding e.g. utf-8, utf-8-sig
#encoding = autodetect
## Ignore inline overrides (e.g. to test if still required)
#disable_noqa = False
## Comma separated list of file extensions to lint
## NB: This config will only apply in the root folder
#sql_file_exts = .sql,.sql.j2,.dml,.ddl
#
[sqlfluff:indentation]
## See https://docs.sqlfluff.com/en/stable/indentation.html
#indented_joins = False
#indented_using_on = True
#template_blocks_indent = True
#
[sqlfluff:templater]
#unwrap_wrapped_queries = True
#
[sqlfluff:templater:jinja]
#apply_dbt_builtins = True
#
[sqlfluff:templater:jinja:macros]
## Macros provided as builtins for dbt projects
#dbt_ref = {% macro ref(model_ref) %}{{model_ref}}{% endmacro %}
#dbt_source = {% macro source(source_name, table) %}{{source_name}}_{{table}}{% endmacro %}
#dbt_config = {% macro config() %}{% for k in kwargs %}{% endfor %}{% endmacro %}
#dbt_var = {% macro var(variable, default='') %}item{% endmacro %}
#dbt_is_incremental = {% macro is_incremental() %}True{% endmacro %}
#
## Some rules can be configured directly from the config common to other rules
[sqlfluff:rules]
#tab_space_size = 4
#max_line_length = 80
#indent_unit = space
#comma_style = trailing
#allow_scalar = True
#single_table_references = consistent
#unquoted_identifiers_policy = all
#
## Some rules have their own specific config
[sqlfluff:rules:L007]
#operator_new_lines = after
#
[sqlfluff:rules:L010]
## Keywords
#capitalisation_policy = consistent
#
[sqlfluff:rules:L011]
## Aliasing preference for tables
#aliasing = explicit
#
[sqlfluff:rules:L012]
## Aliasing preference for columns
#aliasing = explicit
#
[sqlfluff:rules:L014]
## Unquoted identifiers
#extended_capitalisation_policy = consistent
#
[sqlfluff:rules:L016]
## Line length
#ignore_comment_lines = False
#
[sqlfluff:rules:L026]
## References must be in FROM clause
## Disabled for some dialects (e.g. bigquery)
#force_enable = False
#
[sqlfluff:rules:L028]
## References must be consistently used
## Disabled for some dialects (e.g. bigquery)
#force_enable = False
#
[sqlfluff:rules:L029]
## Keywords should not be used as identifiers.
#unquoted_identifiers_policy = aliases
#quoted_identifiers_policy = none
#
[sqlfluff:rules:L030]
## Function names
#capitalisation_policy = consistent
#
[sqlfluff:rules:L038]
## Trailing commas
#select_clause_trailing_comma = forbid
#
[sqlfluff:rules:L040]
## Null & Boolean Literals
#capitalisation_policy = consistent
#
[sqlfluff:rules:L042]
## By default, allow subqueries in from clauses, but not join clauses
#forbid_subquery_in = join
#
[sqlfluff:rules:L047]
## Consistent syntax to count all rows
#prefer_count_1 = False
#prefer_count_0 = False
#
[sqlfluff:rules:L052]
## Semi-colon formatting approach
#multiline_newline = False
#require_final_semicolon = False
#
[sqlfluff:rules:L054]
## GROUP BY/ORDER BY column references
#group_by_and_order_by_style = consistent
#
[sqlfluff:rules:L057]
## Special characters in identifiers
#unquoted_identifiers_policy = all
#quoted_identifiers_policy = all
#allow_space_in_identifier = False
#additional_allowed_characters = ""

View file

@ -318,6 +318,7 @@ But if you wish to select or exclude specific linters, we give you full control
| **SNAKEMAKE_SNAKEFMT_CONFIG_FILE** | `.snakefmt.toml` | Filename for [Snakemake configuration](https://github.com/snakemake/snakefmt#configuration) (ex: `pyproject.toml`, `.snakefmt.toml`) | | **SNAKEMAKE_SNAKEFMT_CONFIG_FILE** | `.snakefmt.toml` | Filename for [Snakemake configuration](https://github.com/snakemake/snakefmt#configuration) (ex: `pyproject.toml`, `.snakefmt.toml`) |
| **SSL_CERT_SECRET** | `none` | SSL cert to add to the **Super-Linter** trust store. This is needed for users on `self-hosted` runners or need to inject the cert for security standards (ex. ${{ secrets.SSL_CERT }}) | | **SSL_CERT_SECRET** | `none` | SSL cert to add to the **Super-Linter** trust store. This is needed for users on `self-hosted` runners or need to inject the cert for security standards (ex. ${{ secrets.SSL_CERT }}) |
| **SQL_CONFIG_FILE** | `.sql-config.json` | Filename for [SQL-Lint configuration](https://sql-lint.readthedocs.io/en/latest/files/configuration.html) (ex: `sql-config.json` , `.config.json`) | | **SQL_CONFIG_FILE** | `.sql-config.json` | Filename for [SQL-Lint configuration](https://sql-lint.readthedocs.io/en/latest/files/configuration.html) (ex: `sql-config.json` , `.config.json`) |
| **SQLFLUFF_CONFIG_FILE** | `.sqlfluffini` | Filename for [SQLFLUFF configuration](https://docs.sqlfluff.com/en/stable/configuration.html) (ex: `.sqlfluffini`, `pyproject.toml`) |
| **TERRAFORM_TFLINT_CONFIG_FILE** | `.tflint.hcl` | Filename for [tfLint configuration](https://github.com/terraform-linters/tflint) (ex: `.tflint.hcl`) | | **TERRAFORM_TFLINT_CONFIG_FILE** | `.tflint.hcl` | Filename for [tfLint configuration](https://github.com/terraform-linters/tflint) (ex: `.tflint.hcl`) |
| **TERRAFORM_TERRASCAN_CONFIG_FILE**| `terrascan.toml` | Filename for [terrascan configuration](https://github.com/accurics/terrascan) (ex: `terrascan.toml`) | | **TERRAFORM_TERRASCAN_CONFIG_FILE**| `terrascan.toml` | Filename for [terrascan configuration](https://github.com/accurics/terrascan) (ex: `terrascan.toml`) |
| **TYPESCRIPT_DEFAULT_STYLE** | `standard` | Flag to set the default style of TypeScript. Available options: **standard**/**prettier** | | **TYPESCRIPT_DEFAULT_STYLE** | `standard` | Flag to set the default style of TypeScript. Available options: **standard**/**prettier** |

148
TEMPLATES/.sqlfluffini Normal file
View file

@ -0,0 +1,148 @@
## This .sqlfluffini file can be used to configure the SQLFluff linter when
## used via the GitHub Super Linter. Copy it to the .github/linters folder of
## your repo, and uncomment the necessary lines to configure the Super Linter.
##
## IMPORTANT NOTE: The GitHub Super Linter configuration file for SQLFluff
## supersedes any local configuration files you might have in within your
## codebase. For this reason it should only be used when you want the same
## configuration for your entire code base. If you need different configuration
## in different folders you must leave this config commented out, and instead
## manage all your config files within your code base rather than in the
## .github/linters folder
##
[sqlfluff]
## verbose is an integer (0-2) indicating the level of log output
#verbose = 0
## Turn off color formatting of output
#nocolor = False
## Supported dialects https://docs.sqlfluff.com/en/stable/dialects.html
## Or run 'sqlfluff dialects'
#dialect = ansi
## One of [raw|jinja|python|placeholder]
#templater = jinja
## Comma separated list of rules to check, or None for all
#rules = None
## Comma separated list of rules to exclude, or None
#exclude_rules = None
## The depth to recursively parse to (0 for unlimited)
#recurse = 0
## Below controls SQLFluff output, see max_line_length for SQL output
#output_line_length = 80
## Number of passes to run before admitting defeat
#runaway_limit = 10
## Ignore linting errors in templated sections
#ignore_templated_areas = True
## can either be autodetect or a valid encoding e.g. utf-8, utf-8-sig
#encoding = autodetect
## Ignore inline overrides (e.g. to test if still required)
#disable_noqa = False
## Comma separated list of file extensions to lint
## NB: This config will only apply in the root folder
#sql_file_exts = .sql,.sql.j2,.dml,.ddl
#
[sqlfluff:indentation]
## See https://docs.sqlfluff.com/en/stable/indentation.html
#indented_joins = False
#indented_using_on = True
#template_blocks_indent = True
#
[sqlfluff:templater]
#unwrap_wrapped_queries = True
#
[sqlfluff:templater:jinja]
#apply_dbt_builtins = True
#
[sqlfluff:templater:jinja:macros]
## Macros provided as builtins for dbt projects
#dbt_ref = {% macro ref(model_ref) %}{{model_ref}}{% endmacro %}
#dbt_source = {% macro source(source_name, table) %}{{source_name}}_{{table}}{% endmacro %}
#dbt_config = {% macro config() %}{% for k in kwargs %}{% endfor %}{% endmacro %}
#dbt_var = {% macro var(variable, default='') %}item{% endmacro %}
#dbt_is_incremental = {% macro is_incremental() %}True{% endmacro %}
#
## Some rules can be configured directly from the config common to other rules
[sqlfluff:rules]
#tab_space_size = 4
#max_line_length = 80
#indent_unit = space
#comma_style = trailing
#allow_scalar = True
#single_table_references = consistent
#unquoted_identifiers_policy = all
#
## Some rules have their own specific config
[sqlfluff:rules:L007]
#operator_new_lines = after
#
[sqlfluff:rules:L010]
## Keywords
#capitalisation_policy = consistent
#
[sqlfluff:rules:L011]
## Aliasing preference for tables
#aliasing = explicit
#
[sqlfluff:rules:L012]
## Aliasing preference for columns
#aliasing = explicit
#
[sqlfluff:rules:L014]
## Unquoted identifiers
#extended_capitalisation_policy = consistent
#
[sqlfluff:rules:L016]
## Line length
#ignore_comment_lines = False
#
[sqlfluff:rules:L026]
## References must be in FROM clause
## Disabled for some dialects (e.g. bigquery)
#force_enable = False
#
[sqlfluff:rules:L028]
## References must be consistently used
## Disabled for some dialects (e.g. bigquery)
#force_enable = False
#
[sqlfluff:rules:L029]
## Keywords should not be used as identifiers.
#unquoted_identifiers_policy = aliases
#quoted_identifiers_policy = none
#
[sqlfluff:rules:L030]
## Function names
#capitalisation_policy = consistent
#
[sqlfluff:rules:L038]
## Trailing commas
#select_clause_trailing_comma = forbid
#
[sqlfluff:rules:L040]
## Null & Boolean Literals
#capitalisation_policy = consistent
#
[sqlfluff:rules:L042]
## By default, allow subqueries in from clauses, but not join clauses
#forbid_subquery_in = join
#
[sqlfluff:rules:L047]
## Consistent syntax to count all rows
#prefer_count_1 = False
#prefer_count_0 = False
#
[sqlfluff:rules:L052]
## Semi-colon formatting approach
#multiline_newline = False
#require_final_semicolon = False
#
[sqlfluff:rules:L054]
## GROUP BY/ORDER BY column references
#group_by_and_order_by_style = consistent
#
[sqlfluff:rules:L057]
## Special characters in identifiers
#unquoted_identifiers_policy = all
#quoted_identifiers_policy = all
#allow_space_in_identifier = False
#additional_allowed_characters = ""

View file

@ -172,6 +172,8 @@ SUPPRESS_POSSUM="${SUPPRESS_POSSUM:-false}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
SQL_FILE_NAME="${SQL_CONFIG_FILE:-.sql-config.json}" SQL_FILE_NAME="${SQL_CONFIG_FILE:-.sql-config.json}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
SQLFLUFF_FILE_NAME="${SQLFLUFF_CONFIG_FILE:-.sqlfluffini}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
TERRAFORM_TFLINT_FILE_NAME="${TERRAFORM_TFLINT_CONFIG_FILE:-.tflint.hcl}" TERRAFORM_TFLINT_FILE_NAME="${TERRAFORM_TFLINT_CONFIG_FILE:-.tflint.hcl}"
# shellcheck disable=SC2034 # Variable is referenced indirectly # shellcheck disable=SC2034 # Variable is referenced indirectly
TERRAFORM_TERRASCAN_FILE_NAME="${TERRAFORM_TERRASCAN_CONFIG_FILE:-terrascan.toml}" TERRAFORM_TERRASCAN_FILE_NAME="${TERRAFORM_TERRASCAN_CONFIG_FILE:-terrascan.toml}"
@ -929,7 +931,7 @@ LINTER_COMMANDS_ARRAY['SNAKEMAKE_LINT']="snakemake --lint -s"
LINTER_COMMANDS_ARRAY['SNAKEMAKE_SNAKEFMT']="snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff" LINTER_COMMANDS_ARRAY['SNAKEMAKE_SNAKEFMT']="snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff"
LINTER_COMMANDS_ARRAY['STATES']="asl-validator --json-path" LINTER_COMMANDS_ARRAY['STATES']="asl-validator --json-path"
LINTER_COMMANDS_ARRAY['SQL']="sql-lint --config ${SQL_LINTER_RULES}" LINTER_COMMANDS_ARRAY['SQL']="sql-lint --config ${SQL_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['SQLFLUFF']="sqlfluff lint" LINTER_COMMANDS_ARRAY['SQLFLUFF']="sqlfluff lint --config ${SQLFLUFF_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['TEKTON']="tekton-lint" LINTER_COMMANDS_ARRAY['TEKTON']="tekton-lint"
LINTER_COMMANDS_ARRAY['TERRAFORM_TFLINT']="tflint -c ${TERRAFORM_TFLINT_LINTER_RULES}" LINTER_COMMANDS_ARRAY['TERRAFORM_TFLINT']="tflint -c ${TERRAFORM_TFLINT_LINTER_RULES}"
LINTER_COMMANDS_ARRAY['TERRAFORM_TERRASCAN']="terrascan scan -i terraform -t all -c ${TERRAFORM_TERRASCAN_LINTER_RULES} -f" LINTER_COMMANDS_ARRAY['TERRAFORM_TERRASCAN']="terrascan scan -i terraform -t all -c ${TERRAFORM_TERRASCAN_LINTER_RULES} -f"

View file

@ -392,6 +392,7 @@ control "super-linter-validate-files" do
"/action/lib/.automation/.scalafmt.conf", "/action/lib/.automation/.scalafmt.conf",
"/action/lib/.automation/.snakefmt.toml", "/action/lib/.automation/.snakefmt.toml",
"/action/lib/.automation/.sql-config.json", "/action/lib/.automation/.sql-config.json",
"/action/lib/.automation/.sqlfluffini",
"/action/lib/.automation/.stylelintrc.json", "/action/lib/.automation/.stylelintrc.json",
"/action/lib/.automation/.tflint.hcl", "/action/lib/.automation/.tflint.hcl",
"/action/lib/.automation/.yaml-lint.yml", "/action/lib/.automation/.yaml-lint.yml",