mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-06 01:05:54 -05:00
Enhancement: Add support for google-java-format (#1969)
* Add support for google-java-format * adding tests and array * fix comma * Update linter.sh * get it in order * fix hava version Co-authored-by: Admiral Awkbar <admiralawkbar@github.com>
This commit is contained in:
parent
ec410c9131
commit
1afc7f8409
12 changed files with 96 additions and 14 deletions
19
.automation/test/google_java_format/README.md
Normal file
19
.automation/test/google_java_format/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Google Java Format Test Cases
|
||||
|
||||
This folder holds the test cases for **Google Java format**.
|
||||
|
||||
## 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.
|
|
@ -0,0 +1,8 @@
|
|||
class java_bad_1 // first letter of classname is not capitalized
|
||||
{
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
System.out.println("Hello, World");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
public class Application {
|
||||
|
||||
/**
|
||||
* main.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Represents a good Java file.
|
||||
*/
|
||||
public static class JavaGood {
|
||||
// Prints "Hello, World" to the terminal window.
|
||||
private void helloWorld() {
|
||||
System.out.println("Hello, World");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
@SuppressWarnings("checkstyle:hideutilityclassconstructor")
|
||||
public class Application {
|
||||
|
||||
/**
|
||||
* main.
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
10
Dockerfile
10
Dockerfile
|
@ -69,7 +69,7 @@ RUN apk add --no-cache \
|
|||
make \
|
||||
musl-dev \
|
||||
npm nodejs-current \
|
||||
openjdk8-jre \
|
||||
openjdk11-jre \
|
||||
openssl-dev \
|
||||
perl perl-dev \
|
||||
py3-setuptools python3-dev \
|
||||
|
@ -287,6 +287,14 @@ RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repo
|
|||
| cut -d '"' -f 4) \
|
||||
&& curl --retry 5 --retry-delay 5 -sSL "$CHECKSTYLE_LATEST" \
|
||||
--output /usr/bin/checkstyle \
|
||||
##############################
|
||||
# Install google-java-format #
|
||||
##############################
|
||||
&& GOOGLE_JAVA_FORMAT_VERSION=$(curl -s https://github.com/google/google-java-format/releases/latest \
|
||||
| cut -d '"' -f 2 | cut -d '/' -f 8 | sed -e 's/v//g') \
|
||||
&& curl --retry 5 --retry-delay 5 -sSL \
|
||||
"https://github.com/google/google-java-format/releases/download/v$GOOGLE_JAVA_FORMAT_VERSION/google-java-format-$GOOGLE_JAVA_FORMAT_VERSION-all-deps.jar" \
|
||||
--output /usr/bin/google-java-format \
|
||||
#################################
|
||||
# Install luacheck and luarocks #
|
||||
#################################
|
||||
|
|
|
@ -68,7 +68,7 @@ RUN apk add --no-cache \
|
|||
make \
|
||||
musl-dev \
|
||||
npm nodejs-current \
|
||||
openjdk8-jre \
|
||||
openjdk11-jre \
|
||||
openssl-dev \
|
||||
perl perl-dev \
|
||||
py3-setuptools python3-dev \
|
||||
|
@ -225,6 +225,14 @@ RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community/" >> /etc/apk/repo
|
|||
| cut -d '"' -f 4) \
|
||||
&& curl --retry 5 --retry-delay 5 -sSL "$CHECKSTYLE_LATEST" \
|
||||
--output /usr/bin/checkstyle \
|
||||
##############################
|
||||
# Install google-java-format #
|
||||
##############################
|
||||
&& GOOGLE_JAVA_FORMAT_VERSION=$(curl -s https://github.com/google/google-java-format/releases/latest \
|
||||
| cut -d '"' -f 2 | cut -d '/' -f 8 | sed -e 's/v//g') \
|
||||
&& curl --retry 5 --retry-delay 5 -sSL \
|
||||
"https://github.com/google/google-java-format/releases/download/v$GOOGLE_JAVA_FORMAT_VERSION/google-java-format-$GOOGLE_JAVA_FORMAT_VERSION-all-deps.jar" \
|
||||
--output /usr/bin/google-java-format \
|
||||
#################################
|
||||
# Install luacheck and luarocks #
|
||||
#################################
|
||||
|
|
|
@ -71,7 +71,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **Golang** | [golangci-lint](https://github.com/golangci/golangci-lint) |
|
||||
| **Groovy** | [npm-groovy-lint](https://github.com/nvuillam/npm-groovy-lint) |
|
||||
| **HTML** | [HTMLHint](https://github.com/htmlhint/HTMLHint) |
|
||||
| **Java** | [checkstyle](https://checkstyle.org) |
|
||||
| **Java** | [checkstyle](https://checkstyle.org) / [google-java-format](https://github.com/google/google-java-format) |
|
||||
| **JavaScript** | [eslint](https://eslint.org/) / [standard js](https://standardjs.com/) |
|
||||
| **JSON** | [eslint-plugin-json](https://www.npmjs.com/package/eslint-plugin-json) |
|
||||
| **JSONC** | [eslint-plugin-jsonc](https://www.npmjs.com/package/eslint-plugin-jsonc) |
|
||||
|
@ -337,9 +337,10 @@ But if you wish to select or exclude specific linters, we give you full control
|
|||
| **VALIDATE_GITLEAKS** | `true` | Flag to enable or disable the linting process of the secrets. |
|
||||
| **VALIDATE_GHERKIN** | `true` | Flag to enable or disable the linting process of the Gherkin language. |
|
||||
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the Golang language. |
|
||||
| **VALIDATE_GOOGLE_JAVA_FORMAT** | `true` | Flag to enable or disable the linting process of the Java language. (Utilizing: google-java-format) |
|
||||
| **VALIDATE_GROOVY** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_HTML** | `true` | Flag to enable or disable the linting process of the HTML language. |
|
||||
| **VALIDATE_JAVA** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_JAVA** | `true` | Flag to enable or disable the linting process of the Java language. (Utilizing: checkstyle) |
|
||||
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: eslint) |
|
||||
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the Javascript language. (Utilizing: standard) |
|
||||
| **VALIDATE_JSCPD** | `true` | Flag to enable or disable the JSCPD. |
|
||||
|
|
|
@ -457,6 +457,7 @@ function BuildFileList() {
|
|||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_JAVA+=("${FILE}")
|
||||
FILE_ARRAY_GOOGLE_JAVA_FORMAT+=("${FILE}")
|
||||
|
||||
############################
|
||||
# Get the JavaScript files #
|
||||
|
|
|
@ -81,7 +81,7 @@ BuildLinterVersions() {
|
|||
GET_VERSION_CMD="$("${LINTER}" -v 2>&1)"
|
||||
elif [[ ${LINTER} == "terrascan" ]]; then
|
||||
GET_VERSION_CMD="$("${LINTER}" version 2>&1)"
|
||||
elif [[ ${LINTER} == "checkstyle" ]]; then
|
||||
elif [[ ${LINTER} == "checkstyle" ]] || [[ ${LINTER} == "google-java-format" ]]; then
|
||||
GET_VERSION_CMD="$(java -jar "/usr/bin/${LINTER}" --version 2>&1)"
|
||||
elif [[ ${LINTER} == "clippy" ]]; then
|
||||
GET_VERSION_CMD="$(cargo-clippy --version 2>&1)"
|
||||
|
|
|
@ -202,15 +202,15 @@ fi
|
|||
LANGUAGE_ARRAY=('ANSIBLE' 'ARM' 'BASH' 'BASH_EXEC' 'CLANG_FORMAT'
|
||||
'CLOUDFORMATION' 'CLOJURE' 'COFFEESCRIPT' 'CPP' 'CSHARP' 'CSS' 'DART'
|
||||
'DOCKERFILE' 'DOCKERFILE_HADOLINT' 'EDITORCONFIG' 'ENV' 'GITHUB_ACTIONS'
|
||||
'GITLEAKS' 'GHERKIN' 'GO' 'GROOVY' 'HTML' 'JAVA' 'JAVASCRIPT_ES'
|
||||
"${JAVASCRIPT_STYLE_NAME}" 'JSCPD' 'JSON' 'JSONC' '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' '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')
|
||||
'GITLEAKS' 'GHERKIN' 'GO' 'GOOGLE_JAVA_FORMAT' 'GROOVY' 'HTML' 'JAVA'
|
||||
'JAVASCRIPT_ES' "${JAVASCRIPT_STYLE_NAME}" 'JSCPD' 'JSON' 'JSONC' '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' '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')
|
||||
|
||||
##############################
|
||||
# Linter command names array #
|
||||
|
@ -236,6 +236,7 @@ LINTER_NAMES_ARRAY['GITHUB_ACTIONS']="actionlint"
|
|||
LINTER_NAMES_ARRAY['GITLEAKS']="gitleaks"
|
||||
LINTER_NAMES_ARRAY['GHERKIN']="gherkin-lint"
|
||||
LINTER_NAMES_ARRAY['GO']="golangci-lint"
|
||||
LINTER_NAMES_ARRAY['GOOGLE_JAVA_FORMAT']="google-java-format"
|
||||
LINTER_NAMES_ARRAY['GROOVY']="npm-groovy-lint"
|
||||
LINTER_NAMES_ARRAY['HTML']="htmlhint"
|
||||
LINTER_NAMES_ARRAY['JAVA']="checkstyle"
|
||||
|
@ -837,6 +838,7 @@ LINTER_COMMANDS_ARRAY['GITHUB_ACTIONS']="actionlint -config-file ${GITHUB_ACTION
|
|||
LINTER_COMMANDS_ARRAY['GITLEAKS']="gitleaks -q -c ${GITLEAKS_LINTER_RULES} --no-git -p"
|
||||
LINTER_COMMANDS_ARRAY['GHERKIN']="gherkin-lint -c ${GHERKIN_LINTER_RULES}"
|
||||
LINTER_COMMANDS_ARRAY['GO']="golangci-lint run -c ${GO_LINTER_RULES}"
|
||||
LINTER_COMMANDS_ARRAY['GOOGLE_JAVA_FORMAT']="java -jar /usr/bin/google-java-format"
|
||||
LINTER_COMMANDS_ARRAY['GROOVY']="npm-groovy-lint -c ${GROOVY_LINTER_RULES} --failon warning"
|
||||
LINTER_COMMANDS_ARRAY['HTML']="htmlhint --config ${HTML_LINTER_RULES}"
|
||||
LINTER_COMMANDS_ARRAY['JAVA']="java -jar /usr/bin/checkstyle -c ${JAVA_LINTER_RULES}"
|
||||
|
|
|
@ -98,6 +98,7 @@ control "super-linter-installed-commands" do
|
|||
{ linter_name: "clang-format"},
|
||||
{ linter_name: "cfn-lint"},
|
||||
{ linter_name: "checkstyle", version_command: "java -jar /usr/bin/checkstyle --version"},
|
||||
{ linter_name: "google-java-format", version_command: "java -jar /usr/bin/google-java-format --version"},
|
||||
{ linter_name: "chktex"},
|
||||
{ linter_name: "clippy", linter_command: "clippy", version_command: "cargo-clippy --version"},
|
||||
{ linter_name: "clj-kondo"},
|
||||
|
|
Loading…
Reference in a new issue