Skip to content

Commit 947d455

Browse files
committedJul 7, 2022
chore: code formatting
1 parent 33a2f43 commit 947d455

File tree

18 files changed

+44
-35
lines changed

18 files changed

+44
-35
lines changed
 

‎.github/scripts/preview.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ for (const insights of ["insights", "about"]) {
104104
if (file !== ".statics")
105105
fs.copyFile(paths.join(__web_insights, file), paths.join(__preview_insights, file))
106106
}
107-
}
107+
}

‎source/app/metrics/index.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
3838
}
3939
: null),
4040
}
41-
const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error:false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error:false}) ? q["extras.js"] ?? "" : ""}
41+
const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error: false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error: false}) ? q["extras.js"] ?? "" : ""}
4242
const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], plugins: {}, computed: {}, extras, postscripts: []}
4343
const experimental = new Set(decodeURIComponent(q["experimental.features"] ?? "").split(" ").map(x => x.trim().toLocaleLowerCase()).filter(x => x))
4444
if (conf.settings["debug.headless"])
@@ -184,7 +184,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
184184
if ((conf.settings?.optimize === true) || (conf.settings?.optimize?.includes?.("svg")))
185185
rendered = await imports.svg.optimize.svg(rendered, q, experimental)
186186
//Verify svg
187-
if ((verify)&&(imports.metadata.plugins.core.extras("verify", {...conf.settings, error:false}))) {
187+
if ((verify) && (imports.metadata.plugins.core.extras("verify", {...conf.settings, error: false}))) {
188188
console.debug(`metrics/compute/${login} > verify SVG`)
189189
let libxmljs = null
190190
try {

‎source/app/metrics/metadata.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
265265
console.debug(`metrics/extras > ${name} > ${key} > skipping (no error mode)`)
266266
return false
267267
}
268-
throw Object.assign(new Error(`Unsupported option "${key}"`), {extras:true})
268+
throw Object.assign(new Error(`Unsupported option "${key}"`), {extras: true})
269269
}
270270
}
271271
}

‎source/app/metrics/setup.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default async function({log = true, sandbox = false, community = {}} = {}
7878
logger("metrics/setup > load package.json > success")
7979

8080
//Load community templates
81-
if ((conf.settings.extras?.features?.includes("metrics.setup.community.templates"))||(conf.settings.extras?.features === true)||(conf.settings.extras?.default)) {
81+
if ((conf.settings.extras?.features?.includes("metrics.setup.community.templates")) || (conf.settings.extras?.features === true) || (conf.settings.extras?.default)) {
8282
if ((typeof conf.settings.community.templates === "string") && (conf.settings.community.templates.length)) {
8383
logger("metrics/setup > parsing community templates list")
8484
conf.settings.community.templates = [...new Set([...decodeURIComponent(conf.settings.community.templates).split(",").map(v => v.trim().toLocaleLowerCase()).filter(v => v)])]
@@ -194,12 +194,12 @@ export default async function({log = true, sandbox = false, community = {}} = {}
194194
conf.metadata = await metadata({log})
195195

196196
//Modes
197-
if ((!conf.settings.modes)||(!conf.settings.modes.length))
197+
if ((!conf.settings.modes) || (!conf.settings.modes.length))
198198
conf.settings.modes = ["embed", "insights"]
199199
logger(`metrics/setup > setup > enabled modes ${JSON.stringify(conf.settings.modes)}`)
200200

201201
//Allowed outputs formats
202-
if ((!conf.settings.outputs)||(!conf.settings.outputs.length))
202+
if ((!conf.settings.outputs) || (!conf.settings.outputs.length))
203203
conf.settings.outputs = metadata.inputs.config_output.values
204204
else
205205
conf.settings.outputs = conf.settings.outputs.filter(format => metadata.inputs.config_output.values.includes(format))

‎source/app/metrics/utils.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function formatters({timeZone} = {}) {
148148
message = `API error: ${status}`
149149

150150
//Error description (optional)
151-
if ((descriptions)&&(descriptions[status]))
151+
if ((descriptions) && (descriptions[status]))
152152
message += ` (${descriptions[status]})`
153153
else {
154154
const description = error.response?.data?.errors?.[0]?.message ?? error.response.data?.error_description ?? error.response?.data?.message ?? null

‎source/app/web/instance.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export default async function({sandbox = false} = {}) {
338338
//Render
339339
const q = req.query
340340
console.debug(`metrics/app/${login} > ${util.inspect(q, {depth: Infinity, maxStringLength: 256})}`)
341-
if ((q["config.presets"]) && ((conf.settings.extras?.features?.includes("metrics.setup.community.presets"))||(conf.settings.extras?.features === true)||(conf.settings.extras?.default))) {
341+
if ((q["config.presets"]) && ((conf.settings.extras?.features?.includes("metrics.setup.community.presets")) || (conf.settings.extras?.features === true) || (conf.settings.extras?.default))) {
342342
console.debug(`metrics/app/${login} > presets have been specified, loading them`)
343343
Object.assign(q, await presets(q["config.presets"]))
344344
}

‎source/app/web/statics/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@
6666
},
6767
},
6868
//Methods
69-
methods:{
69+
methods: {
7070
//Metrics insights
7171
async insights() {
7272
window.location.href = `/insights?user=${this.user1}`
7373
},
7474
//Metrics embed
7575
async embed() {
7676
window.location.href = `/embed?user=${this.user2}`
77-
}
78-
}
77+
},
78+
},
7979
})
8080
})()

‎source/plugins/base/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default async function({login, graphql, rest, data, q, queries, imports,
8989
}
9090
//Query contributions collection over account lifetime instead of last year
9191
if (account === "user") {
92-
if ((indepth) && (imports.metadata.plugins.base.extras("indepth", {...conf.settings, error:false}))) {
92+
if ((indepth) && (imports.metadata.plugins.base.extras("indepth", {...conf.settings, error: false}))) {
9393
const fields = ["totalRepositoriesWithContributedCommits", "totalCommitContributions", "restrictedContributionsCount", "totalIssueContributions", "totalPullRequestContributions", "totalPullRequestReviewContributions"]
9494
const start = new Date(data.user.createdAt)
9595
const end = new Date()

‎source/plugins/community/screenshot/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ export default async function({login, q, imports, data, account}, {enabled = fal
3737
}
3838
//Handle errors
3939
catch (error) {
40-
throw imports.format.error(error, {title:"Screenshot error"})
40+
throw imports.format.error(error, {title: "Screenshot error"})
4141
}
4242
}

‎source/plugins/followup/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default async function({login, data, computed, imports, q, graphql, queri
5757
}
5858

5959
//Indepth mode
60-
if ((indepth)&&(imports.metadata.plugins.followup.extras("indepth", {extras}))) {
60+
if ((indepth) && (imports.metadata.plugins.followup.extras("indepth", {extras}))) {
6161
console.debug(`metrics/compute/${login}/plugins > followup > indepth`)
6262
followup.indepth = {repositories: {}}
6363

‎source/plugins/habits/index.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
9797
}
9898

9999
//Linguist
100-
if ((charts)&&((imports.metadata.plugins.habits.extras("charts", {extras, error:false})))) {
100+
if ((charts) && (imports.metadata.plugins.habits.extras("charts", {extras, error: false}))) {
101101
//Check if linguist exists
102102
console.debug(`metrics/compute/${login}/plugins > habits > searching recently used languages using linguist`)
103103
if (patches.length) {
@@ -113,7 +113,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
113113
}
114114

115115
//Generating charts with chartist
116-
if ((_charts === "chartist")&&(imports.metadata.plugins.habits.extras("charts.type", {extras}))) {
116+
if ((_charts === "chartist") && (imports.metadata.plugins.habits.extras("charts.type", {extras}))) {
117117
console.debug(`metrics/compute/${login}/plugins > habits > generating charts`)
118118
habits.charts = await Promise.all([
119119
{type: "line", data: {...empty(24), ...Object.fromEntries(Object.entries(habits.commits.hours).filter(([k]) => !Number.isNaN(+k)))}, low: 0, high: habits.commits.hours.max},

‎source/plugins/languages/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default async function({login, data, imports, q, rest, account}, {enabled
7676
}
7777

7878
//Indepth mode
79-
if ((indepth)&&(imports.metadata.plugins.languages.extras("indepth", {extras}))) {
79+
if ((indepth) && (imports.metadata.plugins.languages.extras("indepth", {extras}))) {
8080
//Fetch gpg keys (web-flow is GitHub's public key when making changes from web ui)
8181
const gpg = []
8282
try {

‎source/plugins/notable/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
3333
console.debug(`metrics/compute/${login}/plugins > notable > found ${contributions.length} notable contributions`)
3434

3535
//Indepth
36-
if ((indepth)&&(imports.metadata.plugins.notable.extras("indepth", {extras}))) {
36+
if ((indepth) && (imports.metadata.plugins.notable.extras("indepth", {extras}))) {
3737
console.debug(`metrics/compute/${login}/plugins > notable > indepth`)
3838

3939
//Fetch issues

‎source/plugins/pagespeed/index.mjs

+13-8
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ export default async function({login, imports, data, q, account}, {enabled = fal
4747
}
4848
//Handle errors
4949
catch (error) {
50-
throw imports.format.error(error, {descriptions:{"429":'(consider using "plugin_pagespeed_token")', custom(error) {
51-
const description = error.response?.data?.error?.message?.match(/Lighthouse returned error: (?<description>[A-Z_]+)/)?.groups?.description ?? null
52-
if (description) {
53-
const status = error.response?.status
54-
return `API error: ${status} (${description})`
55-
}
56-
return null
57-
}}})
50+
throw imports.format.error(error, {
51+
descriptions: {
52+
"429": '(consider using "plugin_pagespeed_token")',
53+
custom(error) {
54+
const description = error.response?.data?.error?.message?.match(/Lighthouse returned error: (?<description>[A-Z_]+)/)?.groups?.description ?? null
55+
if (description) {
56+
const status = error.response?.status
57+
return `API error: ${status} (${description})`
58+
}
59+
return null
60+
},
61+
},
62+
})
5863
}
5964
}

‎source/plugins/projects/index.mjs

+9-5
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,14 @@ export default async function({login, data, imports, graphql, q, queries, accoun
6666
}
6767
//Handle errors
6868
catch (error) {
69-
throw imports.format.error(error, {descriptions:{custom(error) {
70-
if (error.errors?.map(({type}) => type)?.includes("INSUFFICIENT_SCOPES"))
71-
return "Insufficient token scopes"
72-
return null
73-
}}})
69+
throw imports.format.error(error, {
70+
descriptions: {
71+
custom(error) {
72+
if (error.errors?.map(({type}) => type)?.includes("INSUFFICIENT_SCOPES"))
73+
return "Insufficient token scopes"
74+
return null
75+
},
76+
},
77+
})
7478
}
7579
}

‎source/plugins/stargazers/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default async function({login, graphql, data, imports, q, queries, accoun
5959

6060
//Generating charts
6161
let charts = null
62-
if ((_charts === "chartist")&&(imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
62+
if ((_charts === "chartist") && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
6363
console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`)
6464
charts = await Promise.all([{data: total, low: total.min, high: total.max}, {data: increments, ref: 0, low: increments.min, high: increments.max, sign: true}].map(({data: {dates: set}, high, low, ref, sign = false}) =>
6565
imports.chartist("line", {

‎source/plugins/traffic/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export default async function({login, imports, data, rest, q, account}, {enabled
2727
}
2828
//Handle errors
2929
catch (error) {
30-
throw imports.format.error(error, {descriptions:{"403":"Insufficient token scopes"}})
30+
throw imports.format.error(error, {descriptions: {"403": "Insufficient token scopes"}})
3131
}
3232
}

‎tests/metrics.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ describe("GitHub Action", () =>
119119
if ((skip.includes(template)) || ((modes.length) && (!modes.includes("action"))))
120120
test.skip(name, () => null)
121121
else
122-
test(name, async () => expect(await action.run({template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, retries:1, ...input})).toBe(true), timeout)
122+
test(name, async () => expect(await action.run({template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, retries: 1, ...input})).toBe(true), timeout)
123123
}
124124
}))
125125

0 commit comments

Comments
 (0)
Failed to load comments.