mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 16:21:00 -05:00
Adding scalafmt (#2053)
* Adding scalafmt * add it Co-authored-by: Jake Herbst <jherbst@rsglab.com> Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
parent
1d50613c10
commit
897185a4aa
9 changed files with 115 additions and 3 deletions
19
.automation/test/scalafmt/README.md
Normal file
19
.automation/test/scalafmt/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Scala Test Cases
|
||||
|
||||
This folder holds the test cases for **Scala**.
|
||||
|
||||
## Additional Docs
|
||||
|
||||
No Additional information is needed for this test case.
|
||||
|
||||
## Good Test Cases
|
||||
|
||||
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
||||
|
||||
## Bad Test Cases
|
||||
|
||||
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
31
.automation/test/scalafmt/scalafmt_bad_1.scala
Normal file
31
.automation/test/scalafmt/scalafmt_bad_1.scala
Normal file
|
@ -0,0 +1,31 @@
|
|||
object a {
|
||||
class a[
|
||||
t1,
|
||||
t2 // comment
|
||||
](a1: Int,
|
||||
a2: Int // comment
|
||||
)(
|
||||
b1: String,
|
||||
b2: String // comment
|
||||
)(implicit
|
||||
c1: SomeType1,
|
||||
c2: SomeType2 // comment
|
||||
) {
|
||||
def this(
|
||||
a1: Int,
|
||||
a2: Int // comment
|
||||
)(
|
||||
b1: String,
|
||||
b2: String // comment
|
||||
)(implicit
|
||||
c1: SomeType1,
|
||||
c2: SomeType2 // comment
|
||||
) = this(
|
||||
a1,
|
||||
a2 // comment
|
||||
) (
|
||||
b1,
|
||||
b2 // comment
|
||||
)
|
||||
}
|
||||
}
|
32
.automation/test/scalafmt/scalafmt_good_1.scala
Normal file
32
.automation/test/scalafmt/scalafmt_good_1.scala
Normal file
|
@ -0,0 +1,32 @@
|
|||
object a {
|
||||
class a[
|
||||
t1,
|
||||
t2 // comment
|
||||
](
|
||||
a1: Int,
|
||||
a2: Int // comment
|
||||
)(
|
||||
b1: String,
|
||||
b2: String // comment
|
||||
)(implicit
|
||||
c1: SomeType1,
|
||||
c2: SomeType2 // comment
|
||||
) {
|
||||
def this(
|
||||
a1: Int,
|
||||
a2: Int // comment
|
||||
)(
|
||||
b1: String,
|
||||
b2: String // comment
|
||||
)(implicit
|
||||
c1: SomeType1,
|
||||
c2: SomeType2 // comment
|
||||
) = this(
|
||||
a1,
|
||||
a2 // comment
|
||||
)(
|
||||
b1,
|
||||
b2 // comment
|
||||
)
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ FROM zricethezav/gitleaks:v7.6.1 as gitleaks
|
|||
FROM garethr/kubeval:0.15.0 as kubeval
|
||||
FROM ghcr.io/assignuser/lintr-lib:0.3.0 as lintr-lib
|
||||
FROM ghcr.io/awkbar-devops/clang-format:v1.0.2 as clang-format
|
||||
FROM scalameta/scalafmt:v2.7.5 as scalafmt
|
||||
|
||||
##################
|
||||
# Get base image #
|
||||
|
@ -253,6 +254,11 @@ COPY --from=clang-format /usr/bin/clang-format /usr/bin/
|
|||
####################
|
||||
COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
|
||||
|
||||
####################
|
||||
# Install scalafmt #
|
||||
####################
|
||||
COPY --from=scalafmt /bin/scalafmt /usr/bin/
|
||||
|
||||
#################
|
||||
# Install Litnr #
|
||||
#################
|
||||
|
|
|
@ -29,6 +29,7 @@ FROM zricethezav/gitleaks:v7.6.1 as gitleaks
|
|||
FROM garethr/kubeval:0.15.0 as kubeval
|
||||
FROM ghcr.io/assignuser/lintr-lib:0.3.0 as lintr-lib
|
||||
FROM ghcr.io/awkbar-devops/clang-format:v1.0.2 as clang-format
|
||||
FROM scalameta/scalafmt:v2.7.5 as scalafmt
|
||||
|
||||
##################
|
||||
# Get base image #
|
||||
|
@ -191,6 +192,11 @@ COPY --from=clang-format /usr/bin/clang-format /usr/bin/
|
|||
####################
|
||||
COPY --from=gitleaks /usr/bin/gitleaks /usr/bin/
|
||||
|
||||
####################
|
||||
# Install scalafmt #
|
||||
####################
|
||||
COPY --from=scalafmt /bin/scalafmt /usr/bin/
|
||||
|
||||
#################
|
||||
# Install Litnr #
|
||||
#################
|
||||
|
|
|
@ -91,6 +91,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their codebase w
|
|||
| **Raku** | [Raku](https://raku.org) |
|
||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||
| **Rust** | [Rustfmt](https://github.com/rust-lang/rustfmt) / [Clippy](https://github.com/rust-lang/rust-clippy) |
|
||||
| **Scala** | [scalafmt](https://github.com/scalameta/scalafmt) |
|
||||
| **Secrets** | [GitLeaks](https://github.com/zricethezav/gitleaks) |
|
||||
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) / [executable bit check] / [shfmt](https://github.com/mvdan/sh) |
|
||||
| **Snakemake** | [snakefmt](https://github.com/snakemake/snakefmt/) / [snakemake --lint](https://snakemake.readthedocs.io/en/stable/snakefiles/writing_snakefiles.html#best-practices) |
|
||||
|
@ -310,6 +311,7 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **RUBY_CONFIG_FILE** | `.ruby-lint.yml` | Filename for [rubocop configuration](https://docs.rubocop.org/rubocop/configuration.html) (ex: `.ruby-lint.yml`, `.rubocop.yml`) |
|
||||
| **SUPPRESS_FILE_TYPE_WARN** | `false` | If set to `true`, will hide warning messages about files without their proper extensions. Default is `false` |
|
||||
| **SUPPRESS_POSSUM** | `false` | If set to `true`, will hide the ASCII possum at top of log output. Default is `false` |
|
||||
| **SCALAFMT_CONFIG_FILE** | `.scalafmt.conf` | Filename for [scalafmt configuration](https://scalameta.org/scalafmt/docs/configuration.html) (ex: `.scalafmt.conf`) |
|
||||
| **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 }}) |
|
||||
| **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`) |
|
||||
|
@ -375,6 +377,7 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **VALIDATE_RUST_2015** | `true` | Flag to enable or disable the linting process of the Rust language. (edition: 2015) |
|
||||
| **VALIDATE_RUST_2018** | `true` | Flag to enable or disable the linting process of Rust language. (edition: 2018) |
|
||||
| **VALIDATE_RUST_CLIPPY** | `true` | Flag to enable or disable the clippy linting process of Rust language. |
|
||||
| **VALIDATE_SCALAFMT_LINT** | `true` | Flag to enable or disable the linting process of Scala language. (Utilizing: scalafmt --test) |
|
||||
| **VALIDATE_SHELL_SHFMT** | `true` | Flag to enable or disable the linting process of Shell scripts. (Utilizing: shfmt) |
|
||||
| **VALIDATE_SNAKEMAKE_LINT** | `true` | Flag to enable or disable the linting process of Snakefiles. (Utilizing: snakemake --lint) |
|
||||
| **VALIDATE_SNAKEMAKE_SNAKEFMT** | `true` | Flag to enable or disable the linting process of Snakefiles. (Utilizing: snakefmt) |
|
||||
|
|
|
@ -687,6 +687,15 @@ function BuildFileList() {
|
|||
###############################################
|
||||
FILE_ARRAY_RUST_CLIPPY+=("${FILE}")
|
||||
|
||||
###########################
|
||||
# Get the SCALA files #
|
||||
###########################
|
||||
elif [ "${FILE_TYPE}" == "scala" ] || [ "${BASE_FILE}" == "??????" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_SCALAFMT+=("${FILE}")
|
||||
|
||||
###########################
|
||||
# Get the SNAKEMAKE files #
|
||||
###########################
|
||||
|
|
|
@ -162,6 +162,8 @@ R_FILE_NAME=".lintr"
|
|||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
RUBY_FILE_NAME="${RUBY_CONFIG_FILE:-.ruby-lint.yml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
SCALAFMT_FILE_NAME="${SCALAFMT_CONFIG_FILE:-.scalafmt.conf}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
SNAKEMAKE_SNAKEFMT_FILE_NAME="${SNAKEMAKE_SNAKEFMT_CONFIG_FILE:-.snakefmt.toml}"
|
||||
# shellcheck disable=SC2034 # Variable is referenced indirectly
|
||||
SUPPRESS_FILE_TYPE_WARN="${SUPPRESS_FILE_TYPE_WARN:-false}"
|
||||
|
@ -218,9 +220,9 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLANG_FORMAT'
|
|||
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM'
|
||||
'POWERSHELL' 'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8'
|
||||
'PYTHON_ISORT' 'PYTHON_MYPY' 'R' 'RAKU' 'RUBY' 'RUST_2015' 'RUST_2018'
|
||||
'RUST_CLIPPY' 'SHELL_SHFMT' 'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES'
|
||||
'SQL' 'SQLFLUFF' 'TEKTON' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT'
|
||||
'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
'RUST_CLIPPY' 'SCALAFMT' 'SHELL_SHFMT' 'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT'
|
||||
'STATES' 'SQL' 'SQLFLUFF' 'TEKTON' 'TERRAFORM_TFLINT' 'TERRAFORM_TERRASCAN'
|
||||
'TERRAGRUNT' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
|
||||
##############################
|
||||
# Linter command names array #
|
||||
|
@ -281,6 +283,7 @@ LINTER_NAMES_ARRAY['RUBY']="rubocop"
|
|||
LINTER_NAMES_ARRAY['RUST_2015']="rustfmt"
|
||||
LINTER_NAMES_ARRAY['RUST_2018']="rustfmt"
|
||||
LINTER_NAMES_ARRAY['RUST_CLIPPY']="clippy"
|
||||
LINTER_NAMES_ARRAY['SCALAFMT']="scalafmt"
|
||||
LINTER_NAMES_ARRAY['SHELL_SHFMT']="shfmt"
|
||||
LINTER_NAMES_ARRAY['SNAKEMAKE_LINT']="snakemake"
|
||||
LINTER_NAMES_ARRAY['SNAKEMAKE_SNAKEFMT']="snakefmt"
|
||||
|
@ -899,6 +902,7 @@ LINTER_COMMANDS_ARRAY['RUBY']="rubocop -c ${RUBY_LINTER_RULES} --force-exclusion
|
|||
LINTER_COMMANDS_ARRAY['RUST_2015']="rustfmt --check --edition 2015"
|
||||
LINTER_COMMANDS_ARRAY['RUST_2018']="rustfmt --check --edition 2018"
|
||||
LINTER_COMMANDS_ARRAY['RUST_CLIPPY']="clippy"
|
||||
LINTER_COMMANDS_ARRAY['SCALAFMT']="scalafmt --config ${SCALAFMT_LINTER_RULES} --test"
|
||||
LINTER_COMMANDS_ARRAY['SHELL_SHFMT']="shfmt -d"
|
||||
LINTER_COMMANDS_ARRAY['SNAKEMAKE_LINT']="snakemake --lint -s"
|
||||
LINTER_COMMANDS_ARRAY['SNAKEMAKE_SNAKEFMT']="snakefmt --config ${SNAKEMAKE_SNAKEFMT_LINTER_RULES} --check --compact-diff"
|
||||
|
|
|
@ -137,6 +137,7 @@ control "super-linter-installed-commands" do
|
|||
{ linter_name: "raku", version_command: "raku --version | strings -n 8"},
|
||||
{ linter_name: "rubocop"},
|
||||
{ linter_name: "rustfmt"},
|
||||
{ linter_name: "scalafmt"},
|
||||
{ linter_name: "shellcheck"},
|
||||
{ linter_name: "shfmt"},
|
||||
{ linter_name: "snakefmt"},
|
||||
|
@ -424,6 +425,7 @@ control "super-linter-validate-files" do
|
|||
"/action/lib/.automation/.python-black",
|
||||
"/action/lib/.automation/.python-lint",
|
||||
"/action/lib/.automation/.ruby-lint.yml",
|
||||
"/action/lib/.automation/.scalafmt.conf",
|
||||
"/action/lib/.automation/.snakefmt.toml",
|
||||
"/action/lib/.automation/.sql-config.json",
|
||||
"/action/lib/.automation/.stylelintrc.json",
|
||||
|
|
Loading…
Reference in a new issue