zalando/zappr

View on GitHub

Showing 190 of 190 total issues

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

    if (PullRequestMilestone.isTriggeredBy(event) && tokens[PullRequestMilestone.TYPE]) {
      info(`${owner}/${name}: Executing check PullRequestMilestone`)
      await this.checkHandler.onExecutionStart(dbRepo.id, PullRequestMilestone.TYPE, delay)
      try {
        await this.pullRequestMilestone.execute(config, payload, tokens[PullRequestMilestone.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 229..238
server/checks/CheckRunner.js on lines 240..249

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

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 7 locations. Consider refactoring.
Open

    if (PullRequestLabels.isTriggeredBy(event) && tokens[PullRequestLabels.TYPE]) {
      info(`${owner}/${name}: Executing check PullRequestLabels`)
      await this.checkHandler.onExecutionStart(dbRepo.id, PullRequestLabels.TYPE, delay)
      try {
        await this.pullRequestLabels.execute(config, payload, tokens[PullRequestLabels.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 229..238
server/checks/CheckRunner.js on lines 240..249

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

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 7 locations. Consider refactoring.
Open

    if (Autobranch.isTriggeredBy(event) && tokens[Autobranch.TYPE]) {
      info(`${owner}/${name}: Executing check Autobranch`)
      await this.checkHandler.onExecutionStart(dbRepo.id, Autobranch.TYPE, delay)
      try {
        await this.autobranch.execute(config, payload, tokens[Autobranch.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 229..238
server/checks/CheckRunner.js on lines 240..249

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

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 7 locations. Consider refactoring.
Open

    if (PullRequestTasks.isTriggeredBy(event) && tokens[PullRequestTasks.TYPE]) {
      info(`${owner}/${name}: Executing check PullRequestTasks`)
      await this.checkHandler.onExecutionStart(dbRepo.id, PullRequestTasks.TYPE, delay)
      try {
        await this.pullRequestTasks.execute(config, payload, tokens[PullRequestTasks.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 229..238

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

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 7 locations. Consider refactoring.
Open

    if (PullRequestMergeCommit.isTriggeredBy(event) && tokens[PullRequestMergeCommit.TYPE]) {
      info(`${owner}/${name}: Executing check PullRequestMergeCommit`)
      await this.checkHandler.onExecutionStart(dbRepo.id, PullRequestMergeCommit.TYPE, delay)
      try {
        await this.pullRequestMergeCommit.execute(config, payload, tokens[PullRequestMergeCommit.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 229..238
server/checks/CheckRunner.js on lines 240..249

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

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 7 locations. Consider refactoring.
Open

    if (Specification.isTriggeredBy(event) && tokens[Specification.TYPE]) {
      info(`${owner}/${name}: Executing check Specification`)
      await this.checkHandler.onExecutionStart(dbRepo.id, Specification.TYPE, delay)
      try {
        await this.specification.execute(config, payload, tokens[Specification.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 229..238
server/checks/CheckRunner.js on lines 240..249

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

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 7 locations. Consider refactoring.
Open

    if (CommitMessage.isTriggeredBy(event) && tokens[CommitMessage.TYPE]) {
      info(`${owner}/${name}: Executing check CommitMessage`)
      await this.checkHandler.onExecutionStart(dbRepo.id, CommitMessage.TYPE, delay)
      try {
        await this.commitMessage.execute(config, payload, tokens[CommitMessage.TYPE])
Severity: Major
Found in server/checks/CheckRunner.js and 6 other locations - About 7 hrs to fix
server/checks/CheckRunner.js on lines 163..172
server/checks/CheckRunner.js on lines 174..183
server/checks/CheckRunner.js on lines 185..194
server/checks/CheckRunner.js on lines 196..205
server/checks/CheckRunner.js on lines 218..227
server/checks/CheckRunner.js on lines 240..249

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

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

File GithubService.js has 446 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import path from 'path'
import nconf from '../nconf'
import { Counter } from 'prom-client'
import GithubServiceError, { GithubBranchProtectedError } from './GithubServiceError'
import { joinURL, promiseFirst, decode, encode, getIn, toGenericComment } from '../../common/util'
Severity: Minor
Found in server/service/GithubService.js - About 6 hrs to fix

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

      render() {
    
        const animationProps = {
          width: 300,
          height: 200,
    Severity: Major
    Found in client/containers/Login.jsx - About 5 hrs to fix

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

        id: {
          type: Sequelize.BIGINT,
          primaryKey: true,
          unique: true,
          allowNull: false,
      Severity: Major
      Found in server/model/User.js and 2 other locations - About 5 hrs to fix
      server/model/FrozenComment.js on lines 8..29
      server/model/Repository.js on lines 15..36

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

      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

        id: {
          type: Sequelize.BIGINT,
          primaryKey: true,
          unique: true,
          allowNull: false,
      Severity: Major
      Found in server/model/Repository.js and 2 other locations - About 5 hrs to fix
      server/model/FrozenComment.js on lines 8..29
      server/model/User.js on lines 14..35

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

      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

        id: {
          type: Sequelize.BIGINT,
          primaryKey: true,
          unique: true,
          allowNull: false,
      Severity: Major
      Found in server/model/FrozenComment.js and 2 other locations - About 5 hrs to fix
      server/model/Repository.js on lines 15..36
      server/model/User.js on lines 14..35

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

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

      export function repo(router) {
        return router
        .get('/api/repos/:id', requireAuth, async(ctx) => {
          try {
            const query = qs.parse(url.parse(ctx.req.url).query)
      Severity: Major
      Found in server/routes/api.js - About 5 hrs to fix

        Function execute has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          async execute(config, event, hookPayload, token, dbRepoId) {
            const {action, repository, pull_request, number, issue} = hookPayload
            const repoName = repository.name
            const user = repository.owner.login
            const {minimum} = config.approvals
        Severity: Minor
        Found in server/checks/Approval.js - About 5 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

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

              if (statusCode >= 400 && statusCode <= 499) {
                if (method !== 'GET' || statusCode !== 404) {
                  // only log 4xx if not GET 404 (happens often during zappr.yaml file check
                  if (statusCode === 403) {
                    CallCounter.inc({type: '4xx'}, 1)
        Severity: Major
        Found in server/service/GithubService.js and 1 other location - About 5 hrs to fix
        server/service/GithubService.js on lines 99..111

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

        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

              if (statusCode >= 400 && statusCode <= 499) {
                if (method !== 'GET' || statusCode !== 404) {
                  // only log 4xx if not GET 404 (happens often during zappr.yaml file check
                  if (statusCode === 403) {
                    CallCounter.inc({type: '4xx'}, 1)
        Severity: Major
        Found in server/service/GithubService.js and 1 other location - About 5 hrs to fix
        server/service/GithubService.js on lines 73..85

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

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

          async execute(config, event, hookPayload, token, dbRepoId) {
            const {action, repository, pull_request, number, issue} = hookPayload
            const repoName = repository.name
            const user = repository.owner.login
            const {minimum} = config.approvals
        Severity: Major
        Found in server/checks/Approval.js - About 4 hrs to fix

          GithubService has 36 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class GithubService {
          
            getOptions(method, path, body, accessToken, headers = {}) {
              headers['User-Agent'] = `Zappr (+${nconf.get('HOST_ADDR')})`
              if (accessToken) {
          Severity: Minor
          Found in server/service/GithubService.js - About 4 hrs to fix

            File Approval.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import Check from './Check'
            import AuditEvent from '../service/audit/AuditEvent'
            import { logger, formatDate } from '../../common/debug'
            import { promiseReduce, getIn, toGenericComment } from '../../common/util'
            import * as EVENTS from '../model/GithubEvents'
            Severity: Minor
            Found in server/checks/Approval.js - About 4 hrs to fix

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

                  } else if (oneOf.length > 0) {
                    const labels = await this.github.getIssueLabels(repoOwner, repoName, number, token)
                    status = generateStatusForOneOf(labels, {oneOf, additional})
                    await this.github.setCommitStatus(repoOwner, repoName, pull_request.head.sha, status, token)
                    info(`${fullName}#${number}: Set status to ${status.state} (labels: ${labels}, required: ${oneOf}, 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 74..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

              Severity
              Category
              Status
              Source
              Language