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
Exception while parsing Android lint output #93
Comments
This is a logged exception that probably doesn't need to be shown to end users in its entirety. Currently, we attempt to parse a line number that may or may not be present. If it is, parsing (should) succeed. If it is not, parsing is expected to fail. Printing an "error" message and showing the full stack trace to end users is alarmist! |
@btkelly how do you feel about replacing xml.issue.findAll { severityEnabled((String) it.@severity.text()) }
.each { violation ->
final Integer lineNumber;
try {
lineNumber = violation.location.@line.toInteger()
} catch (final NumberFormatException e) {
System.out.println("Error reading line number from Android Lint violations.");
e.printStackTrace();
lineNumber = null
}
result.add(new Violation(
sanitize((String) violation.@id.text()),
sanitize((String) name()),
sanitize((String) violation.@message.text()),
sanitize((String) violation.@url.text()),
sanitize((String) violation.location.@file.text())
.replace(project.rootDir.absolutePath + "/", ""),
lineNumber))
} with something like xml.issue.findAll { severityEnabled((String) it.@severity.text()) }
.each { violation ->
final String violationName = sanitize((String) violation.@id.text())
final String lineNumberString = sanitize((String) violation.location.@line.text())
final Integer lineNumber;
if (lineNumberString.isEmpty()) {
lineNumber = null
} else {
try {
lineNumber = lineNumberString.toInteger()
} catch (final NumberFormatException ignored) {
System.out.println(
"Error parsing line number string: " + lineNumberString +
" for Android Lint violation: " + violationName);
lineNumber = null
}
}
result.add(new Violation(
violationName,
sanitize((String) name()),
sanitize((String) violation.@message.text()),
sanitize((String) violation.@url.text()),
sanitize((String) violation.location.@file.text())
.replace(project.rootDir.absolutePath + "/", ""),
lineNumber))
} |
That parsing logic could then be pulled into a |
Gnag version: 1.1
Gnag configuration:
Stack trace (recorded output when running
./gradlew clean gnagCheck
):Lint output (check the errors of type
InvalidPackage
; they are missing line/column numbers):The text was updated successfully, but these errors were encountered: