convert some service classes to static props, run [codacy codeclimate codecov] (#5514)

* refactor(codacy): convert to static props

* refactor(codeclimate): convert to static props

* refactor(codecov): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Caleb Cartwright
2020-09-12 11:55:45 -05:00
committed by GitHub
parent 55310c3ed0
commit 005b3ba4ac
5 changed files with 136 additions and 189 deletions

View File

@@ -14,19 +14,10 @@ const schema = Joi.object({
}).required()
module.exports = class CodacyCoverage extends BaseSvgScrapingService {
static get category() {
return 'coverage'
}
static category = 'coverage'
static route = { base: 'codacy/coverage', pattern: ':projectId/:branch*' }
static get route() {
return {
base: 'codacy/coverage',
pattern: ':projectId/:branch*',
}
}
static get examples() {
return [
static examples = [
{
title: 'Codacy coverage',
pattern: ':projectId',
@@ -43,13 +34,8 @@ module.exports = class CodacyCoverage extends BaseSvgScrapingService {
staticPreview: this.render({ percentage: 90 }),
},
]
}
static get defaultBadgeData() {
return {
label: 'coverage',
}
}
static defaultBadgeData = { label: 'coverage' }
static render({ percentage }) {
return {

View File

@@ -7,19 +7,10 @@ const { codacyGrade } = require('./codacy-helpers')
const schema = Joi.object({ message: codacyGrade }).required()
module.exports = class CodacyGrade extends BaseSvgScrapingService {
static get category() {
return 'analysis'
}
static category = 'analysis'
static route = { base: 'codacy/grade', pattern: ':projectId/:branch*' }
static get route() {
return {
base: 'codacy/grade',
pattern: ':projectId/:branch*',
}
}
static get examples() {
return [
static examples = [
{
title: 'Codacy grade',
pattern: ':projectId',
@@ -36,13 +27,8 @@ module.exports = class CodacyGrade extends BaseSvgScrapingService {
staticPreview: this.render({ grade: 'A' }),
},
]
}
static get defaultBadgeData() {
return {
label: 'code quality',
}
}
static defaultBadgeData = { label: 'code quality' }
static render({ grade }) {
const color = {

View File

@@ -88,20 +88,14 @@ const variantMap = {
}
module.exports = class CodeclimateAnalysis extends BaseJsonService {
static get category() {
return 'analysis'
}
static get route() {
return {
static category = 'analysis'
static route = {
base: 'codeclimate',
pattern:
':variant(maintainability|maintainability-percentage|tech-debt|issues)/:user/:repo',
}
}
static get examples() {
return [
static examples = [
{
title: 'Code Climate maintainability',
pattern:
@@ -138,7 +132,6 @@ module.exports = class CodeclimateAnalysis extends BaseJsonService {
keywords,
},
]
}
static render({ variant, ...props }) {
const { render } = variantMap[variant]

View File

@@ -17,19 +17,13 @@ const schema = Joi.object({
}).required()
module.exports = class CodeclimateCoverage extends BaseJsonService {
static get category() {
return 'coverage'
}
static get route() {
return {
static category = 'coverage'
static route = {
base: 'codeclimate',
pattern: ':format(coverage|coverage-letter)/:user/:repo',
}
}
static get examples() {
return [
static examples = [
{
title: 'Code Climate coverage',
namedParams: {
@@ -45,7 +39,6 @@ module.exports = class CodeclimateCoverage extends BaseJsonService {
keywords,
},
]
}
static render({ wantLetter, percentage, letter }) {
if (wantLetter) {

View File

@@ -46,23 +46,16 @@ const documentation = `
`
module.exports = class Codecov extends BaseSvgScrapingService {
static get category() {
return 'coverage'
}
static get route() {
return {
static category = 'coverage'
static route = {
base: 'codecov/c',
// https://docs.codecov.io/docs#section-common-questions
// Github, BitBucket, and GitLab are the only supported options (long or short form)
pattern:
':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch*',
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch*',
queryParamSchema,
}
}
static get examples() {
return [
static examples = [
{
title: 'Codecov',
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo',
@@ -80,8 +73,7 @@ module.exports = class Codecov extends BaseSvgScrapingService {
},
{
title: 'Codecov branch',
pattern:
':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch',
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch',
namedParams: {
vcsName: 'github',
user: 'codecov',
@@ -96,11 +88,8 @@ module.exports = class Codecov extends BaseSvgScrapingService {
documentation,
},
]
}
static get defaultBadgeData() {
return { label: 'coverage' }
}
static defaultBadgeData = { label: 'coverage' }
static render({ coverage }) {
if (coverage === 'unknown') {