robvanderleek/create-issue-branch

View on GitHub

Showing 53 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,
Severity: Minor
Found in src/github.ts - About 6 hrs to fix

    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) {
    Severity: Minor
    Found in src/config.ts - About 4 hrs to fix

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        app.on('pull_request.closed', async ctx => {
            try {
                await pullRequestClosed(app, ctx);
            } catch (e) {
                if (e instanceof Error) {
    Severity: Major
    Found in src/probot.ts and 1 other location - About 2 hrs to fix
    src/probot.ts on lines 55..67

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            async ctx => {
                try {
                    await pullRequest(app, ctx);
                } catch (e) {
                    if (e instanceof Error) {
    Severity: Major
    Found in src/probot.ts and 1 other location - About 2 hrs to fix
    src/probot.ts on lines 41..53

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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 => {
    Severity: Minor
    Found in src/probot.ts - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if (config.conventionalPrTitles) {
              const pr = ctx.payload.pull_request
              const branchName = pr.head.ref
              const issueNumber = getIssueNumberFromBranchName(branchName)
              if (issueNumber) {
      Severity: Major
      Found in src/webhooks/pull-request.ts and 1 other location - About 1 hr to fix
      src/webhooks/pull-request.ts on lines 23..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if (config.autoLinkIssue) {
              const pr = ctx.payload.pull_request;
              const branchName = pr.head.ref;
              const issueNumber = getIssueNumberFromBranchName(branchName);
              if (issueNumber) {
      Severity: Major
      Found in src/webhooks/pull-request.ts and 1 other location - About 1 hr to fix
      src/webhooks/pull-request.ts on lines 15..22

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 72.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export function skipForIssue(ctx: Context<any>, config: Config) {
          const branchConfig = getIssueBranchConfig(ctx, config)
          if (branchConfig) {
              return branchConfig.skip === true
          } else {
      Severity: Major
      Found in src/github.ts and 1 other location - About 1 hr to fix
      src/github.ts on lines 164..171

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export function skipBranchCreationForIssue(ctx: Context<any>, config: Config) {
          const branchConfig = getIssueBranchConfig(ctx, config)
          if (branchConfig) {
              return branchConfig.skipBranch === true
          } else {
      Severity: Major
      Found in src/github.ts and 1 other location - About 1 hr to fix
      src/github.ts on lines 155..162

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 66.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          try {
              if (config.copyIssueLabelsToPR) {
                  app.log.info('Copying issue labels to PR')
                  await copyIssueLabelsToPr(ctx, pr)
              }
      Severity: Major
      Found in src/github.ts and 1 other location - About 1 hr to fix
      src/github.ts on lines 285..299

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 64.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          try {
              const baseHeadSha = await getBranchHeadSha(ctx, base)
              const branchHeadSha = await getBranchHeadSha(ctx, branchName)
              if (branchHeadSha === baseHeadSha) {
                  app.log.info('Branch and base heads are equal, creating empty commit for PR')
      Severity: Major
      Found in src/github.ts and 1 other location - About 1 hr to fix
      src/github.ts on lines 353..373

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 64.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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) {
      Severity: Minor
      Found in src/config.ts - About 1 hr to fix

        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},
        Severity: Minor
        Found in src/config.ts - About 1 hr to fix

          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) {
          Severity: Minor
          Found in src/github.ts - About 1 hr to fix

            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`');
                }
            Severity: Minor
            Found in src/webhooks/comment-created.ts - About 1 hr to fix

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  if (shouldCreatePR) {
                      const assignee = getSender(ctx);
                      app.log.info(`Creating pull request for user ${assignee}`);
                      await createPr(app, ctx, config, assignee, branchName);
                  }
              Severity: Major
              Found in src/webhooks/issue-opened.ts and 2 other locations - About 1 hr to fix
              src/webhooks/comment-created.ts on lines 69..73
              src/webhooks/issue-assigned.ts on lines 50..54

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  if (shouldCreatePR) {
                      const assignee = getAssignee(ctx)
                      app.log.info(`Creating pull request for user ${assignee}`)
                      await createPr(app, ctx, config, assignee, branchName)
                  }
              Severity: Major
              Found in src/webhooks/issue-assigned.ts and 2 other locations - About 1 hr to fix
              src/webhooks/comment-created.ts on lines 69..73
              src/webhooks/issue-opened.ts on lines 50..54

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              const containsLowerCaseOperator = (tokens: Array<Token>) => tokens.length > 0 && tokens[tokens.length - 1].value === ',';
              Severity: Major
              Found in src/interpolate.ts and 1 other location - About 1 hr to fix
              src/interpolate.ts on lines 7..7

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                  if (shouldCreatePR) {
                      const sender = getSender(ctx);
                      app.log.info(`Creating pull request for user ${sender}`);
                      await createPr(app, ctx, config, sender, branchName);
                  }
              Severity: Major
              Found in src/webhooks/comment-created.ts and 2 other locations - About 1 hr to fix
              src/webhooks/issue-assigned.ts on lines 50..54
              src/webhooks/issue-opened.ts on lines 50..54

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              const containsUpperCaseOperator = (tokens: Array<Token>) => tokens.length > 0 && tokens[tokens.length - 1].value === '^';
              Severity: Major
              Found in src/interpolate.ts and 1 other location - About 1 hr to fix
              src/interpolate.ts on lines 5..5

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 55.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language