Skip to content

Commit

Permalink
more style adjustments to try to placate CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Ciavarella committed Jan 2, 2022
1 parent 2fc6190 commit c028328
Showing 1 changed file with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.Report;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.Nullable;

import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.parsers.ValgrindParser;

Expand All @@ -23,7 +26,7 @@
*/
public class ValgrindAdapter extends AbstractViolationAdapter {
private static final long serialVersionUID = -6117336551972081612L;
private static final int numberedStackThreshold = 2;
private static final int NUMBERED_STACK_THRESHOLD = 2;

@Override
ValgrindParser createParser() {
Expand Down Expand Up @@ -59,7 +62,7 @@ private String generateDescriptionHtml(final Violation violation) {
return description.toString();
}

private void appendGeneralTable(final StringBuilder html, final String executable, final String uniqueId, final String threadId, final String threadName, final JSONArray auxWhats) {
private void appendGeneralTable(final StringBuilder html, final String executable, final String uniqueId, @Nullable final String threadId, @Nullable final String threadName, @Nullable final JSONArray auxWhats) {
html.append("<table>");

maybeAppendTableRow(html, "Executable", executable);
Expand All @@ -76,30 +79,33 @@ private void appendGeneralTable(final StringBuilder html, final String executabl
html.append("</table>");
}

private void maybeAppendStackTraces(final StringBuilder html, final String stacksJson, final String message, final JSONArray auxWhats) {
final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));
private void maybeAppendStackTraces(final StringBuilder html, @Nullable final String stacksJson, final String message, @Nullable final JSONArray auxWhats) {
if (stacksJson != null && !stacksJson.isEmpty()) {
final JSONArray stacks = new JSONArray(new JSONTokener(stacksJson));

if (!stacks.isEmpty()) {
appendStackTrace(html, "Primary Stack Trace", message, stacks.getJSONArray(0));
if (!stacks.isEmpty()) {
appendStackTrace(html, "Primary Stack Trace", message, stacks.getJSONArray(0));

for (int stackIndex = 1; stackIndex < stacks.length(); ++stackIndex) {
String msg = null;
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() > numberedStackThreshold) {
title = "Auxiliary Stack Trace #" + Integer.toString(stackIndex);
}
String title = "Auxiliary Stack Trace";

appendStackTrace(html, title, msg, stacks.getJSONArray(stackIndex));
if (stacks.length() > NUMBERED_STACK_THRESHOLD) {
title = "Auxiliary Stack Trace #" + stackIndex;
}

appendStackTrace(html, title, msg, stacks.getJSONArray(stackIndex));
}
}
}
}

private void appendStackTrace(final StringBuilder html, final String title, final String message, final JSONArray frames) {
private void appendStackTrace(final StringBuilder html, final String title, @Nullable final String message, final JSONArray frames) {
html
.append("<h2>")
.append(title)
Expand Down Expand Up @@ -131,7 +137,7 @@ private void appendStackFrame(final StringBuilder html, final JSONObject frame)
html.append("</table>");
}

private void maybeAppendSuppression(final StringBuilder html, final String suppression) {
private void maybeAppendSuppression(final StringBuilder html, @Nullable final String suppression) {
if (suppression != null && !suppression.isEmpty()) {
html
.append("<h2>Suppression</h2><table><tr><td class=\"pane\"><pre>")
Expand All @@ -140,7 +146,7 @@ private void maybeAppendSuppression(final StringBuilder html, final String suppr
}
}

private void maybeAppendTableRow(final StringBuilder html, final String name, final String value) {
private void maybeAppendTableRow(final StringBuilder html, final String name, @Nullable final String value) {
if (value != null && !value.isEmpty()) {
html
.append("<tr><td class=\"pane-header\">")
Expand Down Expand Up @@ -173,13 +179,12 @@ private void maybeAppendStackFrameFileTableRow(final StringBuilder html, final J
}
}

@CheckForNull
private JSONArray getAuxWhatsArray(final Map<String, String> specifics) {
if (specifics != null && !specifics.isEmpty()) {
final String auxWhatsJson = specifics.get("auxwhats");
final String auxWhatsJson = specifics.get("auxwhats");

if (auxWhatsJson != null && !auxWhatsJson.isEmpty()) {
return new JSONArray(new JSONTokener(auxWhatsJson));
}
if (auxWhatsJson != null && !auxWhatsJson.isEmpty()) {
return new JSONArray(new JSONTokener(auxWhatsJson));
}

return null;
Expand Down

0 comments on commit c028328

Please sign in to comment.