Merge branch 'master' into dart

This commit is contained in:
Lucas Gravley 2020-07-15 15:42:02 -05:00
commit 93dec38ebf
16 changed files with 6163 additions and 129 deletions

View file

@ -29,6 +29,15 @@ Draft pull requests are also welcome to get feedback early on, or if there is so
- Create a branch with a name that identifies the user and nature of the changes (similar to `user/branch-purpose`)
- Open a pull request
### CI/CT/CD
The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions.
- When a branch is created and code is pushed, a **GitHub** Action is triggered for building the new **Docker** container with the new codebase
- The **Docker** container is then ran against the *test cases* to validate all code sanity
- `.automation/test` contains all test cases for each language that should be validated
- These **GitHub** Actions utilize the Checks API and Protected Branches to help follow the SDLC
- When the Pull Request is merged to master, the **Super-Linter** **Docker** container is then updated and deployed with the new codebase
- **Note:** The branch's **Docker** container is also removed from **DockerHub** to cleanup after itself
## Releasing
If you are the current maintainer of this action:
1. If a major version number change: Update `README.md` and the wiki to reflect new version number in the example workflow file sections

View file

@ -1,3 +1,6 @@
#################################
# GitHub Dependabot Config info #
#################################
version: 2
updates:
- package-ecosystem: github-actions
@ -5,3 +8,32 @@ updates:
schedule:
interval: daily
open-pull-requests-limit: 10
# Maintain dependencies for js with npm
- package-ecosystem: "npm"
directory: "/dependencies"
schedule:
interval: "daily"
open-pull-requests-limit: 10
# Maintain dependencies for ruby with bundler
- package-ecosystem: "bundler"
directory: "/dependencies"
schedule:
interval: "daily"
labels:
- "Type: Maintenance"
# Maintain dependencies for docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
# Maintain dependencies for python with pip
- package-ecosystem: "pip"
directory: "/dependencies"
schedule:
interval: "daily"
open-pull-requests-limit: 10

View file

@ -1,3 +1,7 @@
# We have this file on hold as its an Action that would trigger another action, and not currently supported.
# This then causes the deployRelease action to never fun, which is far more important than auto drafting
# Until we have a better solution, this needs to remain on hold
name: Release Drafter
on:

View file

@ -29,7 +29,7 @@ jobs:
if: "github.event_name == 'schedule'"
steps:
- name: Mark issue stale
uses: actions/stale@v3.0.7
uses: actions/stale@v3.0.8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue has been automatically marked as stale because it has not had recent activity.\nIt will be closed in 14 days if no further activity occurs.\nThank you for your contributions.\n\nIf you think this issue should stay open, please remove the `O: stale 🤖` label or comment on the issue."
@ -37,9 +37,9 @@ jobs:
days-before-stale: 30
days-before-close: 14
stale-issue-label: "O: stale 🤖"
exempt-issue-label: "O: backlog 🤖"
exempt-issue-labels: "O: backlog 🤖"
stale-pr-label: "O: stale 🤖"
exempt-pr-label: "O: backlog 🤖"
exempt-pr-labels: "O: backlog 🤖"
##################
# Mark not stale #

5
.gitignore vendored
View file

@ -61,4 +61,7 @@ typings/
.next
# clj-kondo cache
.cache
.cache
# default output report
super-linter.report

View file

@ -26,12 +26,9 @@ ARG PWSH_VERSION='latest'
ARG PWSH_DIRECTORY='/opt/microsoft/powershell'
ARG PSSA_VERSION='latest'
# arm-ttk
ARG ARM_TTK_URI='https://github.com/Azure/arm-ttk.git'
ARG ARM_TTK_DIRECTORY='/opt/microsoft/arm-ttk'
# clj-kondo
ARG CLJ_KONDO_VERSION='2020.06.21'
# Go Linter
ARG GO_VERSION='v1.27.0'
ARG ARM_TTK_NAME='master.zip'
ARG ARM_TTK_URI='https://github.com/Azure/arm-ttk/archive/master.zip'
ARG ARM_TTK_DIRECTORY='/opt/microsoft'
# Raku Linter
ARG RAKU_VER="2020.06"
ARG RAKU_INSTALL_PATH=/usr
@ -41,19 +38,62 @@ ARG RAKUBREW_HOME=/tmp/rakubrew
# Run APK installs #
####################
RUN apk add --no-cache \
bash git git-lfs musl-dev curl gcc jq file\
npm nodejs \
libxml2-utils perl \
ruby ruby-dev ruby-bundler ruby-rdoc make \
py3-setuptools ansible-lint \
ansible-lint \
bash \
curl \
gcc \
git \
go \
icu-libs \
jq \
libxml2-utils \
make \
musl-dev \
npm \
nodejs \
openjdk8-jre \
perl \
php7 \
ca-certificates less ncurses-terminfo-base \
krb5-libs libgcc libintl libssl1.1 libstdc++ \
tzdata userspace-rcu zlib icu-libs lttng-ust \
libffi-dev openssl-dev
py3-setuptools \
ruby \
ruby-dev \
ruby-bundler \
ruby-rdoc
########################################
# Copy dependencies files to container #
########################################
COPY dependencies/* /
################################
# Installs python dependencies #
################################
RUN pip3 install --no-cache-dir pipenv
RUN pipenv install --system
####################
# Run NPM Installs #
####################
RUN npm config set package-lock false \
&& npm config set loglevel error \
&& npm --no-cache install
#############################
# Add node packages to path #
#############################
ENV PATH="/node_modules/.bin:${PATH}"
####################
# Run GEM installs #
####################
RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0
# Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default
# We then need to promote the correct version, uninstall, and fix deps
RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2 | cut -d"," -f1); \
gem install --default rubocop:0.74.0; \
yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; \
gem install rubocop:0.74.0'
#########################################
# Install Powershell + PSScriptAnalyzer #
@ -77,109 +117,41 @@ RUN mkdir -p ${PWSH_DIRECTORY} \
# Depends on PowerShell
# Reference https://github.com/Azure/arm-ttk
# Reference https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/test-toolkit
ENV ARM_TTK_PSD1="${ARM_TTK_DIRECTORY}/arm-ttk/arm-ttk.psd1"
RUN git clone "${ARM_TTK_URI}" "${ARM_TTK_DIRECTORY}" \
ENV ARM_TTK_PSD1="${ARM_TTK_DIRECTORY}/arm-ttk-master/arm-ttk/arm-ttk.psd1"
RUN curl -sLO "${ARM_TTK_URI}" \
&& unzip "${ARM_TTK_NAME}" -d "${ARM_TTK_DIRECTORY}" \
&& rm "${ARM_TTK_NAME}" \
&& ln -sTf "$ARM_TTK_PSD1" /usr/bin/arm-ttk
#####################
# Run Pip3 Installs #
#####################
RUN pip3 --no-cache-dir install --upgrade --no-cache-dir \
yamllint pylint yq cfn-lint shyaml
####################
# Run NPM Installs #
####################
RUN npm config set package-lock false \
&& npm config set loglevel error \
&& npm -g --no-cache install \
markdownlint-cli \
jsonlint prettyjson \
@coffeelint/cli \
typescript eslint \
standard \
babel-eslint \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint-plugin-jest \
stylelint \
stylelint-config-standard \
@stoplight/spectral \
htmlhint \
&& npm --no-cache install \
markdownlint-cli \
jsonlint prettyjson \
@coffeelint/cli \
typescript eslint \
standard \
babel-eslint \
prettier \
eslint-config-prettier \
@typescript-eslint/eslint-plugin \
@typescript-eslint/parser \
eslint-plugin-jest \
stylelint \
stylelint-config-standard \
htmlhint
####################################
# Install dockerfilelint from repo #
####################################
RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfilelint && npm install
# I think we could fix this with path but not sure the language...
# https://github.com/nodejs/docker-node/blob/master/docs/BestPractices.md
####################
# Run GEM installs #
####################
RUN gem install rubocop:0.74.0 rubocop-rails rubocop-github:0.13.0
# Need to fix the version as it installs 'rubocop:0.85.1' as a dep, and forces the default
# We then need to promote the correct version, uninstall, and fix deps
RUN sh -c 'INCORRECT_VERSION=$(gem list rhc -e rubocop | grep rubocop | awk "{print $2}" | cut -d"(" -f2 | cut -d"," -f1); \
gem install --default rubocop:0.74.0; \
yes | gem uninstall rubocop:$INCORRECT_VERSION -a -x -I; \
gem install rubocop:0.74.0'
######################
# Install shellcheck #
######################
RUN wget -qO- "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" | tar -xJv \
&& mv "shellcheck-stable/shellcheck" /usr/bin/
COPY --from=koalaman/shellcheck:v0.7.1 /bin/shellcheck /usr/bin/
#####################
# Install Go Linter #
#####################
RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GO_VERSION"
COPY --from=golangci/golangci-lint:v1.27.0 /usr/bin/golangci-lint /usr/bin/
##################
# Install TFLint #
##################
RUN curl -Ls "$(curl -Ls https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" -o tflint.zip && unzip tflint.zip && rm tflint.zip \
&& mv "tflint" /usr/bin/
COPY --from=wata727/tflint:0.16.2 /usr/local/bin/tflint /usr/bin/
######################
# Install protolint #
######################
RUN curl -LsS "$(curl -Ls https://api.github.com/repos/yoheimuta/protolint/releases/latest | grep -o -E "https://.+?_Linux_x86_64.tar.gz")" -o protolint.tar.gz \
&& tar -xzf protolint.tar.gz \
&& rm protolint.tar.gz \
&& mv "protolint" /usr/bin/
COPY --from=yoheimuta/protolint:v0.25.1 /usr/local/bin/protolint /usr/bin/
#########################
# Install dotenv-linter #
#########################
RUN wget "https://github.com/dotenv-linter/dotenv-linter/releases/latest/download/dotenv-linter-alpine-x86_64.tar.gz" -O - -q | tar -xzf - \
&& mv "dotenv-linter" /usr/bin
COPY --from=dotenvlinter/dotenv-linter:2.0.0 /dotenv-linter /usr/bin/
#####################
# Install clj-kondo #
#####################
RUN curl -sLO https://github.com/borkdude/clj-kondo/releases/download/v${CLJ_KONDO_VERSION}/clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
&& unzip clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
&& rm clj-kondo-${CLJ_KONDO_VERSION}-linux-static-amd64.zip \
&& mv clj-kondo /usr/bin/
COPY --from=borkdude/clj-kondo:2020.06.21 /usr/local/bin/clj-kondo /usr/bin/
##################
# Install ktlint #
@ -206,11 +178,8 @@ RUN wget https://storage.googleapis.com/dart-archive/channels/stable/release/${D
################
# Install Raku #
################
# Environment
ENV PATH="$RAKU_INSTALL_PATH/share/perl6/site/bin:${PATH}"
# Basic setup, programs and init
RUN mkdir -p $RAKUBREW_HOME/bin \
&& curl -sSLo $RAKUBREW_HOME/bin/rakubrew https://rakubrew.org/perl/rakubrew \
@ -224,8 +193,7 @@ RUN mkdir -p $RAKUBREW_HOME/bin \
################################
# Install editorconfig-checker #
################################
RUN wget -qO- "https://github.com/editorconfig-checker/editorconfig-checker/releases/latest/download/ec-linux-amd64.tar.gz" | tar -xzf - \
&& mv "bin/ec-linux-amd64" /usr/bin/editorconfig-checker
COPY --from=mstruebing/editorconfig-checker:2.1.0 /usr/bin/ec /usr/bin/editorconfig-checker
###########################################
# Load GitHub Env Vars for GitHub Actions #
@ -257,6 +225,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \
VALIDATE_CSS=${VALIDATE_CSS} \
VALIDATE_ENV=${VALIDATE_ENV} \
VALIDATE_HTML=${VALIDATE_HTML} \
VALIDATE_CLOJURE=${VALIDATE_CLOJURE} \
VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \
VALIDATE_DART=${VALIDATE_DART} \
@ -269,7 +238,10 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
RUN_LOCAL=${RUN_LOCAL} \
TEST_CASE_RUN=${TEST_CASE_RUN} \
ACTIONS_RUNNER_DEBUG=${ACTIONS_RUNNER_DEBUG} \
DISABLE_ERRORS=${DISABLE_ERRORS}
DISABLE_ERRORS=${DISABLE_ERRORS} \
OUTPUT_FORMAT=${OUTPUT_FORMAT} \
OUTPUT_FOLDER=${OUTPUT_FOLDER} \
OUTPUT_DETAILS=${OUTPUT_DETAILS}
#############################
# Copy scripts to container #

View file

@ -16,8 +16,7 @@ The end goal of this tool:
- [Environment variables](#environment-variables)
- [Disable rules](#disabling-rules)
- [Docker Hub](#docker-hub)
- [Run Super-Linter locally](#running-super-linter-locally-troubleshootingdebuggingenhancements)
- [CI / CT/ CD](#cictcd)
- [Run Super-Linter outside GitHub Actions](#run-super-linter-outside-github-actions)
- [Limitations](#limitations)
- [Contributing](#how-to-contribute)
@ -137,7 +136,7 @@ jobs:
...
```
**NOTE:**
**NOTE:**
Using the line:`uses: docker://github/super-linter:v3` will pull the image down from **DockerHub** and run the **GitHub Super-Linter**. Using the line: `uses: github/super-linter@v3` will build and compile the **GitHub Super-Linter** at build time. *This can be far more costly in time...*
## Environment variables
@ -171,6 +170,8 @@ and won't run anything unexpected.
| **VALIDATE_JAVASCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
| **JAVASCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)|
| **VALIDATE_JAVASCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
| **VALIDATE_JSX** | `true` | Flag to enable or disable the linting process for jsx files (Utilizing: eslint) |
| **VALIDATE_TSX** | `true` | Flag to enable or disable the linting process for tsx files (Utilizing: eslint) |
| **VALIDATE_TYPESCRIPT_ES** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: eslint) |
| **TYPESCRIPT_ES_CONFIG_FILE** | `.eslintrc.yml` | Filename for [eslint configuration](https://eslint.org/docs/user-guide/configuring#configuration-file-formats) (ex: `.eslintrc.yml`, `.eslintrc.json`)|
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
@ -193,6 +194,10 @@ and won't run anything unexpected.
| **ACTIONS_RUNNER_DEBUG** | `false` | Flag to enable additional information about the linter, versions, and additional output. |
| **DISABLE_ERRORS** | `false` | Flag to have the linter complete with exit code 0 even if errors were detected. |
| **DEFAULT_WORKSPACE** | `/tmp/lint` | The location containing files to lint if you are running locally. |
| **OUTPUT_FORMAT** | `none` | The report format to be generated, besides the stdout one. Output format of tap is currently using v13 of the specification. Supported formats: tap |
| **OUTPUT_FOLDER** | `super-linter.report` | The location where the output reporting will be generated to. Output folder must not previously exist. |
| **OUTPUT_DETAILS** | `simpler` | What level of details to be reported. Supported formats: simpler or detailed. |
### Template rules files
You can use the **GitHub** **Super-Linter** *with* or *without* your own personal rules sets. This allows for greater flexibility for each individual code base. The Template rules all try to follow the standards we believe should be enabled at the basic level.
@ -205,19 +210,23 @@ If you need to disable certain *rules* and *functionality*, you can view [Disabl
## Docker Hub
The **Docker** container that is built from this repository is located at `https://hub.docker.com/r/github/super-linter`
## Running Super-Linter locally (troubleshooting/debugging/enhancements)
## Run Super-Linter outside GitHub Actions
### Local (troubleshooting/debugging/enhancements)
If you find that you need to run super-linter locally, you can follow the documentation at [Running super-linter locally](https://github.com/github/super-linter/blob/master/docs/run-linter-locally.md)
Check out the [note](#how-it-works) in **How it Works** to understand more about the **Super-Linter** linting locally versus via continuous integration.
### CI/CT/CD
The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions.
- When a branch is created and code is pushed, a **GitHub** Action is triggered for building the new **Docker** container with the new codebase
- The **Docker** container is then ran against the *test cases* to validate all code sanity
- `.automation/test` contains all test cases for each language that should be validated
- These **GitHub** Actions utilize the Checks API and Protected Branches to help follow the SDLC
- When the Pull Request is merged to master, the **Super-Linter** **Docker** container is then updated and deployed with the new codebase
- **Note:** The branch's **Docker** container is also removed from **DockerHub** to cleanup after itself
### Azure
Check out this [article](http://blog.tyang.org/2020/06/27/use-github-super-linter-in-azure-pipelines/)
### GitLab
Check out this [snippet](https://gitlab.com/snippets/1988376)
### Visual Studio Code
You can checkout this repository using [Container Remote Development](https://code.visualstudio.com/docs/remote/containers), and debug the linter using the `Test Linter` task.
![Example](https://user-images.githubusercontent.com/15258962/85165778-2d2ce700-b21b-11ea-803e-3f6709d8e609.gif)
We will also support [Github Codespaces](https://github.com/features/codespaces/) once it becomes available
## Limitations
Below are a list of the known limitations for the **GitHub Super-Linter**:
@ -228,12 +237,6 @@ Below are a list of the known limitations for the **GitHub Super-Linter**:
## How to contribute
If you would like to help contribute to this **GitHub** Action, please see [CONTRIBUTING](https://github.com/github/super-linter/blob/master/.github/CONTRIBUTING.md)
### Visual Studio Code
You can checkout this repository using [Container Remote Development](https://code.visualstudio.com/docs/remote/containers), and debug the linter using the `Test Linter` task.
![Example](https://user-images.githubusercontent.com/15258962/85165778-2d2ce700-b21b-11ea-803e-3f6709d8e609.gif)
We will also support [Github Codespaces](https://github.com/features/codespaces/) once it becomes available
--------------------------------------------------------------------------------
### License

16
dependencies/Pipfile vendored Normal file
View file

@ -0,0 +1,16 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
yamllint = "*"
pylint = "*"
yq = "*"
cfn-lint = "*"
shyaml = "*"
[requires]
python_version = "3.8"

290
dependencies/Pipfile.lock generated vendored Normal file
View file

@ -0,0 +1,290 @@
{
"_meta": {
"hash": {
"sha256": "f8d7f08c1efbacea7c92868babd54bc040413f865e3cd7ea8d4bebab310b3da3"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"argcomplete": {
"hashes": [
"sha256:5ae7b601be17bf38a749ec06aa07fb04e7b6b5fc17906948dc1866e7facf3740",
"sha256:890bdd1fcbb973ed73db241763e78b6d958580e588c2910b508c770a59ef37d7"
],
"version": "==1.11.1"
},
"astroid": {
"hashes": [
"sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703",
"sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386"
],
"markers": "python_version >= '3.5'",
"version": "==2.4.2"
},
"attrs": {
"hashes": [
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
"sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==19.3.0"
},
"aws-sam-translator": {
"hashes": [
"sha256:33c5e9a04584a88b2dc730991f7aea52acc4a077a194444e16728dd2be997dc0",
"sha256:5b31769d271fa6c7e87cde076ce819f9f9c7da324b3880f2cd0f5f5aa837e520",
"sha256:f2d0585fc7dd071f136b543e9a614945cb80bbd3113a25f260797c126456dd25"
],
"version": "==1.25.0"
},
"boto3": {
"hashes": [
"sha256:c2a223f4b48782e8b160b2130265e2a66081df111f630a5a384d6909e29a5aa9",
"sha256:ce5a4ab6af9e993d1864209cbbb6f4812f65fbc57ad6b95e5967d8bf38b1dcfb"
],
"version": "==1.14.16"
},
"botocore": {
"hashes": [
"sha256:99d995ef99cf77458a661f3fc64e0c3a4ce77ca30facfdf0472f44b2953dd856",
"sha256:fe0c4f7cd6b67eff3b7cb8dff6709a65d6fca10b7b7449a493b2036915e98b4c"
],
"version": "==1.17.16"
},
"cfn-lint": {
"hashes": [
"sha256:b29d172a0910f305162e354fd421594ab575ace6431b7b8884c245dfc5064859",
"sha256:ff9b566bda43a2e74fdd89b57cbf0f76e209e4e666cc4babe7c96cbd3fb56bfe"
],
"index": "pypi",
"version": "==0.33.2"
},
"decorator": {
"hashes": [
"sha256:41fa54c2a0cc4ba648be4fd43cff00aedf5b9465c9bf18d64325bc225f08f760",
"sha256:e3a62f0520172440ca0dcc823749319382e377f37f140a0b99ef45fecb84bfe7"
],
"version": "==4.4.2"
},
"docutils": {
"hashes": [
"sha256:6c4f696463b79f1fb8ba0c594b63840ebd41f059e92b31957c46b74a4599b6d0",
"sha256:9e4d7ecfc600058e07ba661411a2b7de2fd0fafa17d1a7f7361cd47b1175c827",
"sha256:a2aeea129088da402665e92e0b25b04b073c04b2dce4ab65caaa38b7ce2e1a99"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.15.2"
},
"isort": {
"hashes": [
"sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1",
"sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==4.3.21"
},
"jmespath": {
"hashes": [
"sha256:b85d0567b8666149a93172712e68920734333c0ce7e89b78b3e987f71e5ed4f9",
"sha256:cdf6525904cc597730141d61b36f2e4b8ecc257c420fa2f4549bac2c2d0cb72f"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.0"
},
"jsonpatch": {
"hashes": [
"sha256:83ff23119b336ea2feffa682307eb7269b58097b4e88c089a4950d946442db16",
"sha256:e45df18b0ab7df1925f20671bbc3f6bd0b4b556fb4b9c5d97684b0a7eac01744"
],
"markers": "python_version != '3.4'",
"version": "==1.26"
},
"jsonpointer": {
"hashes": [
"sha256:c192ba86648e05fdae4f08a17ec25180a9aef5008d973407b581798a83975362",
"sha256:ff379fa021d1b81ab539f5ec467c7745beb1a5671463f9dcc2b2d458bd361c1e"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.0"
},
"jsonschema": {
"hashes": [
"sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163",
"sha256:c8a85b28d377cc7737e46e2d9f2b4f44ee3c0e1deac6bf46ddefc7187d30797a"
],
"version": "==3.2.0"
},
"junit-xml": {
"hashes": [
"sha256:ec5ca1a55aefdd76d28fcc0b135251d156c7106fa979686a4b48d62b761b4732"
],
"version": "==1.9"
},
"lazy-object-proxy": {
"hashes": [
"sha256:0c4b206227a8097f05c4dbdd323c50edf81f15db3b8dc064d08c62d37e1a504d",
"sha256:194d092e6f246b906e8f70884e620e459fc54db3259e60cf69a4d66c3fda3449",
"sha256:1be7e4c9f96948003609aa6c974ae59830a6baecc5376c25c92d7d697e684c08",
"sha256:4677f594e474c91da97f489fea5b7daa17b5517190899cf213697e48d3902f5a",
"sha256:48dab84ebd4831077b150572aec802f303117c8cc5c871e182447281ebf3ac50",
"sha256:5541cada25cd173702dbd99f8e22434105456314462326f06dba3e180f203dfd",
"sha256:59f79fef100b09564bc2df42ea2d8d21a64fdcda64979c0fa3db7bdaabaf6239",
"sha256:8d859b89baf8ef7f8bc6b00aa20316483d67f0b1cbf422f5b4dc56701c8f2ffb",
"sha256:9254f4358b9b541e3441b007a0ea0764b9d056afdeafc1a5569eee1cc6c1b9ea",
"sha256:9651375199045a358eb6741df3e02a651e0330be090b3bc79f6d0de31a80ec3e",
"sha256:97bb5884f6f1cdce0099f86b907aa41c970c3c672ac8b9c8352789e103cf3156",
"sha256:9b15f3f4c0f35727d3a0fba4b770b3c4ebbb1fa907dbcc046a1d2799f3edd142",
"sha256:a2238e9d1bb71a56cd710611a1614d1194dc10a175c1e08d75e1a7bcc250d442",
"sha256:a6ae12d08c0bf9909ce12385803a543bfe99b95fe01e752536a60af2b7797c62",
"sha256:ca0a928a3ddbc5725be2dd1cf895ec0a254798915fb3a36af0964a0a4149e3db",
"sha256:cb2c7c57005a6804ab66f106ceb8482da55f5314b7fcb06551db1edae4ad1531",
"sha256:d74bb8693bf9cf75ac3b47a54d716bbb1a92648d5f781fc799347cfc95952383",
"sha256:d945239a5639b3ff35b70a88c5f2f491913eb94871780ebfabb2568bd58afc5a",
"sha256:eba7011090323c1dadf18b3b689845fd96a61ba0a1dfbd7f24b921398affc357",
"sha256:efa1909120ce98bbb3777e8b6f92237f5d5c8ea6758efea36a473e1d38f7d3e4",
"sha256:f3900e8a5de27447acbf900b4750b0ddfd7ec1ea7fbaf11dfa911141bc522af0"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.4.3"
},
"mccabe": {
"hashes": [
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
],
"version": "==0.6.1"
},
"networkx": {
"hashes": [
"sha256:cdfbf698749a5014bf2ed9db4a07a5295df1d3a53bf80bf3cbd61edf9df05fa1",
"sha256:f8f4ff0b6f96e4f9b16af6b84622597b5334bf9cae8cf9b2e42e7985d5c95c64"
],
"markers": "python_version >= '3.5'",
"version": "==2.4"
},
"pathspec": {
"hashes": [
"sha256:7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0",
"sha256:da45173eb3a6f2a5a487efba21f050af2b41948be6ab52b6a1e3ff22bb8b7061"
],
"version": "==0.8.0"
},
"pylint": {
"hashes": [
"sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc",
"sha256:d0ece7d223fe422088b0e8f13fa0a1e8eb745ebffcb8ed53d3e95394b6101a1c"
],
"index": "pypi",
"version": "==2.5.3"
},
"pyrsistent": {
"hashes": [
"sha256:28669905fe725965daa16184933676547c5bb40a5153055a8dee2a4bd7933ad3"
],
"version": "==0.16.0"
},
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
"sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.8.1"
},
"pyyaml": {
"hashes": [
"sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97",
"sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76",
"sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2",
"sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648",
"sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf",
"sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f",
"sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2",
"sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee",
"sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d",
"sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c",
"sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"
],
"markers": "python_version != '3.4'",
"version": "==5.3.1"
},
"s3transfer": {
"hashes": [
"sha256:2482b4259524933a022d59da830f51bd746db62f047d6eb213f2f8855dcb8a13",
"sha256:921a37e2aefc64145e7b73d50c71bb4f26f46e4c9f414dc648c6245ff92cf7db"
],
"version": "==0.3.3"
},
"shyaml": {
"hashes": [
"sha256:3a57e380f66043c661d417106a0f101f8068c80caa2afef57c90447b88526c3d",
"sha256:ac9066eed5b8445de1f83a99106ca96a77900b6873de327fd50d3e3102084752"
],
"index": "pypi",
"version": "==0.6.1"
},
"six": {
"hashes": [
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.15.0"
},
"toml": {
"hashes": [
"sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f",
"sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"
],
"version": "==0.10.1"
},
"urllib3": {
"hashes": [
"sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
],
"markers": "python_version != '3.4'",
"version": "==1.25.9"
},
"wrapt": {
"hashes": [
"sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
],
"version": "==1.12.1"
},
"xmltodict": {
"hashes": [
"sha256:50d8c638ed7ecb88d90561beedbf720c9b4e851a9fa6c47ebd64e99d166d8a21",
"sha256:8bbcb45cc982f48b2ca8fe7e7827c5d792f217ecf1792626f808bf41c3b86051"
],
"version": "==0.12.0"
},
"yamllint": {
"hashes": [
"sha256:0fa69bf8a86182b7fe14918bdd3a30354c869966bbc7cbfff176af71bda9c806",
"sha256:59f3ff77f44e7f46be6aecdb985830f73a1c51e290b7082a7d38c2ae1940f4a9"
],
"index": "pypi",
"version": "==1.23.0"
},
"yq": {
"hashes": [
"sha256:a876304f2b360a968023eb7d13ec669e102fd381c818783e88e475bd2638d278",
"sha256:f6252a0757d0c2a9e55b4402e176a7e41a99e0e6dd5be4f9d5a4d651eeb4d6c0"
],
"index": "pypi",
"version": "==2.10.1"
}
},
"develop": {}
}

5455
dependencies/package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load diff

23
dependencies/package.json vendored Normal file
View file

@ -0,0 +1,23 @@
{
"name": "super-linter",
"dependencies": {
"@coffeelint/cli": "^3.2.9",
"@stoplight/spectral": "^5.4.0",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"babel-eslint": "^10.1.0",
"dockerfilelint": "^1.5.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.18.0",
"htmlhint": "^0.14.1",
"jsonlint": "^1.6.3",
"markdownlint-cli": "^0.23.2",
"prettier": "^2.0.5",
"prettyjson": "^1.2.1",
"standard": "^14.3.4",
"stylelint": "^13.6.1",
"stylelint-config-standard": "^20.0.0",
"typescript": "^3.9.6"
}
}

View file

@ -284,6 +284,33 @@ function BuildFileList() {
##########################################################
READ_ONLY_CHANGE_FLAG=1
############################
# Get the JSX files #
############################
elif [ "$FILE_TYPE" == "jsx" ]; then
################################
# Append the file to the array #
################################
FILE_ARRAY_JSX+=("$FILE")
##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
##########################################################
READ_ONLY_CHANGE_FLAG=1
############################
# Get the TSX files #
############################
elif [ "$FILE_TYPE" == "tsx" ]; then
################################
# Append the file to the array #
################################
FILE_ARRAY_TSX+=("$FILE")
##########################################################
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
##########################################################
READ_ONLY_CHANGE_FLAG=1
########################
# Get the Golang files #
########################
############################
# Get the TypeScript files #
############################
elif [ "$FILE_TYPE" == "ts" ]; then

View file

@ -92,7 +92,7 @@ HTML_LINTER_RULES="$DEFAULT_RULES_LOCATION/$HTML_FILE_NAME" # Path t
#######################################
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
"pylint" "perl" "raku" "rubocop" "coffeelint" "eslint" "standard"
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint"
"ansible-lint" "dockerfilelint" "golangci-lint" "tflint"
"stylelint" "dotenv-linter" "pwsh" "arm-ttk" "ktlint" "protolint" "clj-kondo"
"spectral" "cfn-lint" "dart" "htmlhint")
@ -100,7 +100,7 @@ LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
# Language array for prints #
#############################
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RAKU' 'PHP' 'RUBY' 'PYTHON'
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES' 'JSX' 'TSX'
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM'
'CSS' 'ENV' 'POWERSHELL' 'ARM' 'KOTLIN' 'PROTOBUF' 'CLOJURE' 'OPENAPI'
'CFN' 'DART' 'HTML')
@ -129,6 +129,8 @@ VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to vali
VALIDATE_ANSIBLE="${VALIDATE_ANSIBLE}" # Boolean to validate language
VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to validate language
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
VALIDATE_JSX="${VALIDATE_JSX}" # Boolean to validate jsx files
VALIDATE_TSX="${VALIDATE_TSX}" # Boolean to validate tsx files
VALIDATE_TYPESCRIPT_ES="${VALIDATE_TYPESCRIPT_ES}" # Boolean to validate language
VALIDATE_TYPESCRIPT_STANDARD="${VALIDATE_TYPESCRIPT_STANDARD}" # Boolean to validate language
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
@ -176,6 +178,14 @@ echo "${TEST_CASE_FOLDER}" > /dev/null 2>&1 || true # Workaround SC2034
DEFAULT_ANSIBLE_DIRECTORY="$GITHUB_WORKSPACE/ansible" # Default Ansible Directory
echo "${DEFAULT_ANSIBLE_DIRECTORY}" > /dev/null 2>&1 || true # Workaround SC2034
##############
# Format #
##############
OUTPUT_FORMAT="${OUTPUT_FORMAT}" # Output format to be generated. Default none
OUTPUT_FOLDER="${OUTPUT_FOLDER:-super-linter.report}" # Folder where the reports are generated. Default super-linter.report
OUTPUT_DETAILS="${OUTPUT_DETAILS:-simpler}" # What level of details. (simpler or detailed). Default simpler
REPORT_OUTPUT_FOLDER="${DEFAULT_WORKSPACE}/${OUTPUT_FOLDER}"
##########################
# Array of changed files #
##########################
@ -193,6 +203,8 @@ FILE_ARRAY_CFN=() # Array of files to check
FILE_ARRAY_COFFEESCRIPT=() # Array of files to check
FILE_ARRAY_JAVASCRIPT_ES=() # Array of files to check
FILE_ARRAY_JAVASCRIPT_STANDARD=() # Array of files to check
FILE_ARRAY_JSX=() # Array of files to check
FILE_ARRAY_TSX=() # Array of files to check
FILE_ARRAY_TYPESCRIPT_ES=() # Array of files to check
FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check
FILE_ARRAY_DOCKER=() # Array of files to check
@ -227,6 +239,8 @@ ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
ERRORS_FOUND_ANSIBLE=0 # Count of errors found
ERRORS_FOUND_JAVASCRIPT_STANDARD=0 # Count of errors found
ERRORS_FOUND_JAVASCRIPT_ES=0 # Count of errors found
ERRORS_FOUND_JSX=0 # Count of errors found
ERRORS_FOUND_TSX=0 # Count of errors found
ERRORS_FOUND_TYPESCRIPT_STANDARD=0 # Count of errors found
ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found
ERRORS_FOUND_DOCKER=0 # Count of errors found
@ -745,6 +759,13 @@ Footer() {
echo "----------------------------------------------"
echo ""
###################################
# Prints output report if enabled #
###################################
if [ -z "${FORMAT_REPORT}" ] ; then
echo "Reports generated in folder ${REPORT_OUTPUT_FOLDER}"
fi
##############################
# Prints for errors if found #
##############################
@ -785,6 +806,8 @@ Footer() {
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_JAVASCRIPT_STANDARD" -ne 0 ] ||
[ "$ERRORS_FOUND_JSX" -ne 0 ] ||
[ "$ERRORS_FOUND_TSX" -ne 0 ] ||
[ "$ERRORS_FOUND_TYPESCRIPT_ES" -ne 0 ] ||
[ "$ERRORS_FOUND_TYPESCRIPT_STANDARD" -ne 0 ] ||
[ "$ERRORS_FOUND_DOCKER" -ne 0 ] ||
@ -827,6 +850,17 @@ Footer() {
##########
Header
##############################################################
# check flag for validating the report folder does not exist #
##############################################################
if [ -n "${OUTPUT_FORMAT}" ]; then
if [ -d "${REPORT_OUTPUT_FOLDER}" ] ; then
echo "ERROR! Found ${REPORT_OUTPUT_FOLDER}"
echo "Please remove the folder and try again."
exit 1
fi
fi
#######################
# Get GitHub Env Vars #
#######################
@ -1105,6 +1139,27 @@ if [ "$VALIDATE_JAVASCRIPT_STANDARD" == "true" ]; then
LintCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "${FILE_ARRAY_JAVASCRIPT_STANDARD[@]}"
fi
######################
# JSX LINTING #
######################
if [ "$VALIDATE_JSX" == "true" ]; then
#############################
# Lint the JSX files #
#############################
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
LintCodebase "JSX" "eslint" "eslint --no-eslintrc -c $JAVASCRIPT_LINTER_RULES" ".*\.\(jsx\)\$" "${FILE_ARRAY_JSX[@]}"
fi
######################
# TSX LINTING #
######################
if [ "$VALIDATE_TSX" == "true" ]; then
#############################
# Lint the TSX files #
#############################
LintCodebase "TSX" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(tsx\)\$" "${FILE_ARRAY_TSX[@]}"
fi
######################
# TYPESCRIPT LINTING #
######################
@ -1168,7 +1223,6 @@ fi
########################
# EDITORCONFIG LINTING #
########################
echo ed: "$VALIDATE_EDITORCONFIG"
if [ "$VALIDATE_EDITORCONFIG" == "true" ]; then
####################################
# Lint the files with editorconfig #
@ -1196,7 +1250,8 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then
# Lint the docker files #
#########################
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
# NOTE: dockerfilelint's "-c" option expects the folder *containing* the DOCKER_LINTER_RULES file
LintCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $(dirname $DOCKER_LINTER_RULES)" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
fi
###################

0
lib/termColors.sh Normal file → Executable file
View file

View file

@ -60,6 +60,8 @@ function GetValidationInfo() {
VALIDATE_ANSIBLE=$(echo "$VALIDATE_ANSIBLE" | awk '{print tolower($0)}')
VALIDATE_JAVASCRIPT_ES=$(echo "$VALIDATE_JAVASCRIPT_ES" | awk '{print tolower($0)}')
VALIDATE_JAVASCRIPT_STANDARD=$(echo "$VALIDATE_JAVASCRIPT_STANDARD" | awk '{print tolower($0)}')
VALIDATE_JSX=$(echo "$VALIDATE_JSX" | awk '{print tolower($0)}')
VALIDATE_TSX=$(echo "$VALIDATE_TSX" | awk '{print tolower($0)}')
VALIDATE_TYPESCRIPT_ES=$(echo "$VALIDATE_TYPESCRIPT_ES" | awk '{print tolower($0)}')
VALIDATE_TYPESCRIPT_STANDARD=$(echo "$VALIDATE_TYPESCRIPT_STANDARD" | awk '{print tolower($0)}')
VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}')
@ -310,6 +312,34 @@ function GetValidationInfo() {
VALIDATE_JAVASCRIPT_STANDARD="true"
fi
#############################################
# Validate if we should check JSX #
#############################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_JSX ]]; then
# JSX flag was not set - default to false
VALIDATE_JSX="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_JSX="true"
fi
#############################################
# Validate if we should check TSX #
#############################################
if [[ $ANY_SET == "true" ]]; then
# Some linter flags were set - only run those set to true
if [[ -z $VALIDATE_TSX ]]; then
# TSX flag was not set - default to false
VALIDATE_TSX="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_TSX="true"
fi
#############################################
# Validate if we should check TYPESCRIPT_ES #
#############################################
@ -516,10 +546,13 @@ function GetValidationInfo() {
VALIDATE_EDITORCONFIG="false"
fi
else
# No linter flags were set - default all to true
VALIDATE_EDITORCONFIG="true"
# No linter flags were set
# special case checking for .editorconfig
if [ -f "$GITHUB_WORKSPACE/.editorconfig" ]; then
VALIDATE_EDITORCONFIG="true"
fi
fi
####################################
# Validate if we should check HTML #
####################################

View file

@ -124,6 +124,16 @@ function LintCodebase() {
echo "$LINE"
done
########################################
# Prepare context if TAP format output #
########################################
if IsTAP ; then
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
INDEX=0
mkdir -p "${REPORT_OUTPUT_FOLDER}"
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
fi
##################
# Lint the files #
##################
@ -142,8 +152,16 @@ function LintCodebase() {
elif [[ $FILE == *"$TEST_CASE_FOLDER"* ]]; then
# This is the test cases, we should always skip
continue
elif [[ $FILE == *".git"* ]]; then
# This is likely the .git folder and shouldnt be parsed
continue
fi
##################################
# Increase the linted file index #
##################################
(("INDEX++"))
##############
# File print #
##############
@ -196,13 +214,42 @@ function LintCodebase() {
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
# Increment the error count
(("ERRORS_FOUND_$FILE_TYPE++"))
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if IsTAP ; then
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
##########################################
# Report the detailed message if enabled #
##########################################
DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD")
if [ -n "${DETAILED_MSG}" ] ; then
printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${TMPFILE}"
fi
fi
else
###########
# Success #
###########
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if IsTAP ; then
echo "ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
fi
fi
done
#################################
# Generate report in TAP format #
#################################
if IsTAP && [ ${INDEX} -gt 0 ] ; then
printf "TAP version 13\n1..%s\n" "${INDEX}" > "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
fi
fi
}
################################################################################
@ -467,7 +514,7 @@ function RunTestCases() {
TestCodebase "JAVASCRIPT_STANDARD" "standard" "standard $JAVASCRIPT_STANDARD_LINTER_RULES" ".*\.\(js\)\$" "javascript"
TestCodebase "TYPESCRIPT_ES" "eslint" "eslint --no-eslintrc -c $TYPESCRIPT_LINTER_RULES" ".*\.\(ts\)\$" "typescript"
TestCodebase "TYPESCRIPT_STANDARD" "standard" "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin $TYPESCRIPT_STANDARD_LINTER_RULES" ".*\.\(ts\)\$" "typescript"
TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "docker"
TestCodebase "DOCKER" "dockerfilelint" "dockerfilelint -c $DOCKER_LINTER_RULES" ".*\(Dockerfile\)\$" "docker"
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" ".*\.\(yml\|yaml\)\$" "ansible"
TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$" "terraform"
TestCodebase "CFN" "cfn-lint" "cfn-lint --config-file $CFN_LINTER_RULES" ".*\.\(json\|yml\|yaml\)\$" "cfn"
@ -590,6 +637,16 @@ function LintAnsibleFiles() {
done
fi
########################################
# Prepare context if TAP output format #
########################################
if IsTAP ; then
TMPFILE=$(mktemp -q "/tmp/super-linter-${FILE_TYPE}.XXXXXX")
INDEX=0
mkdir -p "${REPORT_OUTPUT_FOLDER}"
REPORT_OUTPUT_FILE="${REPORT_OUTPUT_FOLDER}/super-linter-${FILE_TYPE}.${OUTPUT_FORMAT}"
fi
##################
# Lint the files #
##################
@ -603,6 +660,11 @@ function LintAnsibleFiles() {
continue
fi
##################################
# Increase the linted file index #
##################################
(("INDEX++"))
####################
# Get the filename #
####################
@ -635,13 +697,43 @@ function LintAnsibleFiles() {
echo -e "${NC}${B[R]}${F[W]}ERROR:${NC}[$LINT_CMD]${NC}"
# Increment error count
((ERRORS_FOUND_ANSIBLE++))
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if IsTAP ; then
echo "not ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
##########################################
# Report the detailed message if enabled #
##########################################
DETAILED_MSG=$(TransformTAPDetails "$LINT_CMD")
if [ -n "${DETAILED_MSG}" ] ; then
printf " ---\n message: %s\n ...\n" "$DETAILED_MSG" >> "${TMPFILE}"
fi
fi
else
###########
# Success #
###########
echo -e "${NC}${F[B]} - File:${F[W]}[$FILE_NAME]${F[B]} was linted with ${F[W]}[$LINTER_NAME]${F[B]} successfully${NC}"
#######################################################
# Store the linting as a temporary file in TAP format #
#######################################################
if IsTAP ; then
echo "ok ${INDEX} - ${FILE}" >> "${TMPFILE}"
fi
fi
done
#################################
# Generate report in TAP format #
#################################
if IsTAP && [ ${INDEX} -gt 0 ] ; then
printf "TAP version 13\n1..%s\n" "${INDEX}" > "${REPORT_OUTPUT_FILE}"
cat "${TMPFILE}" >> "${REPORT_OUTPUT_FILE}"
fi
else # No ansible directory found in path
###############################
# Check to see if debug is on #
@ -655,3 +747,23 @@ function LintAnsibleFiles() {
fi
fi
}
################################################################################
#### Function IsTap ############################################################
function IsTAP() {
if [ "${OUTPUT_FORMAT}" == "tap" ] ; then
return 0
else
return 1
fi
}
################################################################################
#### Function TransformTAPDetails ##############################################
function TransformTAPDetails() {
DATA=$1
if [ -n "${DATA}" ] && [ "${OUTPUT_DETAILS}" == "detailed" ] ; then
#########################################################
# Transform new lines to \\n, remove colours and colons #
#########################################################
echo "${DATA}" | awk 'BEGIN{RS="\n";ORS="\\n"}1' | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | tr ':' ' '
fi
}