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:
@@ -14,42 +14,28 @@ 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 [
|
||||
{
|
||||
title: 'Codacy coverage',
|
||||
pattern: ':projectId',
|
||||
namedParams: { projectId: '59d607d0e311408885e418004068ea58' },
|
||||
staticPreview: this.render({ percentage: 90 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Codacy coverage',
|
||||
pattern: ':projectId',
|
||||
namedParams: { projectId: '59d607d0e311408885e418004068ea58' },
|
||||
staticPreview: this.render({ percentage: 90 }),
|
||||
},
|
||||
{
|
||||
title: 'Codacy branch coverage',
|
||||
pattern: ':projectId/:branch',
|
||||
namedParams: {
|
||||
projectId: '59d607d0e311408885e418004068ea58',
|
||||
branch: 'master',
|
||||
},
|
||||
{
|
||||
title: 'Codacy branch coverage',
|
||||
pattern: ':projectId/:branch',
|
||||
namedParams: {
|
||||
projectId: '59d607d0e311408885e418004068ea58',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({ percentage: 90 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ percentage: 90 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'coverage',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'coverage' }
|
||||
|
||||
static render({ percentage }) {
|
||||
return {
|
||||
|
||||
@@ -7,42 +7,28 @@ 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 [
|
||||
{
|
||||
title: 'Codacy grade',
|
||||
pattern: ':projectId',
|
||||
namedParams: { projectId: 'e27821fb6289410b8f58338c7e0bc686' },
|
||||
staticPreview: this.render({ grade: 'A' }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Codacy grade',
|
||||
pattern: ':projectId',
|
||||
namedParams: { projectId: 'e27821fb6289410b8f58338c7e0bc686' },
|
||||
staticPreview: this.render({ grade: 'A' }),
|
||||
},
|
||||
{
|
||||
title: 'Codacy branch grade',
|
||||
pattern: ':projectId/:branch',
|
||||
namedParams: {
|
||||
projectId: 'e27821fb6289410b8f58338c7e0bc686',
|
||||
branch: 'master',
|
||||
},
|
||||
{
|
||||
title: 'Codacy branch grade',
|
||||
pattern: ':projectId/:branch',
|
||||
namedParams: {
|
||||
projectId: 'e27821fb6289410b8f58338c7e0bc686',
|
||||
branch: 'master',
|
||||
},
|
||||
staticPreview: this.render({ grade: 'A' }),
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ grade: 'A' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'code quality',
|
||||
}
|
||||
}
|
||||
static defaultBadgeData = { label: 'code quality' }
|
||||
|
||||
static render({ grade }) {
|
||||
const color = {
|
||||
|
||||
@@ -88,57 +88,50 @@ const variantMap = {
|
||||
}
|
||||
|
||||
module.exports = class CodeclimateAnalysis extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'analysis'
|
||||
static category = 'analysis'
|
||||
static route = {
|
||||
base: 'codeclimate',
|
||||
pattern:
|
||||
':variant(maintainability|maintainability-percentage|tech-debt|issues)/:user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'codeclimate',
|
||||
static examples = [
|
||||
{
|
||||
title: 'Code Climate maintainability',
|
||||
pattern:
|
||||
':variant(maintainability|maintainability-percentage|tech-debt|issues)/:user/:repo',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Code Climate maintainability',
|
||||
pattern:
|
||||
':format(maintainability|maintainability-percentage)/:user/:repo',
|
||||
namedParams: {
|
||||
format: 'maintainability',
|
||||
user: 'angular',
|
||||
repo: 'angular',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
variant: 'maintainability',
|
||||
maintainabilityLetter: 'F',
|
||||
}),
|
||||
keywords,
|
||||
':format(maintainability|maintainability-percentage)/:user/:repo',
|
||||
namedParams: {
|
||||
format: 'maintainability',
|
||||
user: 'angular',
|
||||
repo: 'angular',
|
||||
},
|
||||
{
|
||||
title: 'Code Climate issues',
|
||||
pattern: 'issues/:user/:repo',
|
||||
namedParams: { user: 'twbs', repo: 'bootstrap' },
|
||||
staticPreview: this.render({
|
||||
variant: 'issues',
|
||||
issueCount: '89',
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Code Climate technical debt',
|
||||
pattern: 'tech-debt/:user/:repo',
|
||||
namedParams: { user: 'angular', repo: 'angular' },
|
||||
staticPreview: this.render({
|
||||
variant: 'tech-debt',
|
||||
techDebtPercentage: 3.0,
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
variant: 'maintainability',
|
||||
maintainabilityLetter: 'F',
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Code Climate issues',
|
||||
pattern: 'issues/:user/:repo',
|
||||
namedParams: { user: 'twbs', repo: 'bootstrap' },
|
||||
staticPreview: this.render({
|
||||
variant: 'issues',
|
||||
issueCount: '89',
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Code Climate technical debt',
|
||||
pattern: 'tech-debt/:user/:repo',
|
||||
namedParams: { user: 'angular', repo: 'angular' },
|
||||
staticPreview: this.render({
|
||||
variant: 'tech-debt',
|
||||
techDebtPercentage: 3.0,
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
|
||||
static render({ variant, ...props }) {
|
||||
const { render } = variantMap[variant]
|
||||
|
||||
@@ -17,35 +17,28 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class CodeclimateCoverage extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'coverage'
|
||||
static category = 'coverage'
|
||||
static route = {
|
||||
base: 'codeclimate',
|
||||
pattern: ':format(coverage|coverage-letter)/:user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'codeclimate',
|
||||
pattern: ':format(coverage|coverage-letter)/:user/:repo',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Code Climate coverage',
|
||||
namedParams: {
|
||||
format: 'coverage',
|
||||
user: 'codeclimate',
|
||||
repo: 'codeclimate',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
format: 'coverage',
|
||||
percentage: 95.123,
|
||||
letter: 'A',
|
||||
}),
|
||||
keywords,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Code Climate coverage',
|
||||
namedParams: {
|
||||
format: 'coverage',
|
||||
user: 'codeclimate',
|
||||
repo: 'codeclimate',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
format: 'coverage',
|
||||
percentage: 95.123,
|
||||
letter: 'A',
|
||||
}),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
|
||||
static render({ wantLetter, percentage, letter }) {
|
||||
if (wantLetter) {
|
||||
|
||||
@@ -46,61 +46,50 @@ const documentation = `
|
||||
`
|
||||
|
||||
module.exports = class Codecov extends BaseSvgScrapingService {
|
||||
static get category() {
|
||||
return 'coverage'
|
||||
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*',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
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*',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Codecov',
|
||||
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo',
|
||||
namedParams: {
|
||||
vcsName: 'github',
|
||||
user: 'codecov',
|
||||
repo: 'example-node',
|
||||
},
|
||||
queryParams: {
|
||||
token: 'a1b2c3d4e5',
|
||||
flag: 'flag_name',
|
||||
},
|
||||
staticPreview: this.render({ coverage: 90 }),
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Codecov',
|
||||
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo',
|
||||
namedParams: {
|
||||
vcsName: 'github',
|
||||
user: 'codecov',
|
||||
repo: 'example-node',
|
||||
},
|
||||
{
|
||||
title: 'Codecov branch',
|
||||
pattern:
|
||||
':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch',
|
||||
namedParams: {
|
||||
vcsName: 'github',
|
||||
user: 'codecov',
|
||||
repo: 'example-node',
|
||||
branch: 'master',
|
||||
},
|
||||
queryParams: {
|
||||
token: 'a1b2c3d4e5',
|
||||
flag: 'flag_name',
|
||||
},
|
||||
staticPreview: this.render({ coverage: 90 }),
|
||||
documentation,
|
||||
queryParams: {
|
||||
token: 'a1b2c3d4e5',
|
||||
flag: 'flag_name',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ coverage: 90 }),
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Codecov branch',
|
||||
pattern: ':vcsName(github|gh|bitbucket|bb|gl|gitlab)/:user/:repo/:branch',
|
||||
namedParams: {
|
||||
vcsName: 'github',
|
||||
user: 'codecov',
|
||||
repo: 'example-node',
|
||||
branch: 'master',
|
||||
},
|
||||
queryParams: {
|
||||
token: 'a1b2c3d4e5',
|
||||
flag: 'flag_name',
|
||||
},
|
||||
staticPreview: this.render({ coverage: 90 }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'coverage' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'coverage' }
|
||||
|
||||
static render({ coverage }) {
|
||||
if (coverage === 'unknown') {
|
||||
|
||||
Reference in New Issue
Block a user