mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-25 07:31:05 -05:00
Merge branch 'master' into linterRules
This commit is contained in:
commit
7c3fb97793
31 changed files with 420 additions and 68 deletions
|
@ -115,9 +115,9 @@ ValidateInput()
|
|||
# Check if we need to get the name of the branch #
|
||||
##################################################
|
||||
if [[ "$IMAGE_VERSION" != "latest" ]]; then
|
||||
###################################
|
||||
# Remove non alpha-numberic chars #
|
||||
###################################
|
||||
##################################
|
||||
# Remove non alpha-numeric chars #
|
||||
##################################
|
||||
IMAGE_VERSION=$(echo "$IMAGE_VERSION" | tr -cd '[:alnum:]')
|
||||
else
|
||||
#############################################
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
group: admin
|
||||
mode: 0644
|
||||
|
||||
#########################################################
|
||||
# Set up Admin password, License, and Initial Setttings #
|
||||
#########################################################
|
||||
########################################################
|
||||
# Set up Admin password, License, and Initial Settings #
|
||||
########################################################
|
||||
- name: Setup Grafana
|
||||
# yamllint disable
|
||||
shell: curl --fail -Lk \
|
||||
|
|
|
@ -57,10 +57,10 @@
|
|||
group: admin
|
||||
mode: 0644
|
||||
|
||||
#########################################################
|
||||
# Set up Admin password, License, and Initial Setttings #
|
||||
#########################################################
|
||||
- name: Setup License, Admin Password, and Initial Setttings
|
||||
########################################################
|
||||
# Set up Admin password, License, and Initial Settings #
|
||||
########################################################
|
||||
- name: Setup License, Admin Password, and Initial Settings
|
||||
command: curl --fail -Lk \
|
||||
-X POST "https://{{ ansible_host }}:8443/setup/api/start" \
|
||||
-F license=@/tmp/ghe-license.ghl \
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
group: admin
|
||||
mode: 0644
|
||||
|
||||
#########################################################
|
||||
# Set up Admin password, License, and Initial Setttings #
|
||||
#########################################################
|
||||
########################################################
|
||||
# Set up Admin password, License, and Initial Settings #
|
||||
########################################################
|
||||
- name: Setup Splunk
|
||||
# yamllint disable
|
||||
shell: curl --fail -Lk \
|
||||
|
|
|
@ -60,7 +60,7 @@ module.exports = (robot) -> )
|
|||
# Drop the hammer #
|
||||
###################
|
||||
robot.respond /drop the hammer/i, (msg) ->
|
||||
msg.send "Commmencing the hammer dropping..."
|
||||
msg.send "Commencing the hammer dropping..."
|
||||
msg.send msg.random dropHammer
|
||||
|
||||
###############
|
||||
|
|
|
@ -62,7 +62,7 @@ module.exports = (robot) ->
|
|||
# Drop the hammer #
|
||||
###################
|
||||
robot.respond /drop the hammer/i, (msg) ->
|
||||
msg.send "Commmencing the hammer dropping..."
|
||||
msg.send "Commencing the hammer dropping..."
|
||||
msg.send msg.random dropHammer
|
||||
|
||||
###############
|
||||
|
|
|
@ -7,7 +7,7 @@ var userArray = [ 'user1' ]
|
|||
here is some garbage = that
|
||||
|
||||
var teamDescription = Team of Robots
|
||||
var teamPrivacy = 'closed' // closed (visibile) / secret (hidden) are options here
|
||||
var teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here
|
||||
|
||||
var teamName = process.env.GHES_TEAM_NAME
|
||||
var teamAccess = 'pull' // pull,push,admin options here
|
||||
|
|
|
@ -5,7 +5,7 @@ var handler = createHandler({ path: '/webhook', secret: (process.env.SECRET) })
|
|||
var userArray = ['user1']
|
||||
|
||||
var teamDescription = 'Team of Robots'
|
||||
var teamPrivacy = 'closed' // closed (visibile) / secret (hidden) are options here
|
||||
var teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here
|
||||
|
||||
var teamName = process.env.GHES_TEAM_NAME
|
||||
var teamAccess = 'pull' // pull,push,admin options here
|
||||
|
|
13
.automation/test/kotlin/README.md
Normal file
13
.automation/test/kotlin/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Kotlin Test Cases
|
||||
This folder holds the test cases for **Kotlin**.
|
||||
|
||||
## 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.
|
6
.automation/test/kotlin/kotlin_bad_1.kt
Normal file
6
.automation/test/kotlin/kotlin_bad_1.kt
Normal file
|
@ -0,0 +1,6 @@
|
|||
fun main() {
|
||||
val n = "World";
|
||||
val v = "Hello, ${n}!";
|
||||
|
||||
println(v);
|
||||
}
|
6
.automation/test/kotlin/kotlint_good_1.kt
Normal file
6
.automation/test/kotlin/kotlint_good_1.kt
Normal file
|
@ -0,0 +1,6 @@
|
|||
fun main() {
|
||||
val n = "World"
|
||||
val v = "Hello, $n!"
|
||||
|
||||
println(v)
|
||||
}
|
13
.automation/test/php/README.md
Normal file
13
.automation/test/php/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# PHP Test Cases
|
||||
This folder holds the test cases for **PHP**.
|
||||
|
||||
## 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.
|
3
.automation/test/php/php_bad_1.php
Normal file
3
.automation/test/php/php_bad_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29
|
3
.automation/test/php/php_good_1.php
Normal file
3
.automation/test/php/php_good_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo "Hello World!", PHP_EOL;
|
13
.automation/test/powershell/README.md
Normal file
13
.automation/test/powershell/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# PowerShell Test Cases
|
||||
This folder holds the test cases for **PowerShell**.
|
||||
|
||||
## 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.
|
14
.automation/test/powershell/powershell_bad_1.ps1
Normal file
14
.automation/test/powershell/powershell_bad_1.ps1
Normal file
|
@ -0,0 +1,14 @@
|
|||
#Plaintext Parameters
|
||||
function BadFunction {
|
||||
param(
|
||||
[String]$Username = 'me',
|
||||
[String]$Password = 'password'
|
||||
)
|
||||
$Username
|
||||
$Password
|
||||
$VariableThatIsNotUsedLater = '5'
|
||||
try {
|
||||
'Empty Catch Block'
|
||||
} catch {}
|
||||
}
|
||||
|
3
.automation/test/powershell/powershell_bad_1.psd1
Normal file
3
.automation/test/powershell/powershell_bad_1.psd1
Normal file
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
'Hello'='World
|
||||
}
|
1
.automation/test/powershell/powershell_bad_1.psm1
Normal file
1
.automation/test/powershell/powershell_bad_1.psm1
Normal file
|
@ -0,0 +1 @@
|
|||
Write-Output "hello world!
|
1
.automation/test/powershell/powershell_good_1.ps1
Normal file
1
.automation/test/powershell/powershell_good_1.ps1
Normal file
|
@ -0,0 +1 @@
|
|||
Write-Output "hello world!"
|
3
.automation/test/powershell/powershell_good_1.psd1
Normal file
3
.automation/test/powershell/powershell_good_1.psd1
Normal file
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
'Hello'='World'
|
||||
}
|
1
.automation/test/powershell/powershell_good_1.psm1
Normal file
1
.automation/test/powershell/powershell_good_1.psm1
Normal file
|
@ -0,0 +1 @@
|
|||
Write-Output "hello world!"
|
|
@ -120,9 +120,9 @@ ValidateInput()
|
|||
exit 1
|
||||
fi
|
||||
|
||||
###################################
|
||||
# Remove non alpha-numberic chars #
|
||||
###################################
|
||||
##################################
|
||||
# Remove non alpha-numeric chars #
|
||||
##################################
|
||||
BRANCH_NAME=$(echo "$BRANCH_NAME" | tr -cd '[:alnum:]')
|
||||
|
||||
############################################
|
||||
|
|
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
|
@ -1,4 +1,4 @@
|
|||
######################################################################
|
||||
# These owners will be the default owners for everything in the repo #
|
||||
######################################################################
|
||||
* @admiralawkbar @jwiebalk @zkoppert
|
||||
* @admiralawkbar @jwiebalk @zkoppert @IAmHughes
|
||||
|
|
8
.github/CONTRIBUTING.md
vendored
8
.github/CONTRIBUTING.md
vendored
|
@ -31,9 +31,11 @@ Draft pull requests are also welcome to get feedback early on, or if there is so
|
|||
|
||||
## Releasing
|
||||
If you are the current maintainer of this action:
|
||||
1. Update `README.md` to reflect new version number in the suggested workflow file section
|
||||
2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) document explaining details of Release
|
||||
3. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners)
|
||||
1. Update `README.md` and the wiki to reflect new version number in the example workflow file sections
|
||||
2. Draft [Release](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) with a summarized changelog
|
||||
3. Publish the docker image to GitHub package registry
|
||||
4. Publish the docker image to Docker Hub
|
||||
5. Look for approval from [CODEOWNERS](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners)
|
||||
|
||||
## Resources
|
||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
|
|
3
.github/ISSUE_TEMPLATE/feature_request.md
vendored
3
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -18,3 +18,6 @@ A clear and concise description of any alternative solutions or features you've
|
|||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
**Note**
|
||||
If this is a request to add a new language, after submitting this issue check out [the wiki](https://github.com/github/super-linter/wiki/Adding-new-language-support) for more info on how to accomplish that.
|
||||
|
|
2
.github/linters/.yaml-lint.yml
vendored
2
.github/linters/.yaml-lint.yml
vendored
|
@ -3,7 +3,7 @@
|
|||
# These are the rules used for #
|
||||
# linting all the yaml files in the stack #
|
||||
# NOTE: #
|
||||
# You can disble line with: #
|
||||
# You can disable line with: #
|
||||
# # yamllint disable-line #
|
||||
###########################################
|
||||
rules:
|
||||
|
|
42
Dockerfile
42
Dockerfile
|
@ -27,7 +27,27 @@ RUN apk add --no-cache \
|
|||
libxml2-utils perl \
|
||||
ruby ruby-dev ruby-bundler ruby-rdoc make \
|
||||
py3-setuptools ansible-lint \
|
||||
go
|
||||
go \
|
||||
openjdk8-jre \
|
||||
php7 \
|
||||
ca-certificates less ncurses-terminfo-base \
|
||||
krb5-libs libgcc libintl libssl1.1 libstdc++ \
|
||||
tzdata userspace-rcu zlib icu-libs lttng-ust
|
||||
|
||||
#########################################
|
||||
# Install Powershell + PSScriptAnalyzer #
|
||||
#########################################
|
||||
# Reference: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7
|
||||
# Slightly modified to always retrieve latest stable Powershell version
|
||||
RUN mkdir -p /opt/microsoft/powershell/7 \
|
||||
&& curl -s https://api.github.com/repos/powershell/powershell/releases/latest \
|
||||
| grep browser_download_url \
|
||||
| grep linux-alpine-x64 \
|
||||
| cut -d '"' -f 4 \
|
||||
| xargs -n 1 wget -O - \
|
||||
| tar -xzC /opt/microsoft/powershell/7 \
|
||||
&& ln -s /opt/microsoft/powershell/7/pwsh /usr/bin/pwsh \
|
||||
&& pwsh -c 'install-module psscriptanalyzer -force'
|
||||
|
||||
#####################
|
||||
# Run Pip3 Installs #
|
||||
|
@ -81,8 +101,11 @@ RUN git clone https://github.com/replicatedhq/dockerfilelint.git && cd /dockerfi
|
|||
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 promot the correct verion, uninstall, and fix deps
|
||||
RUN sh -c 'gem install --default rubocop:0.74.0; yes | gem uninstall rubocop:0.85.1 -a -x -I; gem install rubocop:0.74.0'
|
||||
# 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 #
|
||||
|
@ -102,12 +125,18 @@ RUN wget -O- -nvq https://raw.githubusercontent.com/golangci/golangci-lint/maste
|
|||
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/
|
||||
|
||||
##################
|
||||
#########################
|
||||
# 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
|
||||
|
||||
##################
|
||||
# Install ktlint #
|
||||
##################
|
||||
RUN curl -sSLO https://github.com/pinterest/ktlint/releases/latest/download/ktlint && chmod a+x ktlint \
|
||||
&& mv "ktlint" /usr/bin/
|
||||
|
||||
###########################################
|
||||
# Load GitHub Env Vars for GitHub Actions #
|
||||
###########################################
|
||||
|
@ -123,6 +152,7 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
|||
VALIDATE_MD=${VALIDATE_MD} \
|
||||
VALIDATE_BASH=${VALIDATE_BASH} \
|
||||
VALIDATE_PERL=${VALIDATE_PERL} \
|
||||
VALIDATE_PHP=${VALIDATE_PHP} \
|
||||
VALIDATE_PYTHON=${VALIDATE_PYTHON} \
|
||||
VALIDATE_RUBY=${VALIDATE_RUBY} \
|
||||
VALIDATE_COFFEE=${VALIDATE_COFFEE} \
|
||||
|
@ -136,6 +166,8 @@ ENV GITHUB_SHA=${GITHUB_SHA} \
|
|||
VALIDATE_TERRAFORM=${VALIDATE_TERRAFORM} \
|
||||
VALIDATE_CSS=${VALIDATE_CSS} \
|
||||
VALIDATE_ENV=${VALIDATE_ENV} \
|
||||
VALIDATE_KOTLIN=${VALIDATE_KOTLIN} \
|
||||
VALIDATE_POWERSHELL=${VALIDATE_POWERSHELL} \
|
||||
ANSIBLE_DIRECTORY=${ANSIBLE_DIRECTORY} \
|
||||
RUN_LOCAL=${RUN_LOCAL} \
|
||||
TEST_CASE_RUN=${TEST_CASE_RUN} \
|
||||
|
|
10
README.md
10
README.md
|
@ -27,6 +27,7 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **JSON** | [jsonlint](https://github.com/zaach/jsonlint) |
|
||||
| **Markdown** | [markdownlint](https://github.com/igorshubovych/markdownlint-cli#readme) |
|
||||
| **Perl** | [perl](https://pkgs.alpinelinux.org/package/edge/main/x86/perl) |
|
||||
| **PHP** | [PHP](https://www.php.net/) |
|
||||
| **Python3** | [pylint](https://www.pylint.org/) |
|
||||
| **Ruby** | [RuboCop](https://github.com/rubocop-hq/rubocop) |
|
||||
| **Shell** | [Shellcheck](https://github.com/koalaman/shellcheck) |
|
||||
|
@ -34,7 +35,9 @@ Developers on **GitHub** can call the **GitHub Action** to lint their code base
|
|||
| **TypeScript** | [eslint](https://eslint.org/) [standard js](https://standardjs.com/) |
|
||||
| **XML** | [LibXML](http://xmlsoft.org/) |
|
||||
| **YAML** | [YamlLint](https://github.com/adrienverge/yamllint) |
|
||||
| **PowerShell** | [PSScriptAnalyzer](https://github.com/PowerShell/Psscriptanalyzer) |
|
||||
| **ENV** | [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) |
|
||||
| **Kotlin** | [ktlint](https://github.com/pinterest/ktlint) |
|
||||
|
||||
## How to use
|
||||
To use this **GitHub** Action you will need to complete the following:
|
||||
|
@ -95,7 +98,7 @@ jobs:
|
|||
# Run Linter against code base #
|
||||
################################
|
||||
- name: Lint Code Base
|
||||
uses: docker://github/super-linter:v2.1.1
|
||||
uses: docker://github/super-linter:v2.1.0
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_ANSIBLE: false
|
||||
|
@ -125,6 +128,7 @@ and won't run anything unexpected.
|
|||
| **VALIDATE_MD** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_BASH** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_PERL** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_PHP** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_PYTHON** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_RUBY** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_COFFEE** | `true` | Flag to enable or disable the linting process of the language . |
|
||||
|
@ -135,9 +139,11 @@ and won't run anything unexpected.
|
|||
| **VALIDATE_TYPESCRIPT_STANDARD** | `true` | Flag to enable or disable the linting process of the language. (Utilizing: standard) |
|
||||
| **VALIDATE_DOCKER** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_GO** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_POWERSHELL** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_TERRAFORM** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_CSS** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_ENV** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **VALIDATE_KOTLIN** | `true` | Flag to enable or disable the linting process of the language. |
|
||||
| **ANSIBLE_DIRECTORY** | `/ansible` | Flag to set the root directory for Ansible file location(s). |
|
||||
| **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. |
|
||||
|
@ -164,7 +170,7 @@ The **Super-Linter** has *CI/CT/CD* configured utilizing **GitHub** Actions.
|
|||
- `.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 branches **Docker** container is also removed from **DockerHub** to cleanup after itself
|
||||
- **Note:** The branch's **Docker** container is also removed from **DockerHub** to cleanup after itself
|
||||
|
||||
## Limitations
|
||||
Below are a list of the known limitations for the **GitHub Super-Linter**:
|
||||
|
|
18
TEMPLATES/.powershell-psscriptanalyzer.psd1
Normal file
18
TEMPLATES/.powershell-psscriptanalyzer.psd1
Normal file
|
@ -0,0 +1,18 @@
|
|||
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/markdown/Invoke-ScriptAnalyzer.md#-settings
|
||||
@{
|
||||
#CustomRulePath='path\to\CustomRuleModule.psm1'
|
||||
#RecurseCustomRulePath='path\of\customrules'
|
||||
#Severity = @(
|
||||
# 'Error'
|
||||
# 'Warning'
|
||||
#)
|
||||
#IncludeDefaultRules=$true
|
||||
#ExcludeRules = @(
|
||||
# 'PSAvoidUsingWriteHost',
|
||||
# 'MyCustomRuleName'
|
||||
#)
|
||||
#IncludeRules = @(
|
||||
# 'PSAvoidUsingWriteHost',
|
||||
# 'MyCustomRuleName'
|
||||
#)
|
||||
}
|
|
@ -11,6 +11,7 @@ Below is examples and documentation for each language and the various methods to
|
|||
- [JSON](#json)
|
||||
- [Markdown](#markdown)
|
||||
- [Perl](#perl)
|
||||
- [PHP](#php)
|
||||
- [XML](#xml)
|
||||
- [Coffeescript](#coffeescript)
|
||||
- [Javascript Eslint](#javascript-eslint)
|
||||
|
@ -22,6 +23,7 @@ Below is examples and documentation for each language and the various methods to
|
|||
- [Terraform](#terraform)
|
||||
- [CSS](#stylelint)
|
||||
- [ENV](#dotenv-linter)
|
||||
- [Kotlin](#kotlin)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
|
@ -303,6 +305,23 @@ Here is more data
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
## PHP
|
||||
- [PHP](https://www.php.net/)
|
||||
|
||||
### PHP Config file
|
||||
- There is no top level *configuration file* available at this time
|
||||
|
||||
### PHP disable single line
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
### PHP disable code block
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
### PHP disable entire file
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
## XML
|
||||
- [XML](http://xmlsoft.org/)
|
||||
|
||||
|
@ -564,3 +583,27 @@ a {}
|
|||
|
||||
### dotenv-linter disable entire file
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
## Kotlin
|
||||
- [ktlint](https://github.com/pinterest/ktlint)
|
||||
|
||||
### ktlint Config file
|
||||
- There is no top level *configuration file* available at this time
|
||||
|
||||
### ktlint disable single line
|
||||
```kotlin
|
||||
import package.* // ktlint-disable no-wildcard-imports
|
||||
```
|
||||
|
||||
### ktlint disable code block
|
||||
```kotlin
|
||||
/* ktlint-disable no-wildcard-imports */
|
||||
import package.a.*
|
||||
import package.b.*
|
||||
/* ktlint-enable no-wildcard-imports */
|
||||
```
|
||||
|
||||
### ktlint disable entire file
|
||||
- There is currently **No** way to disable rules inline of the file(s)
|
||||
|
|
240
lib/linter.sh
240
lib/linter.sh
|
@ -32,7 +32,7 @@ COFFEESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$COFFEE_FILE_NAME" # Path to
|
|||
JAVASCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file
|
||||
JAVASCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$JAVASCRIPT_FILE_NAME" # Path to the Javascript lint rules
|
||||
JAVASCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||
# Typecript Vars
|
||||
# Typescript Vars
|
||||
TYPESCRIPT_FILE_NAME='.eslintrc.yml' # Name of the file
|
||||
TYPESCRIPT_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TYPESCRIPT_FILE_NAME" # Path to the Typescript lint rules
|
||||
TYPESCRIPT_STANDARD_LINTER_RULES='' # ENV string to pass when running js standard
|
||||
|
@ -48,25 +48,28 @@ GO_LINTER_RULES="$DEFAULT_RULES_LOCATION/$GO_FILE_NAME" # Path to th
|
|||
# Terraform Vars
|
||||
TERRAFORM_FILE_NAME='.tflint.hcl' # Name of the file
|
||||
TERRAFORM_LINTER_RULES="$DEFAULT_RULES_LOCATION/$TERRAFORM_FILE_NAME" # Path to the Terraform lint rules
|
||||
# Powershell Vars
|
||||
POWERSHELL_FILE_NAME='.powershell-psscriptanalyzer.psd1' # Name of the file
|
||||
POWERSHELL_LINTER_RULES="$DEFAULT_RULES_LOCATION/$POWERSHELL_FILE_NAME" # Path to the Powershell lint rules
|
||||
# CSS Vars
|
||||
CSS_FILE_NAME='.stylelintrc.json' # Name of the file
|
||||
CSS_LINTER_RULES="$DEFAULT_RULES_LOCATION/$CSS_FILE_NAME" # Path to the CSS lint rules
|
||||
|
||||
|
||||
#######################################
|
||||
# Linter array for information prints #
|
||||
#######################################
|
||||
LINTER_ARRAY=("jsonlint" "yamllint" "xmllint" "markdownlint" "shellcheck"
|
||||
"pylint" "perl" "rubocop" "coffeelint" "eslint" "standard"
|
||||
"ansible-lint" "/dockerfilelint/bin/dockerfilelint" "golangci-lint" "tflint"
|
||||
"stylelint" "dotenv-linter")
|
||||
"stylelint" "dotenv-linter" "powershell" "ktlint")
|
||||
|
||||
#############################
|
||||
# Language array for prints #
|
||||
#############################
|
||||
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'RUBY' 'PYTHON'
|
||||
LANGUAGE_ARRAY=('YML' 'JSON' 'XML' 'MARKDOWN' 'BASH' 'PERL' 'PHP' 'RUBY' 'PYTHON'
|
||||
'COFFEESCRIPT' 'ANSIBLE' 'JAVASCRIPT_STANDARD' 'JAVASCRIPT_ES'
|
||||
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM' 'CSS' "ENV")
|
||||
'TYPESCRIPT_STANDARD' 'TYPESCRIPT_ES' 'DOCKER' 'GO' 'TERRAFORM'
|
||||
'ENV' 'POWERSHELL' 'KOTLIN')
|
||||
|
||||
###################
|
||||
# GitHub ENV Vars #
|
||||
|
@ -83,6 +86,7 @@ VALIDATE_XML="${VALIDATE_XML}" # Boolean to validate lang
|
|||
VALIDATE_MD="${VALIDATE_MD}" # Boolean to validate language
|
||||
VALIDATE_BASH="${VALIDATE_BASH}" # Boolean to validate language
|
||||
VALIDATE_PERL="${VALIDATE_PERL}" # Boolean to validate language
|
||||
VALIDATE_PHP="${VALIDATE_PHP}" # Boolean to validate language
|
||||
VALIDATE_PYTHON="${VALIDATE_PYTHON}" # Boolean to validate language
|
||||
VALIDATE_RUBY="${VALIDATE_RUBY}" # Boolean to validate language
|
||||
VALIDATE_COFFEE="${VALIDATE_COFFEE}" # Boolean to validate language
|
||||
|
@ -91,11 +95,13 @@ VALIDATE_JAVASCRIPT_ES="${VALIDATE_JAVASCRIPT_ES}" # Boolean to val
|
|||
VALIDATE_JAVASCRIPT_STANDARD="${VALIDATE_JAVASCRIPT_STANDARD}" # Boolean to validate language
|
||||
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
|
||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
||||
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
||||
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
||||
VALIDATE_DOCKER="${VALIDATE_DOCKER}" # Boolean to validate language
|
||||
VALIDATE_GO="${VALIDATE_GO}" # Boolean to validate language
|
||||
VALIDATE_TERRAFORM="${VALIDATE_TERRAFORM}" # Boolean to validate language
|
||||
VALIDATE_POWERSHELL="${VALIDATE_POWERSHELL}" # Boolean to validate language
|
||||
VALIDATE_CSS="${VALIDATE_CSS}" # Boolean to validate language
|
||||
VALIDATE_ENV="${VALIDATE_ENV}" # Boolean to validate language
|
||||
VALIDATE_KOTLIN="${VALIDATE_KOTLIN}" # Boolean to validate language
|
||||
TEST_CASE_RUN="${TEST_CASE_RUN}" # Boolean to validate only test cases
|
||||
DISABLE_ERRORS="${DISABLE_ERRORS}" # Boolean to enable warning-only output without throwing errors
|
||||
LINTER_RULES_PATH="${LINTER_RULES_PATH:-.github/linters}" # Linter Path Directory
|
||||
|
@ -129,6 +135,7 @@ FILE_ARRAY_XML=() # Array of files to check
|
|||
FILE_ARRAY_MD=() # Array of files to check
|
||||
FILE_ARRAY_BASH=() # Array of files to check
|
||||
FILE_ARRAY_PERL=() # Array of files to check
|
||||
FILE_ARRAY_PHP=() # Array of files to check
|
||||
FILE_ARRAY_RUBY=() # Array of files to check
|
||||
FILE_ARRAY_PYTHON=() # Array of files to check
|
||||
FILE_ARRAY_COFFEESCRIPT=() # Array of files to check
|
||||
|
@ -139,8 +146,10 @@ FILE_ARRAY_TYPESCRIPT_STANDARD=() # Array of files to check
|
|||
FILE_ARRAY_DOCKER=() # Array of files to check
|
||||
FILE_ARRAY_GO=() # Array of files to check
|
||||
FILE_ARRAY_TERRAFORM=() # Array of files to check
|
||||
FILE_ARRAY_POWERSHELL=() # Array of files to check
|
||||
FILE_ARRAY_CSS=() # Array of files to check
|
||||
FILE_ARRAY_ENV=() # Array of files to check
|
||||
FILE_ARRAY_KOTLIN=() # Array of files to check
|
||||
|
||||
############
|
||||
# Counters #
|
||||
|
@ -151,6 +160,7 @@ ERRORS_FOUND_XML=0 # Count of errors found
|
|||
ERRORS_FOUND_MARKDOWN=0 # Count of errors found
|
||||
ERRORS_FOUND_BASH=0 # Count of errors found
|
||||
ERRORS_FOUND_PERL=0 # Count of errors found
|
||||
ERRORS_FOUND_PHP=0 # Count of errors found
|
||||
ERRORS_FOUND_RUBY=0 # Count of errors found
|
||||
ERRORS_FOUND_PYTHON=0 # Count of errors found
|
||||
ERRORS_FOUND_COFFEESCRIPT=0 # Count of errors found
|
||||
|
@ -162,8 +172,10 @@ ERRORS_FOUND_TYPESCRIPT_ES=0 # Count of errors found
|
|||
ERRORS_FOUND_DOCKER=0 # Count of errors found
|
||||
ERRORS_FOUND_GO=0 # Count of errors found
|
||||
ERRORS_FOUND_TERRAFORM=0 # Count of errors found
|
||||
ERRORS_FOUND_POWERSHELL=0 # Count of errors found
|
||||
ERRORS_FOUND_CSS=0 # Count of errors found
|
||||
ERRORS_FOUND_ENV=0 # Count of errors found
|
||||
ERRORS_FOUND_KOTLIN=0 # Count of errors found
|
||||
|
||||
################################################################################
|
||||
########################## FUNCTIONS BELOW #####################################
|
||||
|
@ -224,7 +236,7 @@ GetLinterVersions()
|
|||
##############################
|
||||
# Check the shell for errors #
|
||||
##############################
|
||||
if [ $ERROR_CODE -ne 0 ] | [ -z "${GET_VERSION_CMD[*]}" ]; then
|
||||
if [ $ERROR_CODE -ne 0 ] || [ -z "${GET_VERSION_CMD[*]}" ]; then
|
||||
echo "WARN! Failed to get version info for:[$LINTER]"
|
||||
echo "---------------------------------------------"
|
||||
else
|
||||
|
@ -355,9 +367,9 @@ GetStandardRules()
|
|||
ENV_STRING+="--env ${ENV} "
|
||||
done
|
||||
|
||||
########################################
|
||||
# Remove trailing and ending witespace #
|
||||
########################################
|
||||
#########################################
|
||||
# Remove trailing and ending whitespace #
|
||||
#########################################
|
||||
if [[ "$LINTER" == "javascript" ]]; then
|
||||
JAVASCRIPT_STANDARD_LINTER_RULES="$(echo -e "${ENV_STRING}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
elif [[ "$LINTER" == "typescript" ]]; then
|
||||
|
@ -729,6 +741,7 @@ GetValidationInfo()
|
|||
VALIDATE_MD=$(echo "$VALIDATE_MD" | awk '{print tolower($0)}')
|
||||
VALIDATE_BASH=$(echo "$VALIDATE_BASH" | awk '{print tolower($0)}')
|
||||
VALIDATE_PERL=$(echo "$VALIDATE_PERL" | awk '{print tolower($0)}')
|
||||
VALIDATE_PHP=$(echo "$VALIDATE_PHP" | awk '{print tolower($0)}')
|
||||
VALIDATE_PYTHON=$(echo "$VALIDATE_PYTHON" | awk '{print tolower($0)}')
|
||||
VALIDATE_RUBY=$(echo "$VALIDATE_RUBY" | awk '{print tolower($0)}')
|
||||
VALIDATE_COFFEE=$(echo "$VALIDATE_COFFEE" | awk '{print tolower($0)}')
|
||||
|
@ -740,8 +753,10 @@ GetValidationInfo()
|
|||
VALIDATE_DOCKER=$(echo "$VALIDATE_DOCKER" | awk '{print tolower($0)}')
|
||||
VALIDATE_GO=$(echo "$VALIDATE_GO" | awk '{print tolower($0)}')
|
||||
VALIDATE_TERRAFORM=$(echo "$VALIDATE_TERRAFORM" | awk '{print tolower($0)}')
|
||||
VALIDATE_POWERSHELL=$(echo "$VALIDATE_POWERSHELL" | awk '{print tolower($0)}')
|
||||
VALIDATE_CSS=$(echo "$VALIDATE_CSS" | awk '{print tolower($0)}')
|
||||
VALIDATE_ENV=$(echo "$VALIDATE_ENV" | awk '{print tolower($0)}')
|
||||
VALIDATE_KOTLIN=$(echo "$VALIDATE_KOTLIN" | awk '{print tolower($0)}')
|
||||
|
||||
################################################
|
||||
# Determine if any linters were explicitly set #
|
||||
|
@ -753,6 +768,7 @@ GetValidationInfo()
|
|||
-n "$VALIDATE_MD" || \
|
||||
-n "$VALIDATE_BASH" || \
|
||||
-n "$VALIDATE_PERL" || \
|
||||
-n "$VALIDATE_PHP" || \
|
||||
-n "$VALIDATE_PYTHON" || \
|
||||
-n "$VALIDATE_RUBY" || \
|
||||
-n "$VALIDATE_COFFEE" || \
|
||||
|
@ -764,8 +780,10 @@ GetValidationInfo()
|
|||
-n "$VALIDATE_DOCKER" || \
|
||||
-n "$VALIDATE_GO" || \
|
||||
-n "$VALIDATE_TERRAFORM" || \
|
||||
-n "$VALIDATE_POWERSHELL" || \
|
||||
-n "$VALIDATE_CSS" || \
|
||||
-n "$VALIDATE_ENV" ]]; then
|
||||
-n "$VALIDATE_ENV" || \
|
||||
-n "$VALIDATE_KOTLIN" ]]; then
|
||||
ANY_SET="true"
|
||||
fi
|
||||
|
||||
|
@ -853,6 +871,20 @@ GetValidationInfo()
|
|||
VALIDATE_PERL="true"
|
||||
fi
|
||||
|
||||
####################################
|
||||
# Validate if we should check PHP #
|
||||
####################################
|
||||
if [[ "$ANY_SET" == "true" ]]; then
|
||||
# Some linter flags were set - only run those set to true
|
||||
if [[ -z "$VALIDATE_PHP" ]]; then
|
||||
# PHP flag was not set - default to false
|
||||
VALIDATE_PHP="false"
|
||||
fi
|
||||
else
|
||||
# No linter flags were set - default all to true
|
||||
VALIDATE_PHP="true"
|
||||
fi
|
||||
|
||||
######################################
|
||||
# Validate if we should check PYTHON #
|
||||
######################################
|
||||
|
@ -1007,6 +1039,20 @@ GetValidationInfo()
|
|||
VALIDATE_TERRAFORM="true"
|
||||
fi
|
||||
|
||||
#########################################
|
||||
# Validate if we should check POWERSHELL #
|
||||
#########################################
|
||||
if [[ "$ANY_SET" == "true" ]]; then
|
||||
# Some linter flags were set - only run those set to true
|
||||
if [[ -z "$VALIDATE_POWERSHELL" ]]; then
|
||||
# POWERSHELL flag was not set - default to false
|
||||
VALIDATE_POWERSHELL="false"
|
||||
fi
|
||||
else
|
||||
# No linter flags were set - default all to true
|
||||
VALIDATE_POWERSHELL="true"
|
||||
fi
|
||||
|
||||
###################################
|
||||
# Validate if we should check CSS #
|
||||
###################################
|
||||
|
@ -1021,9 +1067,9 @@ GetValidationInfo()
|
|||
VALIDATE_CSS="true"
|
||||
fi
|
||||
|
||||
####################################
|
||||
###################################
|
||||
# Validate if we should check ENV #
|
||||
####################################
|
||||
###################################
|
||||
if [[ "$ANY_SET" == "true" ]]; then
|
||||
# Some linter flags were set - only run those set to true
|
||||
if [[ -z "$VALIDATE_ENV" ]]; then
|
||||
|
@ -1035,6 +1081,21 @@ GetValidationInfo()
|
|||
VALIDATE_ENV="true"
|
||||
fi
|
||||
|
||||
######################################
|
||||
# Validate if we should check KOTLIN #
|
||||
######################################
|
||||
if [[ "$ANY_SET" == "true" ]]; then
|
||||
# Some linter flags were set - only run those set to true
|
||||
if [[ -z "$VALIDATE_KOTLIN" ]]; then
|
||||
# ENV flag was not set - default to false
|
||||
VALIDATE_KOTLIN="false"
|
||||
fi
|
||||
else
|
||||
# No linter flags were set - default all to true
|
||||
VALIDATE_KOTLIN="true"
|
||||
fi
|
||||
|
||||
|
||||
#######################################
|
||||
# Print which linters we are enabling #
|
||||
#######################################
|
||||
|
@ -1068,6 +1129,11 @@ GetValidationInfo()
|
|||
else
|
||||
PRINT_ARRAY+=("- Excluding [PERL] files in code base...")
|
||||
fi
|
||||
if [[ "$VALIDATE_PHP" == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [PHP] files in code base...")
|
||||
else
|
||||
PRINT_ARRAY+=("- Excluding [PHP] files in code base...")
|
||||
fi
|
||||
if [[ "$VALIDATE_PYTHON" == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [PYTHON] files in code base...")
|
||||
else
|
||||
|
@ -1123,6 +1189,11 @@ GetValidationInfo()
|
|||
else
|
||||
PRINT_ARRAY+=("- Excluding [TERRAFORM] files in code base...")
|
||||
fi
|
||||
if [[ "$VALIDATE_POWERSHELL" == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [POWERSHELL] files in code base...")
|
||||
else
|
||||
PRINT_ARRAY+=("- Excluding [POWERSHELL] files in code base...")
|
||||
fi
|
||||
if [[ "$VALIDATE_CSS" == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [CSS] files in code base...")
|
||||
else
|
||||
|
@ -1133,6 +1204,11 @@ GetValidationInfo()
|
|||
else
|
||||
PRINT_ARRAY+=("- Excluding [ENV] files in code base...")
|
||||
fi
|
||||
if [[ "$VALIDATE_KOTLIN" == "true" ]]; then
|
||||
PRINT_ARRAY+=("- Validating [KOTLIN] files in code base...")
|
||||
else
|
||||
PRINT_ARRAY+=("- Excluding [KOTLIN] files in code base...")
|
||||
fi
|
||||
|
||||
##############################
|
||||
# Validate Ansible Directory #
|
||||
|
@ -1262,9 +1338,9 @@ BuildFileList()
|
|||
echo "Generating Diff with:[git diff --name-only '$DEFAULT_BRANCH..$GITHUB_SHA' --diff-filter=d]"
|
||||
fi
|
||||
|
||||
################################################
|
||||
# Get the Array of files changed in the comits #
|
||||
################################################
|
||||
#################################################
|
||||
# Get the Array of files changed in the commits #
|
||||
#################################################
|
||||
# shellcheck disable=SC2207
|
||||
RAW_FILE_ARRAY=($(cd "$GITHUB_WORKSPACE" || exit; git diff --name-only "$DEFAULT_BRANCH..$GITHUB_SHA" --diff-filter=d 2>&1))
|
||||
|
||||
|
@ -1283,9 +1359,9 @@ BuildFileList()
|
|||
exit 1
|
||||
fi
|
||||
|
||||
#################################################
|
||||
# Itterate through the array of all files found #
|
||||
#################################################
|
||||
################################################
|
||||
# Iterate through the array of all files found #
|
||||
################################################
|
||||
echo ""
|
||||
echo "----------------------------------------------"
|
||||
echo "Files that have been modified in the commit(s):"
|
||||
|
@ -1377,6 +1453,18 @@ BuildFileList()
|
|||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
######################
|
||||
# Get the PHP files #
|
||||
######################
|
||||
elif [ "$FILE_TYPE" == "php" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_PHP+=("$FILE")
|
||||
##########################################################
|
||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
######################
|
||||
# Get the RUBY files #
|
||||
######################
|
||||
elif [ "$FILE_TYPE" == "rb" ]; then
|
||||
|
@ -1462,6 +1550,14 @@ BuildFileList()
|
|||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
###########################
|
||||
# Get the Powershell files #
|
||||
###########################
|
||||
elif [ "$FILE_TYPE" == "ps1" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_POWERSHELL+=("$FILE")
|
||||
elif [ "$FILE_TYPE" == "css" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
|
@ -1480,6 +1576,15 @@ BuildFileList()
|
|||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
elif [ "$FILE_TYPE" == "kt" ] || [ "$FILE_TYPE" == "kts" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
################################
|
||||
FILE_ARRAY_KOTLIN+=("$FILE")
|
||||
##########################################################
|
||||
# Set the READ_ONLY_CHANGE_FLAG since this could be exec #
|
||||
##########################################################
|
||||
READ_ONLY_CHANGE_FLAG=1
|
||||
elif [ "$FILE" == "Dockerfile" ]; then
|
||||
################################
|
||||
# Append the file to the array #
|
||||
|
@ -1637,7 +1742,7 @@ LintCodebase()
|
|||
if [ ${#FILE_ARRAY[@]} -eq 0 ] && [ "$VALIDATE_ALL_CODEBASE" == "false" ]; then
|
||||
# No files found in commit and user has asked to not validate code base
|
||||
SKIP_FLAG=1
|
||||
# echo " - No files found in chageset to lint for language:[$FILE_TYPE]"
|
||||
# echo " - No files found in changeset to lint for language:[$FILE_TYPE]"
|
||||
elif [ ${#FILE_ARRAY[@]} -ne 0 ]; then
|
||||
# We have files added to array of files to check
|
||||
LIST_FILES=("${FILE_ARRAY[@]}") # Copy the array into list
|
||||
|
@ -1705,10 +1810,26 @@ LintCodebase()
|
|||
echo "---------------------------"
|
||||
echo "File:[$FILE]"
|
||||
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1)
|
||||
####################
|
||||
# Set the base Var #
|
||||
####################
|
||||
LINT_CMD=''
|
||||
|
||||
#######################################
|
||||
# Corner case for Powershell subshell #
|
||||
#######################################
|
||||
if [[ "$FILE_TYPE" == "POWERSHELL" ]]; then
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
# Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1)
|
||||
fi
|
||||
|
||||
#######################
|
||||
# Load the error code #
|
||||
|
@ -1875,6 +1996,12 @@ TestCodebase()
|
|||
# Lint the file with the rules #
|
||||
################################
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER/ansible" || exit; $LINTER_COMMAND "$FILE" 2>&1)
|
||||
elif [[ "$FILE_TYPE" == "POWERSHELL" ]]; then
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
################################
|
||||
# Need to append "'" to make the pwsh call syntax correct, also exit with exit code from inner subshell
|
||||
LINT_CMD=$(cd "$GITHUB_WORKSPACE/$TEST_CASE_FOLDER" || exit; $LINTER_COMMAND "$FILE"; exit $? 2>&1)
|
||||
else
|
||||
################################
|
||||
# Lint the file with the rules #
|
||||
|
@ -1981,6 +2108,7 @@ Footer()
|
|||
[ "$ERRORS_FOUND_MARKDOWN" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_BASH" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_PERL" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_PHP" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_PYTHON" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_COFFEESCRIPT" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_ANSIBLE" -ne 0 ] || \
|
||||
|
@ -1991,9 +2119,11 @@ Footer()
|
|||
[ "$ERRORS_FOUND_DOCKER" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_GO" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_TERRAFORM" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_POWERSHELL" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_RUBY" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_CSS" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_ENV" -ne 0 ]; then
|
||||
[ "$ERRORS_FOUND_ENV" -ne 0 ] || \
|
||||
[ "$ERRORS_FOUND_KOTLIN" -ne 0 ]; then
|
||||
# Failed exit
|
||||
echo "Exiting with errors found!"
|
||||
exit 1
|
||||
|
@ -2019,7 +2149,7 @@ RunTestCases()
|
|||
# version of linter.sh, and a new container is built with the latest codebase
|
||||
# for testing. That container is spun up, and ran,
|
||||
# with the flag: TEST_CASE_RUN=true
|
||||
# So that the new code can be validated againt the test cases
|
||||
# So that the new code can be validated against the test cases
|
||||
|
||||
#################
|
||||
# Header prints #
|
||||
|
@ -2040,6 +2170,7 @@ RunTestCases()
|
|||
TestCodebase "BASH" "shellcheck" "shellcheck" ".*\.\(sh\)\$"
|
||||
TestCodebase "PYTHON" "pylint" "pylint --rcfile $PYTHON_LINTER_RULES -E" ".*\.\(py\)\$"
|
||||
TestCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$"
|
||||
TestCodebase "PHP" "php" "php -l" ".*\.\(php\)\$"
|
||||
TestCodebase "RUBY" "rubocop" "rubocop -c $RUBY_LINTER_RULES" ".*\.\(rb\)\$"
|
||||
TestCodebase "GO" "golangci-lint" "golangci-lint run -c $GO_LINTER_RULES" ".*\.\(go\)\$"
|
||||
TestCodebase "COFFEESCRIPT" "coffeelint" "coffeelint -f $COFFEESCRIPT_LINTER_RULES" ".*\.\(coffee\)\$"
|
||||
|
@ -2050,8 +2181,10 @@ RunTestCases()
|
|||
TestCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$"
|
||||
TestCodebase "ANSIBLE" "ansible-lint" "ansible-lint -v -c $ANSIBLE_LINTER_RULES" "ansible-lint"
|
||||
TestCodebase "TERRAFORM" "tflint" "tflint -c $TERRAFORM_LINTER_RULES" ".*\.\(tf\)\$"
|
||||
TestCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$"
|
||||
TestCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$"
|
||||
TestCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$"
|
||||
TestCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$"
|
||||
|
||||
#################
|
||||
# Footer prints #
|
||||
|
@ -2076,9 +2209,9 @@ Header
|
|||
# needed to connect back and update checks
|
||||
GetGitHubVars
|
||||
|
||||
##########################################
|
||||
# Get the langugages we need to validate #
|
||||
##########################################
|
||||
#########################################
|
||||
# Get the languages we need to validate #
|
||||
#########################################
|
||||
GetValidationInfo
|
||||
|
||||
########################
|
||||
|
@ -2106,6 +2239,8 @@ GetLinterRules "$GO_FILE_NAME" "$GO_LINTER_RULES"
|
|||
GetLinterRules "$DOCKER_FILE_NAME" "$DOCKER_LINTER_RULES"
|
||||
# Get Terraform rules
|
||||
GetLinterRules "$TERRAFORM_FILE_NAME" "$TERRAFORM_LINTER_RULES"
|
||||
# Get PowerShell rules
|
||||
GetLinterRules "$POWERSHELL_FILE_NAME" "$POWERSHELL_LINTER_RULES"
|
||||
# Get CSS rules
|
||||
GetLinterRules "$CSS_FILE_NAME" "$CSS_LINTER_RULES"
|
||||
|
||||
|
@ -2217,6 +2352,17 @@ if [ "$VALIDATE_PERL" == "true" ]; then
|
|||
LintCodebase "PERL" "perl" "perl -Mstrict -cw" ".*\.\(pl\)\$" "${FILE_ARRAY_PERL[@]}"
|
||||
fi
|
||||
|
||||
################
|
||||
# PHP LINTING #
|
||||
################
|
||||
if [ "$VALIDATE_PHP" == "true" ]; then
|
||||
#######################
|
||||
# Lint the PHP files #
|
||||
#######################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "PHP" "php" "php -l" ".*\.\(php\)\$" "${FILE_ARRAY_PHP[@]}"
|
||||
fi
|
||||
|
||||
################
|
||||
# RUBY LINTING #
|
||||
################
|
||||
|
@ -2337,15 +2483,26 @@ if [ "$VALIDATE_CSS" == "true" ]; then
|
|||
LintCodebase "CSS" "stylelint" "stylelint --config $CSS_LINTER_RULES" ".*\.\(css\)\$" "${FILE_ARRAY_CSS[@]}"
|
||||
fi
|
||||
|
||||
################
|
||||
###############
|
||||
# ENV LINTING #
|
||||
################
|
||||
###############
|
||||
if [ "$VALIDATE_ENV" == "true" ]; then
|
||||
#######################
|
||||
# Lint the env files #
|
||||
#######################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\)\$" "${FILE_ARRAY_ENV[@]}"
|
||||
LintCodebase "ENV" "dotenv-linter" "dotenv-linter" ".*\.\(env\).*\$" "${FILE_ARRAY_ENV[@]}"
|
||||
fi
|
||||
|
||||
##################
|
||||
# KOTLIN LINTING #
|
||||
##################
|
||||
if [ "$VALIDATE_KOTLIN" == "true" ]; then
|
||||
#######################
|
||||
# Lint the Kotlin files #
|
||||
#######################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "KOTLIN" "ktlint" "ktlint" ".*\.\(kt\|kts\)\$" "${FILE_ARRAY_ENV[@]}"
|
||||
fi
|
||||
|
||||
##################
|
||||
|
@ -2359,6 +2516,17 @@ if [ "$VALIDATE_DOCKER" == "true" ]; then
|
|||
LintCodebase "DOCKER" "/dockerfilelint/bin/dockerfilelint" "/dockerfilelint/bin/dockerfilelint" ".*\(Dockerfile\)\$" "${FILE_ARRAY_DOCKER[@]}"
|
||||
fi
|
||||
|
||||
######################
|
||||
# POWERSHELL LINTING #
|
||||
######################
|
||||
if [ "$VALIDATE_POWERSHELL" == "true" ]; then
|
||||
#############################
|
||||
# Lint the powershell files #
|
||||
#############################
|
||||
# LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY"
|
||||
LintCodebase "POWERSHELL" "pwsh" "pwsh -c Invoke-ScriptAnalyzer -EnableExit -Settings $POWERSHELL_LINTER_RULES -Path" ".*\.\(ps1\|psm1\|psd1\|ps1xml\|pssc\|psrc\|cdxml\)\$" "${FILE_ARRAY_POWERSHELL[@]}"
|
||||
fi
|
||||
|
||||
##########
|
||||
# Footer #
|
||||
##########
|
||||
|
|
Loading…
Reference in a new issue