Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRASH] Cannot read property 'length' of undefined #542

Open
zdnk opened this issue Mar 20, 2018 · 1 comment
Open

[CRASH] Cannot read property 'length' of undefined #542

zdnk opened this issue Mar 20, 2018 · 1 comment

Comments

@zdnk
Copy link
Contributor

zdnk commented Mar 20, 2018

This is my dangerfile.js

import { danger, message, warn, fail } from 'danger'
var exec = require('child_process').execSync
var _ = require('lodash')

var result;

try {
    result = exec("swiftlint lint --quiet --reporter json").stdout.toString()
} catch(ex) {
    result = ex.stdout.toString()
}

var json = JSON.parse(result)
json.forEach(finding => {
    if (finding.severity == undefined || finding.reason == undefined) {
        return
    }

    var severity = _.toLower(finding.severity)
    if (severity == "warning" && finding.reason) {
        warn(finding.reason)
    } else if (severity == "error" && finding.reason) {
        fail(finding.reason)
    }
})

The error:

Error:  TypeError: Cannot read property 'length' of undefined
    at Executor.<anonymous> (.../node_modules/danger/distribution/runner/Executor.js:191:31)
    at step (.../node_modules/danger/distribution/runner/Executor.js:32:23)
    at Object.next (.../node_modules/danger/distribution/runner/Executor.js:13:53)
    at .../node_modules/danger/distribution/runner/Executor.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (.../node_modules/danger/distribution/runner/Executor.js:3:12)
    at Executor.handleResultsPostingToSTDOUT (.../node_modules/danger/distribution/runner/Executor.js:175:16)
    at Executor.<anonymous> (.../node_modules/danger/distribution/runner/Executor.js:160:26)
    at step (.../node_modules/danger/distribution/runner/Executor.js:32:23)
    at Object.next (.../node_modules/danger/distribution/runner/Executor.js:13:53)
error An unexpected error occurred: "Command failed.
@zdnk
Copy link
Contributor Author

zdnk commented Mar 21, 2018

It happens when there is a lot of warns/fails (like in the loop I have in my file).
It happens even if I just use warn("dd") and fail("dd") in the loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant