Skip to content

Commit

Permalink
Fixes style
Browse files Browse the repository at this point in the history
  • Loading branch information
jeramysoucy committed Dec 27, 2023
1 parent c6f5ef6 commit af7fdc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
10 changes: 4 additions & 6 deletions lib/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
},

// retrieve issue IDs already created in GitHub
async existingIssues() {
async existingIssues () {
try {
return await octokit.paginate(
`GET /search/issues?q=repo%3A${conf.ghOwner}/${conf.ghRepo}+is%3Aissue+label%3Asnyk`,
Expand All @@ -31,8 +31,7 @@ module.exports = {
existingIssue.number
])
)
}
catch (err) {
} catch (err) {
throw new Error(`Failed to paginate octakit request for existing issues in repository ${conf.ghRepo}, error: ${err.message}`, { cause: err })
}
},
Expand All @@ -41,9 +40,8 @@ module.exports = {
if (conf.dryRun) return
try {
return await this.client.issues.create(options)
}
catch (err) {
throw new Error(`Failed to ${options.issue_number?'update':'create'} issue: ${options.issue_number?options.issue_number:options.title}, error: ${err.message}`, { cause: err })
} catch (err) {
throw new Error(`Failed to ${options.issue_number ? 'update' : 'create'} issue: ${options.issue_number ? options.issue_number : options.title}, error: ${err.message}`, { cause: err })
}
},

Expand Down
8 changes: 3 additions & 5 deletions lib/github/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const ensureLabelsAreCreated = async (octokit, client, ghOwner, ghRepo, issues)
}),
(response) => response.data
)
}
catch (err) {
} catch (err) {
throw new Error(`Failed to paginate octakit request for labels in repository ${ghRepo}, error: ${err.message}`, { cause: err })
}

Expand All @@ -75,7 +74,7 @@ const ensureLabelsAreCreated = async (octokit, client, ghOwner, ghRepo, issues)
await Promise.all(
labelsToCreate.map((name) => {
try {
client.issues
return client.issues
.createLabel({
owner: ghOwner,
repo: ghRepo,
Expand All @@ -84,8 +83,7 @@ const ensureLabelsAreCreated = async (octokit, client, ghOwner, ghRepo, issues)
.then(() => {
console.log(`Created GitHub label: "${name}"`)
})
}
catch (err) {
} catch (err) {
throw new Error(`Failed to create GitHub label '${name}', error: ${err.message}`, { cause: err })
}
})
Expand Down
16 changes: 7 additions & 9 deletions lib/snyk.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = class Snyk {
).orgs
}

async queryOrgInfo(organizationId) {
async queryOrgInfo (organizationId) {
try {
const response = await request({
method: 'get',
Expand All @@ -39,12 +39,11 @@ module.exports = class Snyk {
})

if (response.data === undefined || response.data.attributes === undefined || response.data.attributes.name === undefined) {
throw new Error (`expected response to include data.attributes.name`)
throw new Error('expected response to include data.attributes.name')
}

return response.data
}
catch (err) {
} catch (err) {
throw new Error(`Failed to query snyk organization with id ${organizationId}, error: ${err.message}`, { cause: err })
}
}
Expand All @@ -69,7 +68,7 @@ module.exports = class Snyk {
isMonitored:
project.attributes.status === 'active',
issueCountTotal,
browseUrl: `https://app.snyk.io/org/${organization.attributes.name.toLowerCase()}/project/${project.id}`,
browseUrl: `https://app.snyk.io/org/${organization.attributes.name.toLowerCase()}/project/${project.id}`
}
}).filter(({ id, isMonitored }) => {
if (selectedProjects.includes(id)) {
Expand Down Expand Up @@ -122,7 +121,7 @@ function getSeverities (minimumSeverity) {
return ['critical', 'high', 'medium', 'low']
}

async function paginateRestResponseData(url, headers, method = 'get') {
async function paginateRestResponseData (url, headers, method = 'get') {
try {
const reponseData = []
do {
Expand All @@ -133,13 +132,12 @@ async function paginateRestResponseData(url, headers, method = 'get') {
json: true
})
reponseData.push(...response.data)
if (response.links.next) url = baseRestUrl + response.links.next / trimStart('/rest')
if (response.links.next) url = baseRestUrl + response.links.next.trimStart('/rest')
else url = undefined
} while (url)

return reponseData
}
catch (err) {
} catch (err) {
throw new Error(`Failed to paginate request for ${method} ${url}, error: ${err.message}`, { cause: err })
}
}

0 comments on commit af7fdc5

Please sign in to comment.