zalando/zappr

View on GitHub

Showing 55 of 190 total issues

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

      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

        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

              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

                    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

                        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

                        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

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

                          async fetchPath(method, path, payload, accessToken, headers = {}) {
                            const options = this.getOptions(method, path, payload, accessToken, headers)
                            const [response, body] = await request(options)
                            const {statusCode} = response || {}
                            CallCounter.inc({type: 'total'}, 1)
                        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

                        Function init has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function init(Strategy = GithubStrategy) {
                          const GITHUB_CLIENT_ID = nconf.get('GITHUB_CLIENT_ID')
                          const GITHUB_CLIENT_SECRET = nconf.get('GITHUB_CLIENT_SECRET')
                          const GITHUB_UI_URL = nconf.get('GITHUB_UI_URL')
                          const GITHUB_API_URL = nconf.get('GITHUB_API_URL')
                        Severity: Minor
                        Found in server/passport/passport.js - About 1 hr to fix

                          Function countApprovalsAndVetos has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async countApprovalsAndVetos(repository, pull_request, comments, config, token) {
                              const ignore = await this.fetchIgnoredUsers(repository, pull_request, config, token)
                              const approvalPattern = config.pattern
                              const vetoPattern = _.get(config, 'veto.pattern')
                          
                          
                          Severity: Minor
                          Found in server/checks/Approval.js - About 1 hr to fix

                            Function generateStatus has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              static generateStatus({approvals, vetos}, {minimum, groups}) {
                                if (vetos.length > 0) {
                                  return {
                                    description: `Vetoes: ${vetos.map(u => `@${u}`).join(', ')}.`,
                                    state: 'failure',
                            Severity: Minor
                            Found in server/checks/Approval.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language