zalando/zappr

View on GitHub

Showing 190 of 190 total issues

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

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

                <Col sm={4}>
                  <h4>Commit message patterns</h4>
                  <p>Require commit messages in a pull request to <Highlight>follow a pattern you define.</Highlight></p>
                  <CommitMessage {...animationProps} />
                </Col>
    Severity: Major
    Found in client/containers/Login.jsx and 1 other location - About 1 hr to fix
    client/containers/Login.jsx on lines 111..115

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

    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

                <Col sm={4}>
                  <h4>Automatic branch creation</h4>
                  <p>Automatically create a branch in your repository <Highlight>for every opened issue.</Highlight></p>
                  <Autobranch {...animationProps} />
                </Col>
    Severity: Major
    Found in client/containers/Login.jsx and 1 other location - About 1 hr to fix
    client/containers/Login.jsx on lines 106..110

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

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

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

          return fetch(Service.url(`/api/repos/${check.repoId}/${check.type}`), {
            method: 'PUT',
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json'
      Severity: Major
      Found in client/service/CheckService.js and 1 other location - About 1 hr to fix
      client/service/CheckService.js on lines 53..71

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

      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

          return fetch(Service.url(`/api/repos/${check.repoId}/${check.type}`), {
            method: 'DELETE',
            headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json'
      Severity: Major
      Found in client/service/CheckService.js and 1 other location - About 1 hr to fix
      client/service/CheckService.js on lines 28..48

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

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

        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

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

                          <ellipse stroke="#000"
                                   className={animate ? 'grow' : ''}
                                   ry="10"
                                   rx="10"
                                   id="approval_commit"
                    Severity: Major
                    Found in client/components/ApprovalAnimation.jsx and 2 other locations - About 1 hr to fix
                    client/components/AutobranchAnimation.jsx on lines 46..54
                    client/components/CommitMessageAnimation.jsx on lines 46..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 60.

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

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

                          <ellipse stroke="#fff"
                                   className={animate ? 'grow' : ''}
                                   ry="25"
                                   rx="25"
                                   id="commitmessage_commit"
                    Severity: Major
                    Found in client/components/CommitMessageAnimation.jsx and 2 other locations - About 1 hr to fix
                    client/components/ApprovalAnimation.jsx on lines 73..81
                    client/components/AutobranchAnimation.jsx on lines 46..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 60.

                    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

                          <ellipse stroke="#000"
                                   className={animate ? 'grow' : ''}
                                   ry="10"
                                   rx="10"
                                   id="autobranch_commit"
                    Severity: Major
                    Found in client/components/AutobranchAnimation.jsx and 2 other locations - About 1 hr to fix
                    client/components/ApprovalAnimation.jsx on lines 73..81
                    client/components/CommitMessageAnimation.jsx on lines 46..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 60.

                    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

                                this.kms.encrypt({ KeyId: this.keyId, Plaintext: plaintext}, (err, data) => {
                                    if (err) {
                                        error(err)
                                        return reject(err)
                                    }
                    Severity: Major
                    Found in server/service/encryption/KMSEncryptionService.js and 1 other location - About 1 hr to fix
                    server/service/encryption/KMSEncryptionService.js on lines 39..46

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

                    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