Showing 33 of 53 total issues
File github.ts
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
getAssignee,
getDefaultBranch as getDefaultBranchFromContext,
getIssueDescription,
getIssueLabels,
Function getConventionalPrTitlePrefix
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
export function getConventionalPrTitlePrefix(config: Config, labels: Array<string>) {
const mapping = getConventionalLabelMapping(config)
const conventionalLabels = Object.keys(mapping).filter(k => labels.includes(k)).map(k => mapping[k]);
const featureLabels = conventionalLabels.filter(cl => cl.prefix === 'feat')
if (featureLabels.length > 0) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function setupEventHandlers
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setupEventHandlers(app: Probot) {
app.on('issues.assigned', async ctx => {
await issueAssigned(app, ctx);
});
app.on('issue_comment.created', async ctx => {
Function getConventionalPrTitlePrefix
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getConventionalPrTitlePrefix(config: Config, labels: Array<string>) {
const mapping = getConventionalLabelMapping(config)
const conventionalLabels = Object.keys(mapping).filter(k => labels.includes(k)).map(k => mapping[k]);
const featureLabels = conventionalLabels.filter(cl => cl.prefix === 'feat')
if (featureLabels.length > 0) {
Function getConventionalLabelMapping
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getConventionalLabelMapping(config: Config) {
const mapping: ConventionalLabelMapping = {
bug: {prefix: 'fix', emoji: '🐛', breaking: false},
dependencies: {prefix: 'fix', emoji: '⬆️', breaking: false},
security: {prefix: 'fix', emoji: '🔒', breaking: false},
Function queryProjectIdsForIssue
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function queryProjectIdsForIssue(ctx: Context<any>) {
const queryProjectIds = `
query ($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) {
Function chatOpsCommandGiven
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function chatOpsCommandGiven(app: Probot, ctx: Context<any>, config: Config, comment: string) {
app.log.debug('ChatOps command received');
if (!isModeChatOps(config)) {
app.log.info('Received ChatOps command but current mode is not `chatops`');
}
Function handle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function handle(app: Probot, ctx: Context<any>, config: Config) {
if (skipForIssue(ctx, config)) {
app.log.info(`Skipping run for issue: ${getIssueTitle(ctx)}`)
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function handle
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function handle(app: Probot, ctx: Context<any>, config: Config) {
if (skipForIssue(ctx, config)) {
app.log.info(`Skipping run for issue: ${getIssueTitle(ctx)}`)
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getIssueBranchConfig
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function getIssueBranchConfig(ctx: Context<any>, config: Config) {
if (config.branches.length > 0) {
const issueLabels = getIssueLabelsForMatching(ctx)
for (const branchConfig of config.branches) {
const labels = branchConfig.label instanceof Array ? branchConfig.label : [branchConfig.label];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function slice
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function slice(tokens: Array<Token>, value: string) {
const startOperator = tokens.findIndex(t => t.value === '[')
const endOperator = tokens.findIndex(t => t.value === ']')
if (startOperator === -1 || endOperator === -1 || endOperator <= startOperator) {
return value
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function updatePrTitle
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function updatePrTitle(app: Probot, ctx: Context<any>, config: Config, pr: any, issueTitle: string, labels: Array<string>) {
Function updatePullRequestBody
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function updatePullRequestBody(ctx: Context<any>, issueNumber: number, pr: any, app: Probot, config: Config) {
Function updatePrBody
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function updatePrBody(app: Probot, ctx: Context<any>, config: Config, pr: any, body: any) {
Function updatePullRequestTitle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function updatePullRequestTitle(ctx: Context<any>, issueNumber: number, pr: any, app: Probot, config: Config) {
Function createPr
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function createPr(app: Probot, ctx: Context<any>, config: Config, username: string, branchName: string) {
Function createBranch
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function createBranch(app: Probot, ctx: Context<any>, config: Config, branchName: string, sha: string) {
Function pullRequest
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export async function pullRequest(app: Probot, ctx: Context<any>) {
const action = ctx.payload.action
app.log.debug(`Pull-Request was ${action}`)
const config = await loadConfig(ctx);
if (!config) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getBranchName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export async function getBranchName(ctx: Context<any>, config: Config, title: string) {
const number = getIssueNumber(ctx)
let result
if (config.branchName) {
if (config.branchName === 'tiny') {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function pullRequestClosed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export async function pullRequestClosed(_: Probot, ctx: Context<any>) {
if (ctx.payload.pull_request.merged === true) {
const config = await loadConfig(ctx);
if (config && config.autoCloseIssue) {
const branchName = ctx.payload.pull_request.head.ref
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"