zalando/zappr

View on GitHub

Showing 190 of 190 total issues

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

    if (required.length > 0) {
      const labels = await this.github.getIssueLabels(repoOwner, repoName, number, token)
      status = generateStatusForRequired(labels, {required, additional})
      await this.github.setCommitStatus(repoOwner, repoName, pull_request.head.sha, status, token)
      info(`${fullName}#${number}: Set status to ${status.state} (labels: ${labels}, required: ${required}, additional: ${additional})`)
Severity: Major
Found in server/checks/PullRequestLabels.js and 1 other location - About 4 hrs to fix
server/checks/PullRequestLabels.js on lines 79..87

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 120.

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 handleGithubWebhook has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  async handleGithubWebhook(dbRepo, checkArgs) {
    const {event, payload, config} = checkArgs
    const owner = dbRepo.json.owner.login
    const name = dbRepo.json.name
    const tokens = getTokens(dbRepo)
Severity: Minor
Found in server/checks/CheckRunner.js - About 3 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

Function handleGithubWebhook has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async handleGithubWebhook(dbRepo, checkArgs) {
    const {event, payload, config} = checkArgs
    const owner = dbRepo.json.owner.login
    const name = dbRepo.json.name
    const tokens = getTokens(dbRepo)
Severity: Major
Found in server/checks/CheckRunner.js - About 3 hrs to fix

    Function render has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const {displayName, username, html_url, avatar_url} = this.props.user
        const style = {
          logo: {
            marginTop: '-1px',
    Severity: Major
    Found in client/components/NavHeader.jsx - About 2 hrs to fix

      Function handleExistingPullRequests has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async handleExistingPullRequests(dbRepo, checkType, {config, token}) {
          const PR_TYPES = [
            Approval.TYPE,
            Specification.TYPE,
            PullRequestMilestone.TYPE,
      Severity: Major
      Found in server/checks/CheckRunner.js - About 2 hrs to fix

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

            try {
              if (['milestoned', 'demilestoned', 'opened', 'reopened'].indexOf(action) !== -1 && pull_request.state === 'open') {
                await this.fetchMilestoneAndSetStatus({repository, pull_request, token})
              }
            } catch (e) {
        Severity: Major
        Found in server/checks/PullRequestMilestone.js and 2 other locations - About 2 hrs to fix
        server/checks/PullRequestLabels.js on lines 95..103
        server/checks/PullRequestMergeCommit.js on lines 71..79

        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 83.

        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

            try {
              if (['labeled', 'unlabeled', 'opened', 'reopened', 'synchronize'].indexOf(action) !== -1 && pull_request.state === 'open') {
                await this.fetchLabelsAndSetStatus({repository, pull_request, token, config})
              }
            } catch (e) {
        Severity: Major
        Found in server/checks/PullRequestLabels.js and 2 other locations - About 2 hrs to fix
        server/checks/PullRequestMergeCommit.js on lines 71..79
        server/checks/PullRequestMilestone.js on lines 49..57

        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 83.

        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

            try {
              if (['opened', 'reopened', 'synchronize'].indexOf(action) !== -1 && pull_request.state === 'open') {
                await this.fetchCommitsAndSetStatus({repository, pull_request, token})
              }
            } catch (e) {
        Severity: Major
        Found in server/checks/PullRequestMergeCommit.js and 2 other locations - About 2 hrs to fix
        server/checks/PullRequestLabels.js on lines 95..103
        server/checks/PullRequestMilestone.js on lines 49..57

        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 83.

        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

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

                    await this.audit.log(new AuditEvent(AUDIT_EVENTS.COMMIT_STATUS_UPDATE).fromGithubEvent(hookPayload)
                                                                                          .withResult({
                                                                                            approvals,
                                                                                            vetos,
                                                                                            status
        Severity: Major
        Found in server/checks/Approval.js and 1 other location - About 2 hrs to fix
        server/checks/Approval.js on lines 463..473

        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 81.

        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

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

                  await this.audit.log(new AuditEvent(AUDIT_EVENTS.COMMIT_STATUS_UPDATE).fromGithubEvent(hookPayload)
                                                                                        .withResult({
                                                                                          approvals,
                                                                                          vetos,
                                                                                          status
        Severity: Major
        Found in server/checks/Approval.js and 1 other location - About 2 hrs to fix
        server/checks/Approval.js on lines 434..444

        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 81.

        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

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

            return fetch(Service.url(`/api/repos/${repoId}/zapprfile`), {credentials: 'same-origin'})
            .then(response => {
              return new Promise((resolve, reject) => {
                return response.json().then(json => {
                  if (response.ok) {
        Severity: Major
        Found in client/service/RepoService.js and 2 other locations - About 2 hrs to fix
        client/service/CheckService.js on lines 75..92
        client/service/RepoService.js on lines 21..33

        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 75.

        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

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

            return fetch(Service.url(`/api/repos${loadAllFromUpstream ? '?all=true' : ''}`), {
              credentials: 'same-origin'
            }).then(response => {
              return new Promise((resolve, reject) => {
                return response.json().then(json => {
        Severity: Major
        Found in client/service/RepoService.js and 2 other locations - About 2 hrs to fix
        client/service/CheckService.js on lines 75..92
        client/service/RepoService.js on lines 6..17

        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 75.

        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

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

            return fetch(Service.url(`/api/repos/${repoId}/refreshTokens`), {
              method: 'POST',
              headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json'
        Severity: Major
        Found in client/service/CheckService.js and 2 other locations - About 2 hrs to fix
        client/service/RepoService.js on lines 6..17
        client/service/RepoService.js on lines 21..33

        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 75.

        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 render has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            if (!this.props.repository.full_name) return null
        
            const {repository, checks, validations} = this.props
            const { isRefreshingToken } = checks;
        Severity: Minor
        Found in client/containers/RepositoryDetail.jsx - About 1 hr to fix

          Function processedPullRequests has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                const processedPullRequests = openPullRequests.map(async pullRequest => {
                  const dbPR = await this.pullRequestHandler.onGet(dbRepo.id, pullRequest.number)
                  switch (checkType) {
                    case Approval.TYPE:
                      return this.approval.fetchApprovalsAndSetStatus(
          Severity: Minor
          Found in server/checks/CheckRunner.js - About 1 hr to fix

            Function onGetOne has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              async onGetOne(id, user = null, includeToken = false, autoSync = false) {
                debug(`get Repository ${id}, autoSync ${autoSync}`)
                let repository
                try {
                  if (user) {
            Severity: Minor
            Found in server/handler/RepositoryHandler.js - About 1 hr 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

                return this.filteredRepositories().sort((a, b) => {
                  a = a.full_name.toLowerCase()
                  b = b.full_name.toLowerCase()
                  return a < b ? -1 : (b < a ? 1 : 0)
                })
            Severity: Major
            Found in client/components/RepositoryList.jsx and 1 other location - About 1 hr to fix
            client/actions/repos.js on lines 34..38

            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 70.

            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 handleGithubApiError has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              handleGithubApiError(statusCode, response) {
                if (!this.isOK(statusCode)) {
                  if (statusCode >= 400 && statusCode <= 499) {
                    if (method !== 'GET' || statusCode !== 404) {
                      // only log 4xx if not GET 404 (happens often during zappr.yaml file check
            Severity: Minor
            Found in server/service/GithubService.js - About 1 hr 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

              return repos.sort((a, b) => {
                a = a.full_name.toLowerCase()
                b = b.full_name.toLowerCase()
                return a < b ? -1 : (b < a ? 1 : 0)
              })
            Severity: Major
            Found in client/actions/repos.js and 1 other location - About 1 hr to fix
            client/components/RepositoryList.jsx on lines 48..52

            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 70.

            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 decryptTokenHook has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

            async function decryptTokenHook(thing) {
              /**
               * We check for the existence of a function `set` because if there is none,
               * it means that we selected with raw=true and thus don't want to change
               * the raw database content.
            Severity: Minor
            Found in server/model/Database.js - About 1 hr 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

            Severity
            Category
            Status
            Source
            Language