mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-09 18:43:34 -05:00
Merge pull request #867 from ferrarimarco/dynamically-invoke-tests
Dynamically invoke tests
This commit is contained in:
commit
79c3127f8a
104 changed files with 2013 additions and 552 deletions
19
.automation/test/bash_exec/README.md
Normal file
19
.automation/test/bash_exec/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Bash Test Cases
|
||||
|
||||
This folder holds the test cases for **Bash Exec**.
|
||||
|
||||
## 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.
|
17
.automation/test/bash_exec/shell_bad_1.sh
Normal file
17
.automation/test/bash_exec/shell_bad_1.sh
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# CMD
|
||||
HELLO_WORLD=($(echo "Hello World" | cut -f1 -d' ' 2>&1))
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
||||
# Check the shell
|
||||
if [ $ERROR_CODE -ne 0]; then
|
||||
echo "We did it!"
|
||||
exit 0
|
||||
else
|
||||
echo "We done goofed it..."
|
||||
echo $HELLO_WORLD
|
||||
exit 1
|
||||
fi
|
17
.automation/test/bash_exec/shell_good_1.sh
Executable file
17
.automation/test/bash_exec/shell_good_1.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# CMD
|
||||
HELLO_WORLD=$(echo "Hello World" | cut -f1 -d' ' 2>&1)
|
||||
|
||||
# Load the error code
|
||||
ERROR_CODE=$?
|
||||
|
||||
# Check the shell
|
||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
||||
echo "We did it!"
|
||||
exit 0
|
||||
else
|
||||
echo "We done goofed it..."
|
||||
echo "${HELLO_WORLD}"
|
||||
exit 1
|
||||
fi
|
18
.automation/test/dockerfile_hadolint/README.md
Normal file
18
.automation/test/dockerfile_hadolint/README.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Docker Test Cases
|
||||
|
||||
This folder holds the test cases for **Docker**.
|
||||
|
||||
## Additional Docs
|
||||
|
||||
Due to the nature of the naming of files, we have `2` subfolders in this directory.
|
||||
|
||||
- `good` is for working, and correct **Dockerfile**(s)
|
||||
- `bad` is for invalid, and incorrect **Dockerfile**(s)
|
||||
|
||||
## Good Test Cases
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
||||
|
||||
## Bad Test Cases
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
14
.automation/test/dockerfile_hadolint/bad/Dockerfile
Normal file
14
.automation/test/dockerfile_hadolint/bad/Dockerfile
Normal file
|
@ -0,0 +1,14 @@
|
|||
from node:latest
|
||||
|
||||
# Create app directory
|
||||
run mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install app dependencies
|
||||
copy package.json /usr/src/app/ /here/there
|
||||
RUN sudo npm install
|
||||
|
||||
ADD server.js server.js
|
||||
EXPOSE 1
|
||||
CMD ["node", "server.js"]
|
||||
ENtrypoint /tmp/here.sh
|
13
.automation/test/dockerfile_hadolint/good/Dockerfile
Normal file
13
.automation/test/dockerfile_hadolint/good/Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM node:10
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install app dependencies
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install
|
||||
|
||||
COPY server.js server.js
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
13
.automation/test/dockerfile_hadolint/good/Dockerfile.dev
Normal file
13
.automation/test/dockerfile_hadolint/good/Dockerfile.dev
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM node:10
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install app dependencies
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install
|
||||
|
||||
COPY server.js server.js
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - Dockerfile
|
||||
---
|
||||
message: \nFile /tmp/lint/.automation/test/docker/bad/Dockerfile\nIssues 6\n\nLine 1 from node latest\nIssue Category Title Description\n 1 Clarity Capitalize For clarity and readability, all instructions in a Dockerfile\n Dockerfile should be uppercase.\n Instructions This is a convention adopted by most of the official images and\n greatly improves readability in long Dockerfiles. For an example\n of\n why this makes a difference, check out the current [redis\n Dockerfile](https //github.com/docker-library/redis/blob/b375650fb6\n 9b7db819e90c0033433c705b28656e/3.0/Dockerfile)\n and you should be able to easily see the instructions used.\n 2 Clarity Base Image Latest Base images should not use the latest tag.\n Tag\n\nLine 4 run mkdir -p /usr/src/app\nIssue Category Title Description\n 3 Clarity Capitalize For clarity and readability, all instructions in a Dockerfile\n Dockerfile should be uppercase.\n Instructions This is a convention adopted by most of the official images and\n greatly improves readability in long Dockerfiles. For an example\n of\n why this makes a difference, check out the current [redis\n Dockerfile](https //github.com/docker-library/redis/blob/b375650fb6\n 9b7db819e90c0033433c705b28656e/3.0/Dockerfile)\n and you should be able to easily see the instructions used.\n\nLine 8 copy package.json /usr/src/app/ /here/there\nIssue Category Title Description\n 4 Clarity Capitalize For clarity and readability, all instructions in a Dockerfile\n Dockerfile should be uppercase.\n Instructions This is a convention adopted by most of the official images and\n greatly improves readability in long Dockerfiles. For an example\n of\n why this makes a difference, check out the current [redis\n Dockerfile](https //github.com/docker-library/redis/blob/b375650fb6\n 9b7db819e90c0033433c705b28656e/3.0/Dockerfile)\n and you should be able to easily see the instructions used.\n\nLine 9 RUN sudo npm install\nIssue Category Title Description\n 5 Possible Bug Use Of sudo Is Not Use of `sudo` is not allowed in a Dockerfile. From the official\n Allowed document [Best practices for writing\n Dockerfiles](https //docs.docker.com/engine/userguide/eng-image/doc\n kerfile_best-practices/) \n > You should avoid installing or using `sudo` since it has\n unpredictable TTY and signal-forwarding behavior that can cause\n more problems than it solves.\n > If you absolutely need functionality similar to `sudo` (e.g.,\n initializing the daemon as root but running it as non-root), you\n may be able to use `gosu`.\n\nLine 14 ENtrypoint /tmp/here.sh\nIssue Category Title Description\n 6 Clarity Capitalize For clarity and readability, all instructions in a Dockerfile\n Dockerfile should be uppercase.\n Instructions This is a convention adopted by most of the official images and\n greatly improves readability in long Dockerfiles. For an example\n of\n why this makes a difference, check out the current [redis\n Dockerfile](https //github.com/docker-library/redis/blob/b375650fb6\n 9b7db819e90c0033433c705b28656e/3.0/Dockerfile)\n and you should be able to easily see the instructions used.\n
|
||||
...
|
||||
ok 2 - Dockerfile
|
19
.automation/test/javascript_standard/README.md
Normal file
19
.automation/test/javascript_standard/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Javascript Test Cases
|
||||
|
||||
This folder holds the test cases for **Javascript**.
|
||||
|
||||
## 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.
|
225
.automation/test/javascript_standard/javascript_bad_1.js
Normal file
225
.automation/test/javascript_standard/javascript_bad_1.js
Normal file
|
@ -0,0 +1,225 @@
|
|||
var http = require('http')
|
||||
var createHandler = require( 'github-webhook-handler')
|
||||
|
||||
var handler = createHandler( { path : /webhook, secret : (process.env.SECRET) })
|
||||
|
||||
var userArray = [ 'user1' ]
|
||||
here is some garbage = that
|
||||
|
||||
var teamDescription = Team of Robots
|
||||
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
|
||||
var teamId = ''
|
||||
|
||||
var orgRepos = []
|
||||
|
||||
// var creator = ""
|
||||
|
||||
var foo = someFunction();
|
||||
var bar = a + 1;
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
handler(req, res, function (err) {
|
||||
console.log(err)
|
||||
res.statusCode = 404
|
||||
res.end('no such location')
|
||||
})
|
||||
}).listen(3000)
|
||||
|
||||
handler.on('error', function (err) {
|
||||
console.await.error('Error:', err.message)
|
||||
})
|
||||
|
||||
handler.on('repository', function (event) {
|
||||
if (event.payload.action === 'created') {
|
||||
const repo = event.payload.repository.full_name
|
||||
console.log(repo)
|
||||
const org = event.payload.repository.owner.login
|
||||
getTeamID(org)
|
||||
setTimeout(checkTeamIDVariable, 1000)
|
||||
}
|
||||
})
|
||||
|
||||
handler.on('team', function (event) {
|
||||
// TODO user events such as being removed from team or org
|
||||
if (event.payload.action === 'deleted') {
|
||||
// const name = event.payload.team.name
|
||||
const org = event.payload.organization.login
|
||||
getRepositories(org)
|
||||
setTimeout(checkReposVariable, 5000)
|
||||
} else if (event.payload.action === 'removed_from_repository') {
|
||||
const org = event.payload.organization.login
|
||||
getTeamID(org)
|
||||
// const repo = event.payload.repository.full_name
|
||||
setTimeout(checkTeamIDVariable, 1000)
|
||||
}
|
||||
})
|
||||
|
||||
function getTeamID (org) {
|
||||
const https = require('https')
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443
|
||||
path: '/api/v3/orgs/' + org + '/teams',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk)
|
||||
}).on('end', () => {
|
||||
body = JSON.parse(Buffer.concat(body))
|
||||
body.forEach(item => {
|
||||
if (item.name === teamName) {
|
||||
teamId = item.id
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error, (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.end()
|
||||
}
|
||||
|
||||
function checkTeamIDVariable (repo) {
|
||||
if (typeof teamId != 'undefined') {
|
||||
addTeamToRepo(repo, teamId)
|
||||
}
|
||||
}
|
||||
|
||||
function checkReposVariable (org) {
|
||||
if (typeof orgRepos !== 'undefined') {
|
||||
// for(var repo of orgRepos) {
|
||||
// addTeamToRepo(repo, teamId)
|
||||
// }
|
||||
reCreateTeam(org)
|
||||
}
|
||||
}
|
||||
|
||||
function addTeamToRepo (repo, teamId) {
|
||||
const https = require('https')
|
||||
const data = JSON.stringify({
|
||||
permission: teamAccess
|
||||
})
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443,
|
||||
path: '/api/v3/teams/' + teamId + '/repos/' + repo,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
|
||||
body.push(chunk)
|
||||
|
||||
}).on('end', () => {
|
||||
|
||||
body = Buffer.concat(body).toString()
|
||||
console.log(res.statusCode)
|
||||
console.log('added team to ' + repo)
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
}
|
||||
|
||||
function reCreateTeam (org) {
|
||||
const https = require('https')
|
||||
const data = JSON.stringify({
|
||||
name: teamName,
|
||||
description: teamDescription,
|
||||
privacy: teamPrivacy
|
||||
maintainers: userArray,
|
||||
repo_names: orgRepos
|
||||
})
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443
|
||||
path: '/api/v3/orgs/' + org + '/teams',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
// const body = []
|
||||
const req = https.request(options, (res) => {
|
||||
if (res.statusCode !== 201) {
|
||||
console.log('Status code: ' + res.statusCode)
|
||||
console.log('Added ' + teamName + ' to ' + org + ' Failed')
|
||||
res.on('data', function (chunk) {
|
||||
console.log('BODY: ' + chunk)
|
||||
})
|
||||
} else {
|
||||
console.log('Added ' + teamName ' to ' + org)
|
||||
}
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
}
|
||||
|
||||
function getRepositories (org) {
|
||||
orgRepos = []
|
||||
|
||||
const https = require('https')
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: '443',
|
||||
path: '/api/v3/orgs/' + org + "/repos",
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk)
|
||||
|
||||
}).on('end', () => {
|
||||
body = JSON.parse(Buffer.concat(body))
|
||||
body.forEach(item => {
|
||||
orgRepos.push(item.full_name)
|
||||
|
||||
console.log(item.full_name)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
req.end()
|
||||
}
|
215
.automation/test/javascript_standard/javascript_good_1.js
Normal file
215
.automation/test/javascript_standard/javascript_good_1.js
Normal file
|
@ -0,0 +1,215 @@
|
|||
var http = require('http')
|
||||
var createHandler = require('github-webhook-handler')
|
||||
var handler = createHandler({ path: '/webhook', secret: (process.env.SECRET) })
|
||||
|
||||
var userArray = ['user1']
|
||||
|
||||
var teamDescription = 'Team of Robots'
|
||||
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
|
||||
var teamId = ''
|
||||
|
||||
var orgRepos = []
|
||||
|
||||
// var creator = ""
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
handler(req, res, function (err) {
|
||||
console.log(err)
|
||||
res.statusCode = 404
|
||||
res.end('no such location')
|
||||
})
|
||||
}).listen(3000)
|
||||
|
||||
handler.on('error', function (err) {
|
||||
console.error('Error:', err.message)
|
||||
})
|
||||
|
||||
handler.on('repository', function (event) {
|
||||
if (event.payload.action === 'created') {
|
||||
const repo = event.payload.repository.full_name
|
||||
console.log(repo)
|
||||
const org = event.payload.repository.owner.login
|
||||
getTeamID(org)
|
||||
setTimeout(checkTeamIDVariable, 1000)
|
||||
}
|
||||
})
|
||||
|
||||
handler.on('team', function (event) {
|
||||
// TODO user events such as being removed from team or org
|
||||
if (event.payload.action === 'deleted') {
|
||||
// const name = event.payload.team.name
|
||||
const org = event.payload.organization.login
|
||||
getRepositories(org)
|
||||
setTimeout(checkReposVariable, 5000)
|
||||
} else if (event.payload.action === 'removed_from_repository') {
|
||||
const org = event.payload.organization.login
|
||||
getTeamID(org)
|
||||
// const repo = event.payload.repository.full_name
|
||||
setTimeout(checkTeamIDVariable, 1000)
|
||||
}
|
||||
})
|
||||
|
||||
function getTeamID (org) {
|
||||
const https = require('https')
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443,
|
||||
path: '/api/v3/orgs/' + org + '/teams',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk)
|
||||
}).on('end', () => {
|
||||
body = JSON.parse(Buffer.concat(body))
|
||||
body.forEach(item => {
|
||||
if (item.name === teamName) {
|
||||
teamId = item.id
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.end()
|
||||
}
|
||||
|
||||
function checkTeamIDVariable (repo) {
|
||||
if (typeof teamId !== 'undefined') {
|
||||
addTeamToRepo(repo, teamId)
|
||||
}
|
||||
}
|
||||
|
||||
function checkReposVariable (org) {
|
||||
if (typeof orgRepos !== 'undefined') {
|
||||
// for(var repo of orgRepos) {
|
||||
// addTeamToRepo(repo, teamId)
|
||||
// }
|
||||
reCreateTeam(org)
|
||||
}
|
||||
}
|
||||
|
||||
function addTeamToRepo (repo, teamId) {
|
||||
const https = require('https')
|
||||
const data = JSON.stringify({
|
||||
permission: teamAccess
|
||||
})
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443,
|
||||
path: '/api/v3/teams/' + teamId + '/repos/' + repo,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk)
|
||||
}).on('end', () => {
|
||||
body = Buffer.concat(body).toString()
|
||||
console.log(res.statusCode)
|
||||
console.log('added team to ' + repo)
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
}
|
||||
|
||||
function reCreateTeam (org) {
|
||||
const https = require('https')
|
||||
const data = JSON.stringify({
|
||||
name: teamName,
|
||||
description: teamDescription,
|
||||
privacy: teamPrivacy,
|
||||
maintainers: userArray,
|
||||
repo_names: orgRepos
|
||||
})
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443,
|
||||
path: '/api/v3/orgs/' + org + '/teams',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
// const body = []
|
||||
const req = https.request(options, (res) => {
|
||||
if (res.statusCode !== 201) {
|
||||
console.log('Status code: ' + res.statusCode)
|
||||
console.log('Added ' + teamName + ' to ' + org + ' Failed')
|
||||
res.on('data', function (chunk) {
|
||||
console.log('BODY: ' + chunk)
|
||||
})
|
||||
} else {
|
||||
console.log('Added ' + teamName + ' to ' + org)
|
||||
}
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
}
|
||||
|
||||
function getRepositories (org) {
|
||||
orgRepos = []
|
||||
|
||||
const https = require('https')
|
||||
|
||||
const options = {
|
||||
hostname: (process.env.GHE_HOST),
|
||||
port: 443,
|
||||
path: '/api/v3/orgs/' + org + '/repos',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
let body = []
|
||||
const req = https.request(options, (res) => {
|
||||
res.on('data', (chunk) => {
|
||||
body.push(chunk)
|
||||
}).on('end', () => {
|
||||
body = JSON.parse(Buffer.concat(body))
|
||||
body.forEach(item => {
|
||||
orgRepos.push(item.full_name)
|
||||
console.log(item.full_name)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', (error) => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.end()
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - javascript_bad_1.js
|
||||
---
|
||||
message: \n/tmp/lint/.automation/test/javascript/javascript_bad_1.js\n 4 39 error Parsing error Unterminated regular expression literal\n\n✖ 1 problem (1 error, 0 warnings)\n
|
||||
...
|
||||
ok 2 - javascript_good_1.js
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - javascript_bad_1.js
|
||||
---
|
||||
message: standard Use JavaScript Standard Style (https //standardjs.com)\n /tmp/lint/.automation/test/javascript/javascript_bad_1.js 4 40 Parsing error Unterminated regular expression\n
|
||||
...
|
||||
ok 2 - javascript_good_1.js
|
19
.automation/test/php_phpcs/README.md
Normal file
19
.automation/test/php_phpcs/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# 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_phpcs/php_bad_1.php
Normal file
3
.automation/test/php_phpcs/php_bad_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29
|
15
.automation/test/php_phpcs/php_bad_2.php
Normal file
15
.automation/test/php_phpcs/php_bad_2.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function takesAnInt(int $i) {
|
||||
return [$i, "hello"];
|
||||
}
|
||||
|
||||
$data = ["some text", 5];
|
||||
takesAnInt($data[0]);
|
||||
|
||||
$condition = rand(0, 5);
|
||||
iff ($condition) {
|
||||
} elseif ($condition) {}
|
3
.automation/test/php_phpcs/php_good_1.php
Normal file
3
.automation/test/php_phpcs/php_good_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo "Hello World!", PHP_EOL;
|
25
.automation/test/php_phpcs/php_good_2.php
Normal file
25
.automation/test/php_phpcs/php_good_2.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function helloName(string $name): array
|
||||
{
|
||||
return ["hello", $name];
|
||||
}
|
||||
|
||||
function helloSuperLinter(): void
|
||||
{
|
||||
$hello = helloName("Super-Linter");
|
||||
echo implode(" ", $hello) . PHP_EOL;
|
||||
}
|
||||
|
||||
function helloOrWorld(): void
|
||||
{
|
||||
$random = rand(0, 10);
|
||||
if ($random >= 5) {
|
||||
echo "Hello";
|
||||
} else {
|
||||
echo "World";
|
||||
}
|
||||
}
|
12
.automation/test/php_phpcs/reports/expected-PHP_BUILTIN.tap
Normal file
12
.automation/test/php_phpcs/reports/expected-PHP_BUILTIN.tap
Normal file
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected '}' in /tmp/lint/.automation/test/php/php_bad_2.php on line 15\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_1.php\n----------------------------------------------------------------------\nFOUND 7 ERRORS AFFECTING 1 LINE\n----------------------------------------------------------------------\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_2.php\n----------------------------------------------------------------------\nFOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES\n----------------------------------------------------------------------\n 1 | WARNING | [ ] A file should declare new symbols (classes,\n | | functions, constants, etc.) and cause no other\n | | side effects, or it should execute logic with\n | | side effects, but should not do both. The first\n | | symbol is defined on line 6 and the first side\n | | effect is on line 10.\n 6 | ERROR | [x] Opening brace should be on a new line\n 14 | ERROR | [x] Space before opening parenthesis of function call\n | | prohibited\n 15 | ERROR | [x] Newline required after opening brace\n 15 | ERROR | [x] Closing brace must be on a line by itself\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
12
.automation/test/php_phpcs/reports/expected-PHP_PHPSTAN.tap
Normal file
12
.automation/test/php_phpcs/reports/expected-PHP_PHPSTAN.tap
Normal file
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: ------ ---------------------------------------------- \n Line php_bad_1.php \n ------ ---------------------------------------------- \n 3 Invalid numeric literal on line 3 \n 3 Invalid numeric literal on line 3 \n 3 Syntax error, unexpected '=' on line 3 \n 3 Syntax error, unexpected T_LNUMBER on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n ------ ---------------------------------------------- \n\n [ERROR] Found 6 errors \n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: ------ ----------------------------------------- \n Line php_bad_2.php \n ------ ----------------------------------------- \n 15 Syntax error, unexpected '}' on line 15 \n ------ ----------------------------------------- \n\n [ERROR] Found 1 error \n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR ParseError - php/php_bad_1.php 3 2 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 2 - Const pe98y is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 8 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 10 - Const n0u823n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 17 - Syntax error, unexpected '=' on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 18 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 21 - Invalid numeric literal on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 24 - Const u3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 28 - Const r08u2q098ry is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 40 - Syntax error, unexpected T_LNUMBER on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 42 - Const nq2yr09n2yr9 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 55 - Const y2n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 61 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 61 - Const yr is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 68 - Const yr3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\n------------------------------\n15 errors found\n------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR InvalidReturnType - php/php_bad_2.php 4 12 - The declared return type 'array<array-key, string>' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array<string>\n\n\nERROR InvalidReturnStatement - php/php_bad_2.php 7 12 - The inferred type 'array{int, string(hello)}' does not match the declared return type 'array<array-key, string>' for takesAnInt (see https //psalm.dev/128)\n return [$i, "hello"];\n\n\nERROR InvalidScalarArgument - php/php_bad_2.php 11 12 - Argument 1 of takesAnInt expects int, string(some text) provided (see https //psalm.dev/012)\ntakesAnInt($data[0]);\n\n\nERROR ParseError - php/php_bad_2.php 15 1 - Syntax error, unexpected '}' on line 15 (see https //psalm.dev/173)\n} elseif ($condition) {}\n\n\n------------------------------\n4 errors found\n------------------------------\nPsalm can automatically fix 1 of these issues.\nRun Psalm again with \n[30;48;5;195m--alter --issues=InvalidReturnType --dry-run\nto see what it can fix.\n------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
19
.automation/test/php_phpstan/README.md
Normal file
19
.automation/test/php_phpstan/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# 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_phpstan/php_bad_1.php
Normal file
3
.automation/test/php_phpstan/php_bad_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29
|
15
.automation/test/php_phpstan/php_bad_2.php
Normal file
15
.automation/test/php_phpstan/php_bad_2.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function takesAnInt(int $i) {
|
||||
return [$i, "hello"];
|
||||
}
|
||||
|
||||
$data = ["some text", 5];
|
||||
takesAnInt($data[0]);
|
||||
|
||||
$condition = rand(0, 5);
|
||||
iff ($condition) {
|
||||
} elseif ($condition) {}
|
3
.automation/test/php_phpstan/php_good_1.php
Normal file
3
.automation/test/php_phpstan/php_good_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo "Hello World!", PHP_EOL;
|
25
.automation/test/php_phpstan/php_good_2.php
Normal file
25
.automation/test/php_phpstan/php_good_2.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function helloName(string $name): array
|
||||
{
|
||||
return ["hello", $name];
|
||||
}
|
||||
|
||||
function helloSuperLinter(): void
|
||||
{
|
||||
$hello = helloName("Super-Linter");
|
||||
echo implode(" ", $hello) . PHP_EOL;
|
||||
}
|
||||
|
||||
function helloOrWorld(): void
|
||||
{
|
||||
$random = rand(0, 10);
|
||||
if ($random >= 5) {
|
||||
echo "Hello";
|
||||
} else {
|
||||
echo "World";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected '}' in /tmp/lint/.automation/test/php/php_bad_2.php on line 15\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_1.php\n----------------------------------------------------------------------\nFOUND 7 ERRORS AFFECTING 1 LINE\n----------------------------------------------------------------------\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_2.php\n----------------------------------------------------------------------\nFOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES\n----------------------------------------------------------------------\n 1 | WARNING | [ ] A file should declare new symbols (classes,\n | | functions, constants, etc.) and cause no other\n | | side effects, or it should execute logic with\n | | side effects, but should not do both. The first\n | | symbol is defined on line 6 and the first side\n | | effect is on line 10.\n 6 | ERROR | [x] Opening brace should be on a new line\n 14 | ERROR | [x] Space before opening parenthesis of function call\n | | prohibited\n 15 | ERROR | [x] Newline required after opening brace\n 15 | ERROR | [x] Closing brace must be on a line by itself\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: ------ ---------------------------------------------- \n Line php_bad_1.php \n ------ ---------------------------------------------- \n 3 Invalid numeric literal on line 3 \n 3 Invalid numeric literal on line 3 \n 3 Syntax error, unexpected '=' on line 3 \n 3 Syntax error, unexpected T_LNUMBER on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n ------ ---------------------------------------------- \n\n [ERROR] Found 6 errors \n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: ------ ----------------------------------------- \n Line php_bad_2.php \n ------ ----------------------------------------- \n 15 Syntax error, unexpected '}' on line 15 \n ------ ----------------------------------------- \n\n [ERROR] Found 1 error \n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR ParseError - php/php_bad_1.php 3 2 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 2 - Const pe98y is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 8 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 10 - Const n0u823n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 17 - Syntax error, unexpected '=' on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 18 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 21 - Invalid numeric literal on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 24 - Const u3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 28 - Const r08u2q098ry is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 40 - Syntax error, unexpected T_LNUMBER on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 42 - Const nq2yr09n2yr9 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 55 - Const y2n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 61 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 61 - Const yr is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 68 - Const yr3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\n------------------------------\n15 errors found\n------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR InvalidReturnType - php/php_bad_2.php 4 12 - The declared return type 'array<array-key, string>' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array<string>\n\n\nERROR InvalidReturnStatement - php/php_bad_2.php 7 12 - The inferred type 'array{int, string(hello)}' does not match the declared return type 'array<array-key, string>' for takesAnInt (see https //psalm.dev/128)\n return [$i, "hello"];\n\n\nERROR InvalidScalarArgument - php/php_bad_2.php 11 12 - Argument 1 of takesAnInt expects int, string(some text) provided (see https //psalm.dev/012)\ntakesAnInt($data[0]);\n\n\nERROR ParseError - php/php_bad_2.php 15 1 - Syntax error, unexpected '}' on line 15 (see https //psalm.dev/173)\n} elseif ($condition) {}\n\n\n------------------------------\n4 errors found\n------------------------------\nPsalm can automatically fix 1 of these issues.\nRun Psalm again with \n[30;48;5;195m--alter --issues=InvalidReturnType --dry-run\nto see what it can fix.\n------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
19
.automation/test/php_psalm/README.md
Normal file
19
.automation/test/php_psalm/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# 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_psalm/php_bad_1.php
Normal file
3
.automation/test/php_psalm/php_bad_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29
|
15
.automation/test/php_psalm/php_bad_2.php
Normal file
15
.automation/test/php_psalm/php_bad_2.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function takesAnInt(int $i) {
|
||||
return [$i, "hello"];
|
||||
}
|
||||
|
||||
$data = ["some text", 5];
|
||||
takesAnInt($data[0]);
|
||||
|
||||
$condition = rand(0, 5);
|
||||
iff ($condition) {
|
||||
} elseif ($condition) {}
|
3
.automation/test/php_psalm/php_good_1.php
Normal file
3
.automation/test/php_psalm/php_good_1.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo "Hello World!", PHP_EOL;
|
25
.automation/test/php_psalm/php_good_2.php
Normal file
25
.automation/test/php_psalm/php_good_2.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
function helloName(string $name): array
|
||||
{
|
||||
return ["hello", $name];
|
||||
}
|
||||
|
||||
function helloSuperLinter(): void
|
||||
{
|
||||
$hello = helloName("Super-Linter");
|
||||
echo implode(" ", $hello) . PHP_EOL;
|
||||
}
|
||||
|
||||
function helloOrWorld(): void
|
||||
{
|
||||
$random = rand(0, 10);
|
||||
if ($random >= 5) {
|
||||
echo "Hello";
|
||||
} else {
|
||||
echo "World";
|
||||
}
|
||||
}
|
12
.automation/test/php_psalm/reports/expected-PHP_BUILTIN.tap
Normal file
12
.automation/test/php_psalm/reports/expected-PHP_BUILTIN.tap
Normal file
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected 'pe98y' (T_STRING) in /tmp/lint/.automation/test/php/php_bad_1.php on line 3\nErrors parsing /tmp/lint/.automation/test/php/php_bad_1.php\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: PHP Parse error syntax error, unexpected '}' in /tmp/lint/.automation/test/php/php_bad_2.php on line 15\nErrors parsing /tmp/lint/.automation/test/php/php_bad_2.php\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_1.php\n----------------------------------------------------------------------\nFOUND 7 ERRORS AFFECTING 1 LINE\n----------------------------------------------------------------------\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "="; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space before "-"; 0 found\n 3 | ERROR | [x] Expected at least 1 space after "-"; 0 found\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: \nFILE /tmp/lint/.automation/test/php/php_bad_2.php\n----------------------------------------------------------------------\nFOUND 4 ERRORS AND 1 WARNING AFFECTING 4 LINES\n----------------------------------------------------------------------\n 1 | WARNING | [ ] A file should declare new symbols (classes,\n | | functions, constants, etc.) and cause no other\n | | side effects, or it should execute logic with\n | | side effects, but should not do both. The first\n | | symbol is defined on line 6 and the first side\n | | effect is on line 10.\n 6 | ERROR | [x] Opening brace should be on a new line\n 14 | ERROR | [x] Space before opening parenthesis of function call\n | | prohibited\n 15 | ERROR | [x] Newline required after opening brace\n 15 | ERROR | [x] Closing brace must be on a line by itself\n----------------------------------------------------------------------\nPHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY\n----------------------------------------------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
12
.automation/test/php_psalm/reports/expected-PHP_PHPSTAN.tap
Normal file
12
.automation/test/php_psalm/reports/expected-PHP_PHPSTAN.tap
Normal file
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: ------ ---------------------------------------------- \n Line php_bad_1.php \n ------ ---------------------------------------------- \n 3 Invalid numeric literal on line 3 \n 3 Invalid numeric literal on line 3 \n 3 Syntax error, unexpected '=' on line 3 \n 3 Syntax error, unexpected T_LNUMBER on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n 3 Syntax error, unexpected T_STRING on line 3 \n ------ ---------------------------------------------- \n\n [ERROR] Found 6 errors \n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: ------ ----------------------------------------- \n Line php_bad_2.php \n ------ ----------------------------------------- \n 15 Syntax error, unexpected '}' on line 15 \n ------ ----------------------------------------- \n\n [ERROR] Found 1 error \n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
|
@ -0,0 +1,12 @@
|
|||
TAP version 13
|
||||
1..4
|
||||
not ok 1 - php_bad_1.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR ParseError - php/php_bad_1.php 3 2 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 2 - Const pe98y is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 8 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 10 - Const n0u823n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 17 - Syntax error, unexpected '=' on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 18 - Const r is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 21 - Invalid numeric literal on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 24 - Const u3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 28 - Const r08u2q098ry is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 40 - Syntax error, unexpected T_LNUMBER on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 42 - Const nq2yr09n2yr9 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 55 - Const y2n is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR ParseError - php/php_bad_1.php 3 61 - Syntax error, unexpected T_STRING on line 3 (see https //psalm.dev/173)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 61 - Const yr is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\nERROR UndefinedConstant - php/php_bad_1.php 3 68 - Const yr3 is not defined (see https //psalm.dev/020)\n2pe98y r-n0u823n=r 092u3- r08u2q098ry 09nq2yr09n2yr9 y2n-93yr 298yr3 29\n\n\n------------------------------\n15 errors found\n------------------------------\n\n
|
||||
...
|
||||
not ok 2 - php_bad_2.php
|
||||
---
|
||||
message: Scanning files...\nAnalyzing files...\n\nE\n\nERROR InvalidReturnType - php/php_bad_2.php 4 12 - The declared return type 'array<array-key, string>' for takesAnInt is incorrect, got 'array{int, string(hello)}' (see https //psalm.dev/011)\n * @return array<string>\n\n\nERROR InvalidReturnStatement - php/php_bad_2.php 7 12 - The inferred type 'array{int, string(hello)}' does not match the declared return type 'array<array-key, string>' for takesAnInt (see https //psalm.dev/128)\n return [$i, "hello"];\n\n\nERROR InvalidScalarArgument - php/php_bad_2.php 11 12 - Argument 1 of takesAnInt expects int, string(some text) provided (see https //psalm.dev/012)\ntakesAnInt($data[0]);\n\n\nERROR ParseError - php/php_bad_2.php 15 1 - Syntax error, unexpected '}' on line 15 (see https //psalm.dev/173)\n} elseif ($condition) {}\n\n\n------------------------------\n4 errors found\n------------------------------\nPsalm can automatically fix 1 of these issues.\nRun Psalm again with \n[30;48;5;195m--alter --issues=InvalidReturnType --dry-run\nto see what it can fix.\n------------------------------\n\n
|
||||
...
|
||||
ok 3 - php_good_1.php
|
||||
ok 4 - php_good_2.php
|
19
.automation/test/python_flake8/README.md
Normal file
19
.automation/test/python_flake8/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Python Test Cases
|
||||
|
||||
This folder holds the test cases for **Python**.
|
||||
|
||||
## 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.
|
156
.automation/test/python_flake8/python_bad_1.py
Normal file
156
.automation/test/python_flake8/python_bad_1.py
Normal file
|
@ -0,0 +1,156 @@
|
|||
import json
|
||||
from os import getenv, path
|
||||
from pprint import pprint
|
||||
import sys
|
||||
|
||||
import click # pylint: disable=import-error
|
||||
from dotenv import load_dotenv # pylint: disable=import-error
|
||||
import requests # pylint: disable=import-error
|
||||
|
||||
env = load_dotenv()
|
||||
api_url = getenv(API_URL, default='https://api.github.com/graphql' )
|
||||
github_token = getenv("GITHUB_TOKEN",
|
||||
default=None)
|
||||
|
||||
if github_token is None
|
||||
sys.exit("GitHub Token is not set." +
|
||||
"Please set the GITHUB_TOKEN env variable in your system or " +
|
||||
"the .env file of your project.")
|
||||
|
||||
client_id = getenv(CLIENT_ID, default='copy_labels.py')
|
||||
headers = {
|
||||
'Authorization': 'bearer {github_token}'.format(github_token=github_token),
|
||||
'Accept': 'application/vnd.github.bane-preview+json'
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
def create_label(repo_id, label):
|
||||
"""
|
||||
Create label in the supplied repo.
|
||||
|
||||
:param repo_id: Unique ID that represents the repo in GitHub
|
||||
:type repo_id: str
|
||||
:param label: Object with label information.
|
||||
:type label: dict
|
||||
:return: GitHub API request response
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"createLabelInput": {
|
||||
"color": label["color"],
|
||||
"description": label["description"],
|
||||
"name": label["name"],
|
||||
"repositoryId": repo_id
|
||||
}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/create_label.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
print('Created label {label}'.format(label=label["name"]))
|
||||
|
||||
return response
|
||||
|
||||
def get_labels(owner, repo):
|
||||
"""
|
||||
Gets a list of labels from the supplied repo.
|
||||
:param owner: Repo owner GitHub login.
|
||||
:type owner: str
|
||||
:param repo: Repository name.
|
||||
:type repo: str
|
||||
:return: A tuple with the GitHub id for the repository and a list of labels defined in the repository
|
||||
"""
|
||||
|
||||
query_variables = { "owner": owner, "name": repo, }
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/get_repo_data.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
status_code = response.status_code
|
||||
result = response.json()
|
||||
|
||||
if status_code >= 200 and status_code <= 300:
|
||||
repo_id = result["data"]["repository"]["id"]
|
||||
labels = result["data"]["repository"]["labels"]["nodes"]
|
||||
|
||||
return repo_id, labels
|
||||
else:
|
||||
raise Exception(
|
||||
'[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}'.format(
|
||||
status_code=status_code, result=result["message"]))
|
||||
|
||||
def delete_label(label_id):
|
||||
"""
|
||||
Delete the specified label
|
||||
:param label_id: Label's node id.
|
||||
:type label_id: str
|
||||
:return: GitHub API request response.
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"deleteLabelInput": {
|
||||
"clientMutationId": client_id,
|
||||
"id": label_id,
|
||||
}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/delete_label.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
result = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
|
||||
return result
|
||||
|
||||
@click.command()
|
||||
@click.option('--dry', is_flag=True)
|
||||
@click.argument('source_repo')
|
||||
@click.argument('target_repo')
|
||||
def copy_labels(source_repo, target_repo, dry):
|
||||
"""
|
||||
Copy labels from the source repository to the target repository.
|
||||
\f
|
||||
:param source: The full name of a GitHub repo from where the labels will be copied from. Eg. github/opensourcefriday
|
||||
:type source: str
|
||||
:param target: The full name of a GitHub repo to where the labels will be copied. Eg. github/opensourcefriday
|
||||
:type target: str
|
||||
:return:
|
||||
"""
|
||||
source_owner, source_repo_name = source_repo.split("/")
|
||||
target_owner, target_repo_name = target_repo.split("/")
|
||||
|
||||
try:
|
||||
print('Fetching labels for {source_repo_name} repo.'.format(source_repo_name=source_repo_name))
|
||||
_, source_repo_labels = get_labels(source_owner, source_repo_name)
|
||||
print('Fetched labels for {source_repo_name}'.format(source_repo_name=source_repo_name))
|
||||
|
||||
print('Fetching labels for {target_repo_name} repo.'.format(target_repo_name=target_repo_name))
|
||||
target_repo_id, target_repo_labels = get_labels(target_owner, target_repo_name)
|
||||
print('Fetched labels for {target_repo_name}'.format(target_repo_name=target_repo_name))
|
||||
|
||||
filtered_labels = list(filter(lambda x: x not in target_repo_labels, source_repo_labels))
|
||||
|
||||
if dry:
|
||||
print('This is just a dry run. No labels will be copied/created.')
|
||||
print('{label_count} labels would have been created.'.format(label_count=len(filtered_labels)))
|
||||
pprint(filtered_labels, indent=4)
|
||||
else:
|
||||
print('Preparing to created {label_count} labels in {target_repo}'.format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo))
|
||||
|
||||
for label in filtered_labels:
|
||||
create_label(target_repo_id, label)
|
||||
except Exception as error:
|
||||
sys.exit(error)
|
||||
|
||||
print('Done')
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Pylint doesn't know that @click.command takes care of injecting the
|
||||
# function parameters. Disabling Pylint error.
|
||||
copy_labels() # pylint: disable=no-value-for-parameter
|
195
.automation/test/python_flake8/python_good_1.py
Normal file
195
.automation/test/python_flake8/python_good_1.py
Normal file
|
@ -0,0 +1,195 @@
|
|||
import json
|
||||
from os import getenv, path
|
||||
from pprint import pprint
|
||||
import sys
|
||||
|
||||
import click # pylint: disable=import-error
|
||||
from dotenv import load_dotenv # pylint: disable=import-error
|
||||
import requests # pylint: disable=import-error
|
||||
|
||||
env = load_dotenv()
|
||||
api_url = getenv("API_URL", default="https://api.github.com/graphql")
|
||||
github_token = getenv("GITHUB_TOKEN", default=None)
|
||||
|
||||
if github_token is None:
|
||||
sys.exit(
|
||||
"GitHub Token is not set."
|
||||
+ "Please set the GITHUB_TOKEN env variable in your system or "
|
||||
+ "the .env file of your project."
|
||||
)
|
||||
|
||||
client_id = getenv("CLIENT_ID", default="copy_labels.py")
|
||||
headers = {
|
||||
"Authorization": "bearer {github_token}".format(github_token=github_token),
|
||||
"Accept": "application/vnd.github.bane-preview+json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def create_label(repo_id, label):
|
||||
"""
|
||||
Create label in the supplied repo.
|
||||
|
||||
:param repo_id: Unique ID that represents the repo in GitHub
|
||||
:type repo_id: str
|
||||
:param label: Object with label information.
|
||||
:type label: dict
|
||||
:return: GitHub API request response
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"createLabelInput": {
|
||||
"color": label["color"],
|
||||
"description": label["description"],
|
||||
"name": label["name"],
|
||||
"repositoryId": repo_id,
|
||||
}
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/create_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
print("Created label {label}".format(label=label["name"]))
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_labels(owner, repo):
|
||||
"""
|
||||
Gets a list of labels from the supplied repo.
|
||||
:param owner: Repo owner GitHub login.
|
||||
:type owner: str
|
||||
:param repo: Repository name.
|
||||
:type repo: str
|
||||
:return: A tuple with the GitHub id for the repository and a list of labels defined in the repository
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"owner": owner,
|
||||
"name": repo,
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/get_repo_data.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
status_code = response.status_code
|
||||
result = response.json()
|
||||
|
||||
if status_code >= 200 and status_code <= 300:
|
||||
repo_id = result["data"]["repository"]["id"]
|
||||
labels = result["data"]["repository"]["labels"]["nodes"]
|
||||
|
||||
return repo_id, labels
|
||||
else:
|
||||
raise Exception(
|
||||
"[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}".format(
|
||||
status_code=status_code, result=result["message"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def delete_label(label_id):
|
||||
"""
|
||||
Delete the specified label
|
||||
:param label_id: Label's node id.
|
||||
:type label_id: str
|
||||
:return: GitHub API request response.
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"deleteLabelInput": {"clientMutationId": client_id, "id": label_id}
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/delete_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
result = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--dry", is_flag=True)
|
||||
@click.argument("source_repo")
|
||||
@click.argument("target_repo")
|
||||
def copy_labels(source_repo, target_repo, dry):
|
||||
"""
|
||||
Copy labels from the source repository to the target repository.
|
||||
\f
|
||||
:param source: The full name of a GitHub repo from where the labels will be copied from. Eg. github/opensourcefriday
|
||||
:type source: str
|
||||
:param target: The full name of a GitHub repo to where the labels will be copied. Eg. github/opensourcefriday
|
||||
:type target: str
|
||||
:return:
|
||||
"""
|
||||
source_owner, source_repo_name = source_repo.split("/")
|
||||
target_owner, target_repo_name = target_repo.split("/")
|
||||
|
||||
try:
|
||||
print(
|
||||
"Fetching labels for {source_repo_name} repo.".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
_, source_repo_labels = get_labels(source_owner, source_repo_name)
|
||||
print(
|
||||
"Fetched labels for {source_repo_name}".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
print(
|
||||
"Fetching labels for {target_repo_name} repo.".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
target_repo_id, target_repo_labels = get_labels(target_owner, target_repo_name)
|
||||
print(
|
||||
"Fetched labels for {target_repo_name}".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
filtered_labels = list(
|
||||
filter(lambda x: x not in target_repo_labels, source_repo_labels)
|
||||
)
|
||||
|
||||
if dry:
|
||||
print("This is just a dry run. No labels will be copied/created.")
|
||||
print(
|
||||
"{label_count} labels would have been created.".format(
|
||||
label_count=len(filtered_labels)
|
||||
)
|
||||
)
|
||||
pprint(filtered_labels, indent=4)
|
||||
else:
|
||||
print(
|
||||
"Preparing to created {label_count} labels in {target_repo}".format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo
|
||||
)
|
||||
)
|
||||
|
||||
for label in filtered_labels:
|
||||
create_label(target_repo_id, label)
|
||||
except Exception as error:
|
||||
sys.exit(error)
|
||||
|
||||
print("Done")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Pylint doesn't know that @click.command takes care of injecting the
|
||||
# function parameters. Disabling Pylint error.
|
||||
copy_labels() # pylint: disable=no-value-for-parameter
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - python_bad_1.py
|
||||
---
|
||||
message: ************* Module python_bad_1\npython/python_bad_1.py 15 24 E0001 invalid syntax (<unknown>, line 15) (syntax-error)\n
|
||||
...
|
||||
ok 2 - python_good_1.py
|
19
.automation/test/python_pylint/README.md
Normal file
19
.automation/test/python_pylint/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Python Test Cases
|
||||
|
||||
This folder holds the test cases for **Python**.
|
||||
|
||||
## 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.
|
156
.automation/test/python_pylint/python_bad_1.py
Normal file
156
.automation/test/python_pylint/python_bad_1.py
Normal file
|
@ -0,0 +1,156 @@
|
|||
import json
|
||||
from os import getenv, path
|
||||
from pprint import pprint
|
||||
import sys
|
||||
|
||||
import click # pylint: disable=import-error
|
||||
from dotenv import load_dotenv # pylint: disable=import-error
|
||||
import requests # pylint: disable=import-error
|
||||
|
||||
env = load_dotenv()
|
||||
api_url = getenv(API_URL, default='https://api.github.com/graphql' )
|
||||
github_token = getenv("GITHUB_TOKEN",
|
||||
default=None)
|
||||
|
||||
if github_token is None
|
||||
sys.exit("GitHub Token is not set." +
|
||||
"Please set the GITHUB_TOKEN env variable in your system or " +
|
||||
"the .env file of your project.")
|
||||
|
||||
client_id = getenv(CLIENT_ID, default='copy_labels.py')
|
||||
headers = {
|
||||
'Authorization': 'bearer {github_token}'.format(github_token=github_token),
|
||||
'Accept': 'application/vnd.github.bane-preview+json'
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
def create_label(repo_id, label):
|
||||
"""
|
||||
Create label in the supplied repo.
|
||||
|
||||
:param repo_id: Unique ID that represents the repo in GitHub
|
||||
:type repo_id: str
|
||||
:param label: Object with label information.
|
||||
:type label: dict
|
||||
:return: GitHub API request response
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"createLabelInput": {
|
||||
"color": label["color"],
|
||||
"description": label["description"],
|
||||
"name": label["name"],
|
||||
"repositoryId": repo_id
|
||||
}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/create_label.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
print('Created label {label}'.format(label=label["name"]))
|
||||
|
||||
return response
|
||||
|
||||
def get_labels(owner, repo):
|
||||
"""
|
||||
Gets a list of labels from the supplied repo.
|
||||
:param owner: Repo owner GitHub login.
|
||||
:type owner: str
|
||||
:param repo: Repository name.
|
||||
:type repo: str
|
||||
:return: A tuple with the GitHub id for the repository and a list of labels defined in the repository
|
||||
"""
|
||||
|
||||
query_variables = { "owner": owner, "name": repo, }
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/get_repo_data.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
status_code = response.status_code
|
||||
result = response.json()
|
||||
|
||||
if status_code >= 200 and status_code <= 300:
|
||||
repo_id = result["data"]["repository"]["id"]
|
||||
labels = result["data"]["repository"]["labels"]["nodes"]
|
||||
|
||||
return repo_id, labels
|
||||
else:
|
||||
raise Exception(
|
||||
'[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}'.format(
|
||||
status_code=status_code, result=result["message"]))
|
||||
|
||||
def delete_label(label_id):
|
||||
"""
|
||||
Delete the specified label
|
||||
:param label_id: Label's node id.
|
||||
:type label_id: str
|
||||
:return: GitHub API request response.
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"deleteLabelInput": {
|
||||
"clientMutationId": client_id,
|
||||
"id": label_id,
|
||||
}
|
||||
}
|
||||
|
||||
with open(path.join(path.dirname(__file__), 'queries/delete_label.gql'), 'r') as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
result = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
|
||||
return result
|
||||
|
||||
@click.command()
|
||||
@click.option('--dry', is_flag=True)
|
||||
@click.argument('source_repo')
|
||||
@click.argument('target_repo')
|
||||
def copy_labels(source_repo, target_repo, dry):
|
||||
"""
|
||||
Copy labels from the source repository to the target repository.
|
||||
\f
|
||||
:param source: The full name of a GitHub repo from where the labels will be copied from. Eg. github/opensourcefriday
|
||||
:type source: str
|
||||
:param target: The full name of a GitHub repo to where the labels will be copied. Eg. github/opensourcefriday
|
||||
:type target: str
|
||||
:return:
|
||||
"""
|
||||
source_owner, source_repo_name = source_repo.split("/")
|
||||
target_owner, target_repo_name = target_repo.split("/")
|
||||
|
||||
try:
|
||||
print('Fetching labels for {source_repo_name} repo.'.format(source_repo_name=source_repo_name))
|
||||
_, source_repo_labels = get_labels(source_owner, source_repo_name)
|
||||
print('Fetched labels for {source_repo_name}'.format(source_repo_name=source_repo_name))
|
||||
|
||||
print('Fetching labels for {target_repo_name} repo.'.format(target_repo_name=target_repo_name))
|
||||
target_repo_id, target_repo_labels = get_labels(target_owner, target_repo_name)
|
||||
print('Fetched labels for {target_repo_name}'.format(target_repo_name=target_repo_name))
|
||||
|
||||
filtered_labels = list(filter(lambda x: x not in target_repo_labels, source_repo_labels))
|
||||
|
||||
if dry:
|
||||
print('This is just a dry run. No labels will be copied/created.')
|
||||
print('{label_count} labels would have been created.'.format(label_count=len(filtered_labels)))
|
||||
pprint(filtered_labels, indent=4)
|
||||
else:
|
||||
print('Preparing to created {label_count} labels in {target_repo}'.format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo))
|
||||
|
||||
for label in filtered_labels:
|
||||
create_label(target_repo_id, label)
|
||||
except Exception as error:
|
||||
sys.exit(error)
|
||||
|
||||
print('Done')
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Pylint doesn't know that @click.command takes care of injecting the
|
||||
# function parameters. Disabling Pylint error.
|
||||
copy_labels() # pylint: disable=no-value-for-parameter
|
195
.automation/test/python_pylint/python_good_1.py
Normal file
195
.automation/test/python_pylint/python_good_1.py
Normal file
|
@ -0,0 +1,195 @@
|
|||
import json
|
||||
from os import getenv, path
|
||||
from pprint import pprint
|
||||
import sys
|
||||
|
||||
import click # pylint: disable=import-error
|
||||
from dotenv import load_dotenv # pylint: disable=import-error
|
||||
import requests # pylint: disable=import-error
|
||||
|
||||
env = load_dotenv()
|
||||
api_url = getenv("API_URL", default="https://api.github.com/graphql")
|
||||
github_token = getenv("GITHUB_TOKEN", default=None)
|
||||
|
||||
if github_token is None:
|
||||
sys.exit(
|
||||
"GitHub Token is not set."
|
||||
+ "Please set the GITHUB_TOKEN env variable in your system or "
|
||||
+ "the .env file of your project."
|
||||
)
|
||||
|
||||
client_id = getenv("CLIENT_ID", default="copy_labels.py")
|
||||
headers = {
|
||||
"Authorization": "bearer {github_token}".format(github_token=github_token),
|
||||
"Accept": "application/vnd.github.bane-preview+json",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def create_label(repo_id, label):
|
||||
"""
|
||||
Create label in the supplied repo.
|
||||
|
||||
:param repo_id: Unique ID that represents the repo in GitHub
|
||||
:type repo_id: str
|
||||
:param label: Object with label information.
|
||||
:type label: dict
|
||||
:return: GitHub API request response
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"createLabelInput": {
|
||||
"color": label["color"],
|
||||
"description": label["description"],
|
||||
"name": label["name"],
|
||||
"repositoryId": repo_id,
|
||||
}
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/create_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
print("Created label {label}".format(label=label["name"]))
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_labels(owner, repo):
|
||||
"""
|
||||
Gets a list of labels from the supplied repo.
|
||||
:param owner: Repo owner GitHub login.
|
||||
:type owner: str
|
||||
:param repo: Repository name.
|
||||
:type repo: str
|
||||
:return: A tuple with the GitHub id for the repository and a list of labels defined in the repository
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"owner": owner,
|
||||
"name": repo,
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/get_repo_data.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||
|
||||
status_code = response.status_code
|
||||
result = response.json()
|
||||
|
||||
if status_code >= 200 and status_code <= 300:
|
||||
repo_id = result["data"]["repository"]["id"]
|
||||
labels = result["data"]["repository"]["labels"]["nodes"]
|
||||
|
||||
return repo_id, labels
|
||||
else:
|
||||
raise Exception(
|
||||
"[ERROR] getting issue labels. Status Code: {status_code} - Message: {result}".format(
|
||||
status_code=status_code, result=result["message"]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def delete_label(label_id):
|
||||
"""
|
||||
Delete the specified label
|
||||
:param label_id: Label's node id.
|
||||
:type label_id: str
|
||||
:return: GitHub API request response.
|
||||
"""
|
||||
|
||||
query_variables = {
|
||||
"deleteLabelInput": {"clientMutationId": client_id, "id": label_id}
|
||||
}
|
||||
|
||||
with open(
|
||||
path.join(path.dirname(__file__), "queries/delete_label.gql"), "r"
|
||||
) as query_file:
|
||||
query = "".join(query_file.readlines())
|
||||
|
||||
payload = {"query": query, "variables": query_variables}
|
||||
result = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--dry", is_flag=True)
|
||||
@click.argument("source_repo")
|
||||
@click.argument("target_repo")
|
||||
def copy_labels(source_repo, target_repo, dry):
|
||||
"""
|
||||
Copy labels from the source repository to the target repository.
|
||||
\f
|
||||
:param source: The full name of a GitHub repo from where the labels will be copied from. Eg. github/opensourcefriday
|
||||
:type source: str
|
||||
:param target: The full name of a GitHub repo to where the labels will be copied. Eg. github/opensourcefriday
|
||||
:type target: str
|
||||
:return:
|
||||
"""
|
||||
source_owner, source_repo_name = source_repo.split("/")
|
||||
target_owner, target_repo_name = target_repo.split("/")
|
||||
|
||||
try:
|
||||
print(
|
||||
"Fetching labels for {source_repo_name} repo.".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
_, source_repo_labels = get_labels(source_owner, source_repo_name)
|
||||
print(
|
||||
"Fetched labels for {source_repo_name}".format(
|
||||
source_repo_name=source_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
print(
|
||||
"Fetching labels for {target_repo_name} repo.".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
target_repo_id, target_repo_labels = get_labels(target_owner, target_repo_name)
|
||||
print(
|
||||
"Fetched labels for {target_repo_name}".format(
|
||||
target_repo_name=target_repo_name
|
||||
)
|
||||
)
|
||||
|
||||
filtered_labels = list(
|
||||
filter(lambda x: x not in target_repo_labels, source_repo_labels)
|
||||
)
|
||||
|
||||
if dry:
|
||||
print("This is just a dry run. No labels will be copied/created.")
|
||||
print(
|
||||
"{label_count} labels would have been created.".format(
|
||||
label_count=len(filtered_labels)
|
||||
)
|
||||
)
|
||||
pprint(filtered_labels, indent=4)
|
||||
else:
|
||||
print(
|
||||
"Preparing to created {label_count} labels in {target_repo}".format(
|
||||
label_count=len(filtered_labels), target_repo=target_repo
|
||||
)
|
||||
)
|
||||
|
||||
for label in filtered_labels:
|
||||
create_label(target_repo_id, label)
|
||||
except Exception as error:
|
||||
sys.exit(error)
|
||||
|
||||
print("Done")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Pylint doesn't know that @click.command takes care of injecting the
|
||||
# function parameters. Disabling Pylint error.
|
||||
copy_labels() # pylint: disable=no-value-for-parameter
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - python_bad_1.py
|
||||
---
|
||||
message: ************* Module python_bad_1\npython/python_bad_1.py 15 24 E0001 invalid syntax (<unknown>, line 15) (syntax-error)\n
|
||||
...
|
||||
ok 2 - python_good_1.py
|
19
.automation/test/snakemake_snakefmt/README.md
Normal file
19
.automation/test/snakemake_snakefmt/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Snakemake test cases
|
||||
|
||||
This folder holds the test cases for **Snakemake**.
|
||||
|
||||
## 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.
|
11
.automation/test/snakemake_snakefmt/snakemake_bad_1.smk
Normal file
11
.automation/test/snakemake_snakefmt/snakemake_bad_1.smk
Normal file
|
@ -0,0 +1,11 @@
|
|||
rule all:
|
||||
input:
|
||||
file1='result.txt',
|
||||
|
||||
rule simulation:
|
||||
output:
|
||||
file1="result.txt"
|
||||
shell:
|
||||
"""
|
||||
touch {output}
|
||||
"""
|
16
.automation/test/snakemake_snakefmt/snakemake_good_1.smk
Normal file
16
.automation/test/snakemake_snakefmt/snakemake_good_1.smk
Normal file
|
@ -0,0 +1,16 @@
|
|||
rule all:
|
||||
input:
|
||||
file1="result.txt",
|
||||
|
||||
|
||||
rule simulation:
|
||||
output:
|
||||
file1="result.txt",
|
||||
log:
|
||||
"logs/simulation.log",
|
||||
conda:
|
||||
"envs/simulation.yml"
|
||||
shell:
|
||||
"""
|
||||
touch {output}
|
||||
"""
|
19
.automation/test/typescript_standard/README.md
Normal file
19
.automation/test/typescript_standard/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Typescript Test Cases
|
||||
|
||||
This folder holds the test cases for **Typescript**.
|
||||
|
||||
## Additional Docs
|
||||
|
||||
No Additional information is needed for this test case.
|
||||
|
||||
## Good Test Cases
|
||||
|
||||
The test cases denoted: `LANGUAGE_good_FILE.EXTENSION` are all valid, and should pass successfully when linted.
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
||||
|
||||
## Bad Test Cases
|
||||
|
||||
The test cases denoted: `LANGUAGE_bad_FILE.EXTENSION` are **NOT** valid, and should trigger errors when linted.
|
||||
|
||||
- **Note:** They are linted utilizing the default linter rules.
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - typescript_bad_1.ts
|
||||
---
|
||||
message: \n/tmp/lint/.automation/test/typescript/typescript_bad_1.ts\n 5 39 error Parsing error Unterminated regular expression literal\n\n✖ 1 problem (1 error, 0 warnings)\n
|
||||
...
|
||||
ok 2 - typescript_good_1.ts
|
|
@ -0,0 +1,7 @@
|
|||
TAP version 13
|
||||
1..2
|
||||
not ok 1 - typescript_bad_1.ts
|
||||
---
|
||||
message: standard Use JavaScript Standard Style (https //standardjs.com)\n /tmp/lint/.automation/test/typescript/typescript_bad_1.ts 5 39 Parsing error Unterminated regular expression literal.\n
|
||||
...
|
||||
ok 2 - typescript_good_1.ts
|
8
.automation/test/typescript_standard/typescript_bad_1.ts
Normal file
8
.automation/test/typescript_standard/typescript_bad_1.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
const spiderman = (person: String) => {
|
||||
return 'Hello, ' + person;
|
||||
}
|
||||
|
||||
var handler = createHandler( { path : /webhook, secret : (process.env.SECRET) })
|
||||
|
||||
let user = 1;
|
||||
console.log(spiderman(user));
|
|
@ -0,0 +1,6 @@
|
|||
const spiderman = (person) => {
|
||||
return 'Hello, ' + person
|
||||
}
|
||||
|
||||
const user = 'Peter Parker'
|
||||
console.log(spiderman(user))
|
1
.eslintignore
Normal file
1
.eslintignore
Normal file
|
@ -0,0 +1 @@
|
|||
!.automation
|
2
.github/workflows/deploy-DEV.yml
vendored
2
.github/workflows/deploy-DEV.yml
vendored
|
@ -82,4 +82,4 @@ jobs:
|
|||
############################################
|
||||
- name: Run against all code base
|
||||
shell: bash
|
||||
run: docker run -e RUN_LOCAL=true -e OUTPUT_DETAILS=detailed -v ACTIONS_RUNNER_DEBUG=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
run: docker run -e RUN_LOCAL=true -e OUTPUT_DETAILS=detailed -e ACTIONS_RUNNER_DEBUG=true -v ${GITHUB_WORKSPACE}:/tmp/lint github/super-linter:${GITHUB_SHA}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue