mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Add rustfmt for Rust (#1250)
* Add linter for Rust - add 2015 edition - add 2018 edition * Add tap reports - add tap reports - fix good test case * 1 command=lesslayers Co-authored-by: Lukas Gravley <admiralawkbar@github.com>
This commit is contained in:
parent
141a09cdbf
commit
f47b363f71
10 changed files with 73 additions and 1 deletions
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - rust_bad_1.rs
|
||||
---
|
||||
message: Diff in /tmp/lint/.automation/test/rust_2015/rust_bad_1.rs at line 1 \n // rustfmt-struct_field_align_threshold 50\n fn func() {\n- Ok(ServerInformation { name unwrap_message_string(items.get(0)),\n- vendor unwrap_message_string(items.get(1)),\n- version unwrap_message_string(items.get(2)),\n- spec_version unwrap_message_string(items.get(3)), });\n+ Ok(ServerInformation {\n+ name unwrap_message_string(items.get(0)),\n+ vendor unwrap_message_string(items.get(1)),\n+ version unwrap_message_string(items.get(2)),\n+ spec_version unwrap_message_string(items.get(3)),\n+ });\n }\n \n
|
||||
...
|
||||
ok 2 - rust_good_1.rs
|
7
.automation/test/rust_2015/rust_bad_1.rs
Normal file
7
.automation/test/rust_2015/rust_bad_1.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// rustfmt-struct_field_align_threshold: 50
|
||||
fn func() {
|
||||
Ok(ServerInformation { name: unwrap_message_string(items.get(0)),
|
||||
vendor: unwrap_message_string(items.get(1)),
|
||||
version: unwrap_message_string(items.get(2)),
|
||||
spec_version: unwrap_message_string(items.get(3)), });
|
||||
}
|
8
.automation/test/rust_2015/rust_good_1.rs
Normal file
8
.automation/test/rust_2015/rust_good_1.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
fn func() {
|
||||
Ok(ServerInformation {
|
||||
name: unwrap_message_string(items.get(0)),
|
||||
vendor: unwrap_message_string(items.get(1)),
|
||||
version: unwrap_message_string(items.get(2)),
|
||||
spec_version: unwrap_message_string(items.get(3)),
|
||||
});
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - rust_bad_1.rs
|
||||
---
|
||||
message: Diff in /tmp/lint/.automation/test/rust_2018/rust_bad_1.rs at line 1 \n // rustfmt-struct_field_align_threshold 50\n fn func() {\n- Ok(ServerInformation { name unwrap_message_string(items.get(0)),\n- vendor unwrap_message_string(items.get(1)),\n- version unwrap_message_string(items.get(2)),\n- spec_version unwrap_message_string(items.get(3)), });\n+ Ok(ServerInformation {\n+ name unwrap_message_string(items.get(0)),\n+ vendor unwrap_message_string(items.get(1)),\n+ version unwrap_message_string(items.get(2)),\n+ spec_version unwrap_message_string(items.get(3)),\n+ });\n }\n \n
|
||||
...
|
||||
ok 2 - rust_good_1.rs
|
7
.automation/test/rust_2018/rust_bad_1.rs
Normal file
7
.automation/test/rust_2018/rust_bad_1.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// rustfmt-struct_field_align_threshold: 50
|
||||
fn func() {
|
||||
Ok(ServerInformation { name: unwrap_message_string(items.get(0)),
|
||||
vendor: unwrap_message_string(items.get(1)),
|
||||
version: unwrap_message_string(items.get(2)),
|
||||
spec_version: unwrap_message_string(items.get(3)), });
|
||||
}
|
8
.automation/test/rust_2018/rust_good_1.rs
Normal file
8
.automation/test/rust_2018/rust_good_1.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
fn func() {
|
||||
Ok(ServerInformation {
|
||||
name: unwrap_message_string(items.get(0)),
|
||||
vendor: unwrap_message_string(items.get(1)),
|
||||
version: unwrap_message_string(items.get(2)),
|
||||
spec_version: unwrap_message_string(items.get(3)),
|
||||
});
|
||||
}
|
|
@ -109,6 +109,7 @@ RUN apk add --no-cache \
|
|||
R R-dev R-doc \
|
||||
readline-dev \
|
||||
ruby ruby-dev ruby-bundler ruby-rdoc \
|
||||
rustup \
|
||||
zlib zlib-dev
|
||||
|
||||
########################################
|
||||
|
@ -141,6 +142,14 @@ ENV PATH="/node_modules/.bin:${PATH}"
|
|||
##############################
|
||||
RUN bundle install
|
||||
|
||||
##############################
|
||||
# Install rustfmt #
|
||||
##############################
|
||||
RUN ln -s /usr/bin/rustup-init /usr/bin/rustup \
|
||||
&& rustup toolchain install stable-x86_64-unknown-linux-musl \
|
||||
&& rustup component add rustfmt --toolchain=stable-x86_64-unknown-linux-musl \
|
||||
&& ln -s /root/.rustup/toolchains/stable-x86_64-unknown-linux-musl/bin/rustfmt /usr/bin/rustfmt
|
||||
|
||||
###################################
|
||||
# Install DotNet and Dependencies #
|
||||
###################################
|
||||
|
|
|
@ -79,6 +79,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **R** | [lintr](https://github.com/jimhester/lintr) |
|
||||
| **Raku** | [Raku](https://raku.org) |
|
||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||
| **Rust** | [Rustfmt](https://github.com/rust-lang/rustfmt) |
|
||||
| **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) |
|
||||
| **SQL** | [sql-lint](https://github.com/joereynolds/sql-lint) |
|
||||
|
@ -284,6 +285,8 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **VALIDATE_R** | `true` | Flag to enable or disable the linting process of the R language. |
|
||||
| **VALIDATE_RAKU** | `true` | Flag to enable or disable the linting process of the Raku language. |
|
||||
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the Ruby language. |
|
||||
| **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_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) |
|
||||
|
|
|
@ -640,6 +640,16 @@ function BuildFileList() {
|
|||
################################
|
||||
FILE_ARRAY_RUBY+=("${FILE}")
|
||||
|
||||
######################
|
||||
# Get the RUST files #
|
||||
######################
|
||||
elif [ "${FILE_TYPE}" == "rs" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_RUST_2015+=("${FILE}")
|
||||
FILE_ARRAY_RUST_2018+=("${FILE}")
|
||||
|
||||
###########################
|
||||
# Get the SNAKEMAKE files #
|
||||
###########################
|
||||
|
|
|
@ -184,7 +184,9 @@ LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLOUDFORMATION' 'CLOJURE' 'C
|
|||
'DART' 'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GHERKIN' 'GO' 'GROOVY' 'HTML'
|
||||
'JAVA' 'JAVASCRIPT_ES' "${JAVASCRIPT_STYLE_NAME}" 'JSCPD' 'JSON' 'JSX' 'KUBERNETES_KUBEVAL' 'KOTLIN' 'LATEX' 'LUA' 'MARKDOWN'
|
||||
'OPENAPI' 'PERL' 'PHP_BUILTIN' 'PHP_PHPCS' 'PHP_PHPSTAN' 'PHP_PSALM' 'POWERSHELL'
|
||||
'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'PYTHON_ISORT' 'R' 'RAKU' 'RUBY' 'SHELL_SHFMT' 'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL'
|
||||
'PROTOBUF' 'PYTHON_BLACK' 'PYTHON_PYLINT' 'PYTHON_FLAKE8' 'PYTHON_ISORT'
|
||||
'R' 'RAKU' 'RUBY' 'RUST_2015' 'RUST_2018'
|
||||
'SHELL_SHFMT' 'SNAKEMAKE_LINT' 'SNAKEMAKE_SNAKEFMT' 'STATES' 'SQL'
|
||||
'TEKTON' 'TERRAFORM' 'TERRAFORM_TERRASCAN' 'TERRAGRUNT' 'TSX' 'TYPESCRIPT_ES' 'TYPESCRIPT_STANDARD' 'XML' 'YAML')
|
||||
|
||||
##############################
|
||||
|
@ -235,6 +237,8 @@ LINTER_NAMES_ARRAY['PYTHON_ISORT']="isort"
|
|||
LINTER_NAMES_ARRAY['R']="R"
|
||||
LINTER_NAMES_ARRAY['RAKU']="raku"
|
||||
LINTER_NAMES_ARRAY['RUBY']="rubocop"
|
||||
LINTER_NAMES_ARRAY['RUST_2015']="rustfmt"
|
||||
LINTER_NAMES_ARRAY['RUST_2018']="rustfmt"
|
||||
LINTER_NAMES_ARRAY['SHELL_SHFMT']="shfmt"
|
||||
LINTER_NAMES_ARRAY['SNAKEMAKE_LINT']="snakemake"
|
||||
LINTER_NAMES_ARRAY['SNAKEMAKE_SNAKEFMT']="snakefmt"
|
||||
|
@ -804,6 +808,8 @@ LINTER_COMMANDS_ARRAY['PYTHON_ISORT']="isort --check --diff --sp ${PYTHON_ISORT_
|
|||
LINTER_COMMANDS_ARRAY['R']="lintr"
|
||||
LINTER_COMMANDS_ARRAY['RAKU']="raku"
|
||||
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['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"
|
||||
|
|
Loading…
Reference in a new issue