fix: don't add unnecessary empty lines (#5221)

This commit is contained in:
Marco Ferrari 2024-02-05 11:49:22 +01:00 committed by GitHub
parent ef9449e2b0
commit eded42747b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 16 deletions

View file

@ -379,7 +379,7 @@ ENV PATH="${PATH}:${DART_SDK}/bin:/root/.pub-cache/bin"
# Initialize Terrascan
# Initialize ChkTeX config file
RUN terrascan init \
RUN terrascan init --log-level "debug" \
&& touch ~/.chktexrc
ENTRYPOINT ["/action/lib/linter.sh"]

View file

@ -150,14 +150,14 @@ function BuildFileList() {
local RESULTS_OBJECT
RESULTS_OBJECT=
if ! RESULTS_OBJECT=$(jq -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
if ! RESULTS_OBJECT=$(jq --raw-output -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
fatal "Error loading results when building the file list: ${RESULTS_OBJECT}"
fi
debug "RESULTS_OBJECT for ${FILE_TYPE}:\n${RESULTS_OBJECT}"
local STDOUT_BUILD_FILE_LIST
# Get raw output so we can strip quotes from the data we load
if ! STDOUT_BUILD_FILE_LIST="$(jq --raw-output '.[].Stdout' <<<"${RESULTS_OBJECT}")"; then
if ! STDOUT_BUILD_FILE_LIST="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout when building the file list: ${STDOUT_BUILD_FILE_LIST}"
fi
@ -168,12 +168,12 @@ function BuildFileList() {
fi
local STDERR_BUILD_FILE_LIST
if ! STDERR_BUILD_FILE_LIST="$(jq --raw-output '.[].Stderr' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_BUILD_FILE_LIST="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr when building the file list:\n${STDERR_BUILD_FILE_LIST}"
fi
if [ -n "${STDERR_BUILD_FILE_LIST}" ]; then
info "Command output when building the file list:\n------\n${STDERR_BUILD_FILE_LIST}\n------"
info "Stderr when building the file list:\n------\n${STDERR_BUILD_FILE_LIST}\n------"
else
debug "Stderr when building the file list is empty"
fi

View file

@ -173,7 +173,7 @@ function LintCodebase() {
local RESULTS_OBJECT
RESULTS_OBJECT=
if ! RESULTS_OBJECT=$(jq -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
if ! RESULTS_OBJECT=$(jq --raw-output -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
fatal "Error loading results for ${FILE_TYPE}: ${RESULTS_OBJECT}"
fi
debug "RESULTS_OBJECT for ${FILE_TYPE}:\n${RESULTS_OBJECT}"
@ -187,8 +187,8 @@ function LintCodebase() {
debug "Set INDEX for ${FILE_TYPE} to: ${INDEX}"
local STDOUT_LINTER
# Get raw output so we can strip quotes from the data we load
if ! STDOUT_LINTER="$(jq --raw-output '.[].Stdout' <<<"${RESULTS_OBJECT}")"; then
# Get raw output so we can strip quotes from the data we load. Also, strip the final newline to avoid adding it two times
if ! STDOUT_LINTER="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout for ${FILE_TYPE}:\n${STDOUT_LINTER}"
fi
@ -199,12 +199,12 @@ function LintCodebase() {
fi
local STDERR_LINTER
if ! STDERR_LINTER="$(jq --raw-output '.[].Stderr' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_LINTER="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr for ${FILE_TYPE}:\n${STDERR_LINTER}"
fi
if [ -n "${STDERR_LINTER}" ]; then
info "Command output for ${FILE_TYPE}:\n------\n${STDERR_LINTER}\n------"
info "Stderr contents for ${FILE_TYPE}:\n------\n${STDERR_LINTER}\n------"
else
debug "Stderr for ${FILE_TYPE} is empty"
fi

View file

@ -929,13 +929,13 @@ debug "PARALLEL_COMMAND_OUTPUT when running linters (exit code: ${PARALLEL_COMMA
debug "Parallel output file (${PARALLEL_RESULTS_FILE_PATH}) contents when running linters:\n$(cat "${PARALLEL_RESULTS_FILE_PATH}")"
RESULTS_OBJECT=
if ! RESULTS_OBJECT=$(jq -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
if ! RESULTS_OBJECT=$(jq --raw-output -n '[inputs]' "${PARALLEL_RESULTS_FILE_PATH}"); then
fatal "Error loading results when building the file list: ${RESULTS_OBJECT}"
fi
debug "RESULTS_OBJECT when running linters:\n${RESULTS_OBJECT}"
# Get raw output so we can strip quotes from the data we load
if ! STDOUT_LINTERS="$(jq --raw-output '.[].Stdout' <<<"${RESULTS_OBJECT}")"; then
# Get raw output so we can strip quotes from the data we load. Also, strip the final newline to avoid adding it two times
if ! STDOUT_LINTERS="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout when running linters:\n${STDOUT_LINTERS}"
fi
@ -945,12 +945,12 @@ else
debug "Stdout when running linters is empty"
fi
if ! STDERR_LINTERS="$(jq --raw-output '.[].Stderr' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_LINTERS="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr for ${FILE_TYPE}:\n${STDERR_LINTERS}"
fi
if [ -n "${STDERR_LINTERS}" ]; then
info "Command output for ${FILE_TYPE}:\n------\n${STDERR_LINTERS}\n------"
info "Stderr when running linters:\n------\n${STDERR_LINTERS}\n------"
else
debug "Stderr when running linters is empty"
fi

View file

@ -483,7 +483,8 @@ control "super-linter-validate-files" do
"/action/lib/.automation/.yaml-lint.yml",
"/action/lib/.automation/phpcs.xml",
"/action/lib/.automation/phpstan.neon",
"/action/lib/.automation/psalm.xml"
"/action/lib/.automation/psalm.xml",
"/root/.chktexrc"
]
files.each do |item|