Skip to content

Commit

Permalink
try to make static analysis happy
Browse files Browse the repository at this point in the history
  • Loading branch information
bitrunner committed Sep 17, 2023
1 parent 3fb702c commit dcdb41e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,35 +87,37 @@ private Tag generateGeneralTableHtml(final String executable, final String uniqu
}

private Tag maybeGenerateStackTracesHtml(@CheckForNull final String stacksJson, final String message, @CheckForNull final JSONArray auxWhats) {
ContainerTag stackTraces = null;

if (StringUtils.isNotBlank(stacksJson)) {
final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));
if (StringUtils.isBlank(stacksJson)) {
return iff(false, null);
}

if (!stacks.isEmpty()) {
stackTraces = div();
final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));

stackTraces.with(generateStackTraceHtml("Primary Stack Trace", message, stacks.getJSONArray(0)));
if (!stacks.isEmpty()) {
ContainerTag stackTraces = div();

for (int stackIndex = 1; stackIndex < stacks.length(); ++stackIndex) {
String msg = null;
stackTraces.with(generateStackTraceHtml("Primary Stack Trace", message, stacks.getJSONArray(0)));

if (auxWhats != null && auxWhats.length() >= stackIndex) {
msg = auxWhats.getString(stackIndex - 1);
}
for (int stackIndex = 1; stackIndex < stacks.length(); ++stackIndex) {
String msg = null;

String title = "Auxiliary Stack Trace";
if (auxWhats != null && auxWhats.length() >= stackIndex) {
msg = auxWhats.getString(stackIndex - 1);
}

if (stacks.length() > NUMBERED_STACK_THRESHOLD) {
title += " #" + stackIndex;
}
String title = "Auxiliary Stack Trace";

stackTraces.with(generateStackTraceHtml(title, msg, stacks.getJSONArray(stackIndex)));
if (stacks.length() > NUMBERED_STACK_THRESHOLD) {
title += " #" + stackIndex;
}

stackTraces.with(generateStackTraceHtml(title, msg, stacks.getJSONArray(stackIndex)));
}

return stackTraces;
}

return stackTraces;
return iff(false, null);
}

private Tag generateStackTraceHtml(final String title, @CheckForNull final String message, final JSONArray frames) {
Expand Down Expand Up @@ -162,7 +164,6 @@ private Tag maybeGenerateTableRowHtml(final String name, @CheckForNull final Str
}

private Tag maybeGenerateStackFrameFileTableRowHtml(final JSONObject frame) throws JSONException {
Tag row = null;
final String file = frame.optString("file");

if (StringUtils.isNotBlank(file)) {
Expand All @@ -180,10 +181,10 @@ private Tag maybeGenerateStackFrameFileTableRowHtml(final JSONObject frame) thro
fileBuilder.append(':').append(line);
}

row = maybeGenerateTableRowHtml("File", fileBuilder.toString());
return maybeGenerateTableRowHtml("File", fileBuilder.toString());
}

return row;
return iff(false, null);
}

@CheckForNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ protected void assertThatIssuesArePresent(final Report report, final SoftAsserti
report.forEach(
issue -> {
final String description = issue.getDescription();

if (!issue.getFileName().equals(Violation.NO_FILE)) {
if (Violation.NO_FILE.equals(issue.getFileName())) {
assertThat(!description.contains("Primary Stack Trace"));
}
else {
assertThat(description.contains("Primary Stack Trace"));
assertThat(description.contains("&lt;insert_a_suppression_name_here&gt;"));
} else {
assertThat(!description.contains("Primary Stack Trace"));
}
}
);
Expand Down

0 comments on commit dcdb41e

Please sign in to comment.