zalando/zappr

View on GitHub

Showing 55 of 190 total issues

Function _validateBody has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  _validateBody(body, checks = {}) {
    const {
      [MINIMUM_LENGTH]: {
        enabled: shouldCheckLength = true,
        length: requiredLength = DEFAULT_REQUIRED_LENGTH
Severity: Minor
Found in server/checks/Specification.js - About 1 hr to fix

    Function fetchCommitsAndSetStatus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      async fetchCommitsAndSetStatus({config, pull_request, repository, token}) {
        /**
         * Strategy: On every pull request that is opened or synced,
         * check that all commit messages match at least one of one or more patterns.
         */
    Severity: Minor
    Found in server/checks/CommitMessage.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 LoginNavHeader has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function LoginNavHeader() {
      return <Navbar className="zpr-login-navbar">
        <Navbar.Header>
          <Navbar.Brand>
            <img src={icon}/>
    Severity: Minor
    Found in client/components/LoginNavHeader.jsx - About 1 hr to fix

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

        render() {
          const {selected, repos, fetchAll, filterRepos} = this.props
          const {isFetching} = repos.status
          const selectedRepo = repos.items[selected]
          let content = null
      Severity: Minor
      Found in client/components/RepositoryBrowser.jsx - About 1 hr to fix

        Function requireAuth has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function requireAuth(WrappedComponent, redirect = '/login') {
        
          function mapStateToProps(state) {
            return {
              isAuthenticated: state.auth.isAuthenticated
        Severity: Minor
        Found in client/components/requireAuth.jsx - About 1 hr to fix

          Function authenticate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async authenticate(req) {
              const {headers} = req
              const AUTH_HEADER = headers['authorization']
              if (!AUTH_HEADER) this.fail({status: 400, reason: 'Missing Authorization header'})
              const [type, token, ...rest] = AUTH_HEADER.split(' ')
          Severity: Minor
          Found in server/passport/passport-github-api.js - About 1 hr to fix

            Function getCommentStatsForConfig has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async getCommentStatsForConfig(repository, comments, config, token) {
                const that = this
            
                async function checkComment(stats, comment) {
                  let matchesTotal = false
            Severity: Minor
            Found in server/checks/Approval.js - About 1 hr to fix

              Function authenticate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                async authenticate(req) {
                  const {headers} = req
                  const AUTH_HEADER = headers['authorization']
                  if (!AUTH_HEADER) this.fail({status: 400, reason: 'Missing Authorization header'})
                  const [type, token, ...rest] = AUTH_HEADER.split(' ')
              Severity: Minor
              Found in server/passport/passport-github-api.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 renderStatic has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default async function renderStatic(ctx, next) {
              
                const assets = await getStaticAssets()
                const user = ctx.req.user ? ctx.req.user.json : {}
                // at this point the cookie is guaranteed to exist due to previous middleware
              Severity: Minor
              Found in server/react/render-static.jsx - About 1 hr to fix

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

                  render() {
                    const {selected, isUpdating, filterBy} = this.props
                    const repos = this.sortedRepositories()
                
                    const header = <header>
                Severity: Minor
                Found in client/components/RepositoryList.jsx - About 1 hr to fix

                  Function onGetOne has 29 lines of code (exceeds 25 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

                    Function createShipper has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function createShipper() {
                      switch (shipEngine) {
                        case 'file':
                          const FILENAME = nconf.get('AUDIT_FILENAME') || "audit.log"
                          const MAXSIZE = nconf.get('AUDIT_MAX_SIZE') || 10 ** 7 // 10 MB default max size
                    Severity: Minor
                    Found in server/service/AuditServiceCreator.js - About 1 hr to fix

                      Function updateWebhookFor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async updateWebhookFor(user, repo, events, accessToken) {
                          debug(`${user}/${repo}: updating webhook with events: ${events.join(", ")}`)
                          let path = API_URL_TEMPLATES.HOOK.replace('${owner}', user).replace('${repo}', repo)
                          const HOOK_URL = nconf.get('HOOK_URL')
                          let hook_url = HOOK_URL ? HOOK_URL : nconf.get('HOST_ADDR') + '/api/hook'
                      Severity: Minor
                      Found in server/service/GithubService.js - About 1 hr to fix

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

                        export function init(options = {}) {
                          const passport = initPassport(options.PassportStrategy)
                        
                          return app.use(generatePrometheusMiddleware(router, {
                                      ignore: [/^\/repository/]
                        Severity: Minor
                        Found in server/server.js - About 1 hr to fix

                          Function checkComment has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async function checkComment(stats, comment) {
                                let matchesTotal = false
                                if (config.from) {
                                  matchesTotal = await that.doesCommentMatchConfig(repository, comment, config.from, token)
                                  if (matchesTotal) {
                          Severity: Minor
                          Found in server/checks/Approval.js - About 1 hr to fix

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

                              render() {
                                const style = {
                                  marginLeft: 15
                                }
                                const {check, onToggle} = this.props
                            Severity: Minor
                            Found in client/components/RepositoryCheck.jsx - About 1 hr to fix

                              Function decryptTokenHook has 27 lines of code (exceeds 25 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

                                Function getPrMergedEvent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function getPrMergedEvent(auditEvent) {
                                  const event_type = {
                                    namespace: 'cloud.zalando.com',
                                    name: 'pull-request-merged',
                                    version: nconf.get('AUDIT_EVENT_VERSION') || 1
                                Severity: Minor
                                Found in server/service/audit/transform/ZalandoAuditTrail.js - About 1 hr to fix

                                  Function generateStatus has a Cognitive Complexity of 9 (exceeds 5 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 55 mins 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 doesCommentMatchConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    async doesCommentMatchConfig(repository, comment, fromConfig, token) {
                                      // persons must either be listed explicitly in users OR
                                      // be a collaborator OR
                                      // member of at least one of listed orgs
                                      const {orgs, collaborators, users} = fromConfig
                                  Severity: Minor
                                  Found in server/checks/Approval.js - About 45 mins 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