zalando/zappr

View on GitHub

Showing 55 of 190 total issues

Function findDeepInObjImpl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function findDeepInObjImpl(obj, fn, result = []) {
  if (typeof obj === 'object' && obj != null) {
    for (const key of Object.keys(obj)) {
      if (fn(key)) {
        result.push([key, obj[key]])
Severity: Minor
Found in common/util.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

Avoid deeply nested control flow statements.
Open

            if (new Date(comment.created_at) > dbPR.last_push) {
              frozenComments.push(frozenComment)
            }
Severity: Major
Found in server/checks/Approval.js - About 45 mins to fix

    Function getCommentStatsForConfig has a Cognitive Complexity of 8 (exceeds 5 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 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

    Function handleExistingPullRequests has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      async handleExistingPullRequests(dbRepo, checkType, {config, token}) {
        const PR_TYPES = [
          Approval.TYPE,
          Specification.TYPE,
          PullRequestMilestone.TYPE,
    Severity: Minor
    Found in server/checks/CheckRunner.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

    Function getEffectiveConfiguration has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function getEffectiveConfiguration(userConfig, repository, defaultConfig, ignorePaths, applyConfigIfOwnedBy) {
    Severity: Minor
    Found in server/zapprfile/Configuration.js - About 35 mins to fix

      Function reduce has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        function reduce(aggregator, index, array, resolve, reject) {
      Severity: Minor
      Found in common/util.js - About 35 mins to fix

        Function countApprovalsAndVetos has a Cognitive Complexity of 7 (exceeds 5 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 35 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 generateProblemMiddleware has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function generateProblemMiddleware({exposableErrorTypes}) {
          return async function problemMiddleware(ctx, next) {
            try {
              await next()
            } catch (e) {
        Severity: Minor
        Found in server/middleware/problem.js - About 35 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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function check(state = {
          error: false,
          isUpdating: false,
          isEnabled: false
        }, action) {
        Severity: Minor
        Found in client/reducers/repos/checks.js - About 35 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 getIn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getIn(obj, path, returnDefault = null) {
          if (!obj || typeof path === 'undefined') {
            return returnDefault
          }
          if (!Array.isArray(path)) {
        Severity: Minor
        Found in common/util.js - About 35 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 generatePrometheusMiddleware has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function generatePrometheusMiddleware(router, opts = {}) {
        
          const ROUTES = router.stack.map(({regexp, path}) => ({regexp, path}))
        
          /**
        Severity: Minor
        Found in server/middleware/prometheus.js - About 35 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 fetchIgnoredUsers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          async fetchIgnoredUsers(repository, pull_request, config, token) {
            if (!config.ignore || config.ignore === 'none') {
              return []
            }
            const ignoreConfig = config.ignore
        Severity: Minor
        Found in server/checks/Approval.js - About 35 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 updateWebhookFor has a Cognitive Complexity of 6 (exceeds 5 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 25 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 setIn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function setIn(obj, path, value) {
          if (!Array.isArray(path)) {
            path = [path]
          }
          const [head, ...tail] = path
        Severity: Minor
        Found in common/util.js - About 25 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 validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function validation(state = {
          status: UNKNOWN,
          config: null,
          message: ''
        }, action) {
        Severity: Minor
        Found in client/reducers/repos/validate.js - About 25 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