| 1 | package com.github.valid8j.pcond.validator; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.core.DebuggingUtils; | |
| 4 | import com.github.valid8j.pcond.core.EvaluationEntry; | |
| 5 | import com.github.valid8j.pcond.fluent.ValueHolder; | |
| 6 | import com.github.valid8j.pcond.internals.InternalUtils; | |
| 7 | ||
| 8 | import java.util.*; | |
| 9 | import java.util.concurrent.atomic.AtomicInteger; | |
| 10 | import java.util.concurrent.atomic.AtomicReference; | |
| 11 | import java.util.function.Function; | |
| 12 | import java.util.function.Supplier; | |
| 13 | ||
| 14 | import static com.github.valid8j.pcond.internals.InternalUtils.*; | |
| 15 | import static java.lang.Math.max; | |
| 16 | import static java.lang.Math.min; | |
| 17 | import static java.lang.String.format; | |
| 18 | import static java.util.Collections.emptyList; | |
| 19 | import static java.util.Collections.unmodifiableList; | |
| 20 | import static java.util.stream.Collectors.joining; | |
| 21 | import static java.util.stream.Collectors.toList; | |
| 22 | ||
| 23 | public interface ReportComposer { | |
| 24 | default Explanation explanationFromMessage(String msg) { | |
| 25 |
1
1. explanationFromMessage : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer::explanationFromMessage → KILLED |
return Explanation.fromMessage(msg); |
| 26 | } | |
| 27 | | |
| 28 | default Explanation composeExplanation(String message, List<EvaluationEntry> evaluationEntries) { | |
| 29 |
1
1. composeExplanation : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer::composeExplanation → KILLED |
return Utils.composeExplanation(this, message, evaluationEntries); |
| 30 | } | |
| 31 | | |
| 32 | default FormattedEntry createFormattedEntryForExpectation(EvaluationEntry evaluationEntry) { | |
| 33 |
1
1. createFormattedEntryForExpectation : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer::createFormattedEntryForExpectation → KILLED |
return Utils.createFormattedEntryForExpectation(this, evaluationEntry); |
| 34 | } | |
| 35 | | |
| 36 | default FormattedEntry createFormattedEntryForActualValue(EvaluationEntry evaluationEntry) { | |
| 37 |
1
1. createFormattedEntryForActualValue : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer::createFormattedEntryForActualValue → KILLED |
return Utils.createFormattedEntryForActualValue(this, evaluationEntry); |
| 38 | } | |
| 39 | | |
| 40 | default boolean requiresExplanation(EvaluationEntry evaluationEntry) { | |
| 41 |
2
1. requiresExplanation : replaced boolean return with false for com/github/valid8j/pcond/validator/ReportComposer::requiresExplanation → KILLED 2. requiresExplanation : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer::requiresExplanation → KILLED |
return evaluationEntry.requiresExplanation(); |
| 42 | } | |
| 43 | | |
| 44 | /** | |
| 45 | * A default implementation of `ReportComposer`. | |
| 46 | */ | |
| 47 | class Default implements ReportComposer { | |
| 48 | } | |
| 49 | | |
| 50 | interface Report { | |
| 51 | String summary(); | |
| 52 | | |
| 53 | List<String> details(); | |
| 54 | | |
| 55 | static Report create(String summary, List<String> details) { | |
| 56 | List<String> detailsCopy = unmodifiableList(new ArrayList<>(details)); | |
| 57 |
1
1. create : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Report::create → KILLED |
return new Report() { |
| 58 | @Override | |
| 59 | public String summary() { | |
| 60 |
1
1. summary : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Report$1::summary → KILLED |
return summary; |
| 61 | } | |
| 62 | | |
| 63 | @Override | |
| 64 | public List<String> details() { | |
| 65 |
1
1. details : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Report$1::details → KILLED |
return detailsCopy; |
| 66 | } | |
| 67 | }; | |
| 68 | } | |
| 69 | } | |
| 70 | | |
| 71 | class FormattedEntry { | |
| 72 | private final String input; | |
| 73 | private final String formName; | |
| 74 | private final String indent; | |
| 75 | private final String output; | |
| 76 | private final boolean requiresExplanation; | |
| 77 | | |
| 78 | public FormattedEntry(String input, String formName, String indent, String output, boolean requiresExplanation) { | |
| 79 | this.input = input; | |
| 80 | this.formName = formName; | |
| 81 | this.indent = indent; | |
| 82 | this.output = output; | |
| 83 | this.requiresExplanation = requiresExplanation; | |
| 84 | } | |
| 85 | | |
| 86 | Optional<String> input() { | |
| 87 |
1
1. input : replaced return value with Optional.empty for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::input → KILLED |
return Optional.ofNullable(this.input); |
| 88 | } | |
| 89 | | |
| 90 | String indent() { | |
| 91 |
1
1. indent : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::indent → KILLED |
return this.indent; |
| 92 | } | |
| 93 | | |
| 94 | String formName() { | |
| 95 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::formName → KILLED |
return this.formName; |
| 96 | } | |
| 97 | | |
| 98 | Optional<String> output() { | |
| 99 |
1
1. output : replaced return value with Optional.empty for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::output → KILLED |
return Optional.ofNullable(this.output); |
| 100 | } | |
| 101 | | |
| 102 | public boolean requiresExplanation() { | |
| 103 |
2
1. requiresExplanation : replaced boolean return with false for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::requiresExplanation → KILLED 2. requiresExplanation : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$FormattedEntry::requiresExplanation → KILLED |
return this.requiresExplanation; |
| 104 | } | |
| 105 | } | |
| 106 | | |
| 107 | enum Utils { | |
| 108 | ; | |
| 109 | | |
| 110 | /** | |
| 111 | * Note that an exception thrown during an evaluation is normally caught by the framework. | |
| 112 | * | |
| 113 | * @param message A message to be prepended to a summary. | |
| 114 | * @param evaluationHistory An "evaluation history" object represented as a list of evaluation entries. | |
| 115 | * @return An explanation object. | |
| 116 | */ | |
| 117 | public static Explanation composeExplanation(ReportComposer reportComposer, String message, List<EvaluationEntry> evaluationHistory) { | |
| 118 | List<Object> detailsForExpectation = new LinkedList<>(); | |
| 119 |
2
1. lambda$composeExplanation$0 : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$composeExplanation$0 → SURVIVED 2. lambda$composeExplanation$0 : negated conditional → KILLED |
List<EvaluationEntry> nonTrivialEvaluationHistory = evaluationHistory.stream().filter(each -> !each.isTrivial()).collect(toList()); |
| 120 | List<FormattedEntry> summaryDataForExpectations = formatEvaluationEntries(detailsForExpectation, | |
| 121 | reportComposer, | |
| 122 | nonTrivialEvaluationHistory, | |
| 123 | reportComposer::createFormattedEntryForExpectation, | |
| 124 |
1
1. lambda$composeExplanation$1 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$composeExplanation$1 → KILLED |
each -> each::detailOutputExpectation); |
| 125 | String textSummaryForExpectations = composeSummary(minimizeIndentation(summaryDataForExpectations)); | |
| 126 | | |
| 127 | List<Object> detailsForActual = new LinkedList<>(); | |
| 128 | List<FormattedEntry> summaryForActual = formatEvaluationEntries(detailsForActual, | |
| 129 | reportComposer, | |
| 130 | nonTrivialEvaluationHistory, | |
| 131 | reportComposer::createFormattedEntryForActualValue, | |
| 132 |
1
1. lambda$composeExplanation$2 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$composeExplanation$2 → KILLED |
each -> each::detailOutputActualValue); |
| 133 | String textSummaryForActualResult = composeSummary(minimizeIndentation(summaryForActual)); | |
| 134 |
1
1. composeExplanation : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::composeExplanation → KILLED |
return new Explanation(message, |
| 135 | composeReport(textSummaryForExpectations, detailsForExpectation), | |
| 136 | composeReport(textSummaryForActualResult, detailsForActual)); | |
| 137 | } | |
| 138 | | |
| 139 | private static List<FormattedEntry> formatEvaluationEntries(List<Object> detailsOutput, | |
| 140 | ReportComposer reportComposer, | |
| 141 | List<EvaluationEntry> nonTrivialEvaluationHistory, | |
| 142 | Function<EvaluationEntry, FormattedEntry> evaluationEntryFormatter, | |
| 143 | Function<EvaluationEntry, Supplier<Object>> detailGenerator) { | |
| 144 |
1
1. formatEvaluationEntries : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Utils::formatEvaluationEntries → KILLED |
return squashEntriesWhenPossible(reportComposer, nonTrivialEvaluationHistory) |
| 145 | .stream() | |
| 146 |
1
1. lambda$formatEvaluationEntries$3 : removed call to com/github/valid8j/pcond/validator/ReportComposer$Utils::addToDetailsListIfExplanationIsRequired → KILLED |
.peek((EvaluationEntry each) -> addToDetailsListIfExplanationIsRequired(reportComposer, detailsOutput, each, detailGenerator.apply(each))) |
| 147 | .map(evaluationEntryFormatter) | |
| 148 | .collect(toList()); | |
| 149 | } | |
| 150 | | |
| 151 | public static FormattedEntry createFormattedEntryForExpectation(ReportComposer reportComposer, EvaluationEntry entry) { | |
| 152 |
1
1. createFormattedEntryForExpectation : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::createFormattedEntryForExpectation → KILLED |
return new FormattedEntry(formatObject(entry.inputExpectation()), |
| 153 | entry.formName(), | |
| 154 | InternalUtils.indent(entry.level()), | |
| 155 | formatObject(entry.outputExpectation()), | |
| 156 | reportComposer.requiresExplanation(entry)); | |
| 157 | } | |
| 158 | | |
| 159 | public static FormattedEntry createFormattedEntryForActualValue(ReportComposer reportComposer, EvaluationEntry entry) { | |
| 160 |
1
1. createFormattedEntryForActualValue : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::createFormattedEntryForActualValue → KILLED |
return new FormattedEntry(formatObject(entry.inputActualValue()), |
| 161 | entry.formName(), | |
| 162 | InternalUtils.indent(entry.level()), | |
| 163 | formatObject(entry.outputActualValue()), | |
| 164 | reportComposer.requiresExplanation(entry)); | |
| 165 | } | |
| 166 | | |
| 167 | private static List<FormattedEntry> minimizeIndentation(List<FormattedEntry> summaryForActual) { | |
| 168 | String minIndent = summaryForActual.stream() | |
| 169 |
1
1. lambda$minimizeIndentation$4 : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$minimizeIndentation$4 → SURVIVED |
.map(e -> e.indent) |
| 170 | .min(Comparator.comparingInt(String::length)) | |
| 171 | .orElse(""); | |
| 172 |
1
1. minimizeIndentation : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Utils::minimizeIndentation → KILLED |
return summaryForActual.stream() |
| 173 |
1
1. lambda$minimizeIndentation$5 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$minimizeIndentation$5 → KILLED |
.map(e -> new FormattedEntry(e.input, e.formName(), e.indent().replaceFirst(minIndent, ""), e.output, e.requiresExplanation())) |
| 174 | .collect(toList()); | |
| 175 | } | |
| 176 | | |
| 177 | private static List<EvaluationEntry> squashEntriesWhenPossible(ReportComposer reportComposer, List<EvaluationEntry> evaluationHistory) { | |
| 178 |
2
1. squashEntriesWhenPossible : changed conditional boundary → SURVIVED 2. squashEntriesWhenPossible : negated conditional → KILLED |
if (evaluationHistory.size() > 1) { |
| 179 | List<EvaluationEntry> ret = new LinkedList<>(); | |
| 180 | List<EvaluationEntry> entriesToSquash = new LinkedList<>(); | |
| 181 | AtomicReference<EvaluationEntry> cur = new AtomicReference<>(); | |
| 182 | evaluationHistory.stream() | |
| 183 |
3
1. lambda$squashEntriesWhenPossible$6 : negated conditional → KILLED 2. lambda$squashEntriesWhenPossible$6 : negated conditional → KILLED 3. lambda$squashEntriesWhenPossible$6 : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$squashEntriesWhenPossible$6 → KILLED |
.filter(each -> !each.ignored() || DebuggingUtils.reportIgnoredEntries()) |
| 184 | .filter(each -> { | |
| 185 |
1
1. lambda$squashEntriesWhenPossible$7 : negated conditional → KILLED |
if (cur.get() != null) |
| 186 |
1
1. lambda$squashEntriesWhenPossible$7 : replaced boolean return with false for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$squashEntriesWhenPossible$7 → KILLED |
return true; |
| 187 | else { | |
| 188 |
1
1. lambda$squashEntriesWhenPossible$7 : removed call to java/util/concurrent/atomic/AtomicReference::set → KILLED |
cur.set(each); |
| 189 |
1
1. lambda$squashEntriesWhenPossible$7 : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$squashEntriesWhenPossible$7 → KILLED |
return false; |
| 190 | } | |
| 191 | }) | |
| 192 |
1
1. squashEntriesWhenPossible : removed call to java/util/stream/Stream::forEach → KILLED |
.forEach(each -> { |
| 193 |
1
1. lambda$squashEntriesWhenPossible$8 : negated conditional → KILLED |
if (entriesToSquash.isEmpty()) { |
| 194 |
2
1. lambda$squashEntriesWhenPossible$8 : negated conditional → KILLED 2. lambda$squashEntriesWhenPossible$8 : negated conditional → KILLED |
if (cur.get().isSquashable(each) && !suppressSquashing()) { |
| 195 | entriesToSquash.add(cur.get()); | |
| 196 | } else { | |
| 197 | ret.add(cur.get()); | |
| 198 | } | |
| 199 | } else { | |
| 200 | entriesToSquash.add(cur.get()); | |
| 201 | ret.add(squashEntries(reportComposer, entriesToSquash)); | |
| 202 |
1
1. lambda$squashEntriesWhenPossible$8 : removed call to java/util/List::clear → KILLED |
entriesToSquash.clear(); |
| 203 | } | |
| 204 |
1
1. lambda$squashEntriesWhenPossible$8 : removed call to java/util/concurrent/atomic/AtomicReference::set → KILLED |
cur.set(each); |
| 205 | }); | |
| 206 |
1
1. squashEntriesWhenPossible : removed call to com/github/valid8j/pcond/validator/ReportComposer$Utils::finishLeftOverEntries → KILLED |
finishLeftOverEntries(reportComposer, ret, entriesToSquash, cur); |
| 207 |
1
1. squashEntriesWhenPossible : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Utils::squashEntriesWhenPossible → KILLED |
return ret.stream() |
| 208 |
2
1. lambda$squashEntriesWhenPossible$9 : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$squashEntriesWhenPossible$9 → SURVIVED 2. lambda$squashEntriesWhenPossible$9 : negated conditional → KILLED |
.filter(e -> !(e.inputActualValue() instanceof ValueHolder)) |
| 209 | .collect(toList()); | |
| 210 | } else { | |
| 211 |
1
1. squashEntriesWhenPossible : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Utils::squashEntriesWhenPossible → KILLED |
return new ArrayList<>(evaluationHistory); |
| 212 | } | |
| 213 | } | |
| 214 | | |
| 215 | private static void finishLeftOverEntries(ReportComposer reportComposer, List<EvaluationEntry> out, List<EvaluationEntry> leftOverEntriesToSquash, AtomicReference<EvaluationEntry> leftOver) { | |
| 216 |
4
1. finishLeftOverEntries : Replaced integer subtraction with addition → KILLED 2. finishLeftOverEntries : negated conditional → KILLED 3. finishLeftOverEntries : negated conditional → KILLED 4. finishLeftOverEntries : negated conditional → KILLED |
if (!leftOverEntriesToSquash.isEmpty() && leftOverEntriesToSquash.get(leftOverEntriesToSquash.size() - 1).isSquashable(leftOver.get()) && !suppressSquashing()) { |
| 217 | leftOverEntriesToSquash.add(leftOver.get()); | |
| 218 | out.add(squashEntries(reportComposer, leftOverEntriesToSquash)); | |
| 219 | } else { | |
| 220 |
1
1. finishLeftOverEntries : negated conditional → KILLED |
if (!leftOverEntriesToSquash.isEmpty()) |
| 221 | out.add(squashEntries(reportComposer, leftOverEntriesToSquash)); | |
| 222 | out.add(leftOver.get()); | |
| 223 | } | |
| 224 | } | |
| 225 | | |
| 226 | private static EvaluationEntry squashEntries(ReportComposer reportComposer, List<EvaluationEntry> squashedItems) { | |
| 227 | EvaluationEntry first = squashedItems.get(0); | |
| 228 |
1
1. squashEntries : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::squashEntries → KILLED |
return EvaluationEntry.create( |
| 229 | squashedItems.stream() | |
| 230 |
1
1. lambda$squashEntries$10 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$squashEntries$10 → KILLED |
.map(e -> (EvaluationEntry.Impl) e) |
| 231 | .map(EvaluationEntry::formName) | |
| 232 | .collect(joining(":")), | |
| 233 | first.type(), | |
| 234 | first.level(), | |
| 235 | first.inputExpectation(), first.detailInputExpectation(), | |
| 236 | first.outputExpectation(), computeDetailOutputExpectationFromSquashedItems(squashedItems), | |
| 237 | first.inputActualValue(), null, | |
| 238 |
1
1. squashEntries : Replaced integer subtraction with addition → KILLED |
first.outputActualValue(), squashedItems.get(squashedItems.size() - 1).detailOutputActualValue(), |
| 239 | false, false, | |
| 240 | squashedItems.stream().anyMatch(reportComposer::requiresExplanation), false); | |
| 241 | } | |
| 242 | | |
| 243 | @SuppressWarnings("BooleanMethodIsAlwaysInverted") | |
| 244 | private static boolean suppressSquashing() { | |
| 245 |
2
1. suppressSquashing : replaced boolean return with false for com/github/valid8j/pcond/validator/ReportComposer$Utils::suppressSquashing → SURVIVED 2. suppressSquashing : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::suppressSquashing → KILLED |
return DebuggingUtils.suppressSquashing(); |
| 246 | } | |
| 247 | | |
| 248 | private static String computeDetailOutputExpectationFromSquashedItems(List<EvaluationEntry> squashedItems) { | |
| 249 |
1
1. computeDetailOutputExpectationFromSquashedItems : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::computeDetailOutputExpectationFromSquashedItems → KILLED |
return squashedItems.stream() |
| 250 |
3
1. lambda$computeDetailOutputExpectationFromSquashedItems$11 : negated conditional → KILLED 2. lambda$computeDetailOutputExpectationFromSquashedItems$11 : negated conditional → KILLED 3. lambda$computeDetailOutputExpectationFromSquashedItems$11 : replaced boolean return with true for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$computeDetailOutputExpectationFromSquashedItems$11 → KILLED |
.filter(e -> e.type() != EvaluationEntry.Type.TRANSFORM && e.type() != EvaluationEntry.Type.CHECK) |
| 251 | .map(EvaluationEntry::detailOutputExpectation) | |
| 252 | .map(Objects::toString) | |
| 253 | .collect(joining(":")); | |
| 254 | } | |
| 255 | | |
| 256 | private static void addToDetailsListIfExplanationIsRequired(ReportComposer reportComposer, List<Object> detailsForExpectation, EvaluationEntry evaluationEntry, Supplier<Object> detailOutput) { | |
| 257 |
1
1. addToDetailsListIfExplanationIsRequired : negated conditional → KILLED |
if (reportComposer.requiresExplanation(evaluationEntry)) |
| 258 | detailsForExpectation.add(detailOutput.get()); | |
| 259 | } | |
| 260 | | |
| 261 | static Report composeReport(String summary, List<Object> details) { | |
| 262 |
1
1. composeReport : negated conditional → KILLED |
List<String> stringFormDetails = details != null ? |
| 263 | details.stream() | |
| 264 | .filter(Objects::nonNull) | |
| 265 | .map(Objects::toString) | |
| 266 | .collect(toList()) : | |
| 267 | emptyList(); | |
| 268 |
1
1. composeReport : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::composeReport → KILLED |
return Report.create(summary, stringFormDetails); |
| 269 | } | |
| 270 | | |
| 271 | private static String composeSummaryForExpectations(List<FormattedEntry> formattedEntries) { | |
| 272 |
1
1. composeSummaryForExpectations : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::composeSummaryForExpectations → NO_COVERAGE |
return composeSummary(formattedEntries); |
| 273 | } | |
| 274 | | |
| 275 | private static String composeSummary(List<FormattedEntry> formattedEntries) { | |
| 276 | AtomicInteger mismatchExplanationCount = new AtomicInteger(0); | |
| 277 | boolean mismatchExplanationFound = formattedEntries | |
| 278 | .stream() | |
| 279 | .anyMatch(FormattedEntry::requiresExplanation); | |
| 280 |
1
1. composeSummary : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::composeSummary → KILLED |
return evaluatorEntriesToString( |
| 281 | hideInputValuesWhenRepeated(formattedEntries), | |
| 282 |
1
1. lambda$composeSummary$12 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$composeSummary$12 → KILLED |
columnLengths -> formattedEntryToString( |
| 283 | columnLengths[0], | |
| 284 | columnLengths[1], | |
| 285 | columnLengths[2], | |
| 286 | mismatchExplanationCount, | |
| 287 | mismatchExplanationFound)); | |
| 288 | } | |
| 289 | | |
| 290 | private static Function<FormattedEntry, String> formattedEntryToString( | |
| 291 | int inputColumnWidth, | |
| 292 | int formNameColumnLength, | |
| 293 | int outputColumnLength, | |
| 294 | AtomicInteger i, | |
| 295 | boolean mismatchExplanationFound) { | |
| 296 |
1
1. formattedEntryToString : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::formattedEntryToString → KILLED |
return (FormattedEntry formattedEntry) -> |
| 297 |
2
1. lambda$formattedEntryToString$13 : negated conditional → KILLED 2. lambda$formattedEntryToString$13 : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$formattedEntryToString$13 → KILLED |
(mismatchExplanationFound ? |
| 298 |
1
1. lambda$formattedEntryToString$13 : negated conditional → KILLED |
format("%-4s", formattedEntry.requiresExplanation ? |
| 299 | "[" + i.getAndIncrement() + "]" : "") : | |
| 300 | "") + | |
| 301 | formatFields(inputColumnWidth, formNameColumnLength, outputColumnLength, formattedEntry); | |
| 302 | } | |
| 303 | | |
| 304 | private static String formatFields(int inputColumnWidth, int formNameColumnLength, int outputColumnLength, FormattedEntry formattedEntry) { | |
| 305 |
2
1. formatFields : Replaced integer addition with subtraction → SURVIVED 2. formatFields : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::formatFields → KILLED |
return formatInSpecifiedWidth(max(2, inputColumnWidth), formattedEntry.input() |
| 306 | .orElse("")) + | |
| 307 | formatInSpecifiedWidth(formNameColumnLength + 2, formattedEntry.input() | |
| 308 |
1
1. lambda$formatFields$14 : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$formatFields$14 → KILLED |
.map(v -> "->") |
| 309 |
1
1. formatFields : Replaced integer subtraction with addition → SURVIVED |
.orElse(" ") + formatObject(toNonStringObject(formattedEntry.indent() + formattedEntry.formName()), formNameColumnLength - 2)) + |
| 310 | formatInSpecifiedWidth(max(2, outputColumnLength), formattedEntry.output() | |
| 311 |
1
1. lambda$formatFields$15 : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$formatFields$15 → KILLED |
.map(v -> "->" + v) |
| 312 | .orElse("")); | |
| 313 | } | |
| 314 | | |
| 315 | private static String evaluatorEntriesToString(List<FormattedEntry> formattedEntries, Function<int[], Function<FormattedEntry, String>> formatterFactory) { | |
| 316 | int maxInputLength = 0, maxIndentAndFormNameLength = 0, maxOutputLength = 0; | |
| 317 | for (FormattedEntry eachEntry : formattedEntries) { | |
| 318 | int inputLength = eachEntry.input().map(String::length).orElse(0); | |
| 319 |
2
1. evaluatorEntriesToString : changed conditional boundary → SURVIVED 2. evaluatorEntriesToString : negated conditional → KILLED |
if (inputLength > maxInputLength) |
| 320 | maxInputLength = inputLength; | |
| 321 |
1
1. evaluatorEntriesToString : Replaced integer addition with subtraction → KILLED |
int inputAndFormNameLength = eachEntry.indent().length() + eachEntry.formName().length(); |
| 322 |
2
1. evaluatorEntriesToString : changed conditional boundary → SURVIVED 2. evaluatorEntriesToString : negated conditional → KILLED |
if (inputAndFormNameLength > maxIndentAndFormNameLength) |
| 323 | maxIndentAndFormNameLength = inputAndFormNameLength; | |
| 324 | int outputLength = eachEntry.output().map(String::length).orElse(0); | |
| 325 |
2
1. evaluatorEntriesToString : changed conditional boundary → SURVIVED 2. evaluatorEntriesToString : negated conditional → KILLED |
if (outputLength > maxOutputLength) |
| 326 | maxOutputLength = outputLength; | |
| 327 | } | |
| 328 |
2
1. evaluatorEntriesToString : Replaced integer modulus with multiplication → KILLED 2. evaluatorEntriesToString : Replaced integer addition with subtraction → KILLED |
int formNameColumnLength = (formNameColumnLength = Math.max( |
| 329 |
1
1. evaluatorEntriesToString : negated conditional → KILLED |
DebuggingUtils.showEvaluableDetail() ? 80 : 12, |
| 330 | Math.min(InternalUtils.summarizedStringLength(), maxIndentAndFormNameLength))) + formNameColumnLength % 2; | |
| 331 | Function<FormattedEntry, String> formatter = formatterFactory.apply( | |
| 332 | new int[]{maxInputLength, formNameColumnLength, maxOutputLength}); | |
| 333 |
1
1. evaluatorEntriesToString : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::evaluatorEntriesToString → KILLED |
return formattedEntries |
| 334 | .stream() | |
| 335 | .map(formatter) | |
| 336 |
1
1. lambda$evaluatorEntriesToString$16 : replaced return value with "" for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$evaluatorEntriesToString$16 → KILLED |
.map(s -> ("+" + s).trim().substring(1)) |
| 337 | .collect(joining(format("%n"))); | |
| 338 | } | |
| 339 | | |
| 340 | private static List<FormattedEntry> hideInputValuesWhenRepeated(List<FormattedEntry> formattedEntries) { | |
| 341 | AtomicReference<Object> previousInput = new AtomicReference<>(); | |
| 342 |
1
1. hideInputValuesWhenRepeated : replaced return value with Collections.emptyList for com/github/valid8j/pcond/validator/ReportComposer$Utils::hideInputValuesWhenRepeated → KILLED |
return formattedEntries.stream() |
| 343 | .map(each -> { | |
| 344 |
1
1. lambda$hideInputValuesWhenRepeated$17 : negated conditional → KILLED |
if (!Objects.equals(previousInput.get(), each.input())) { |
| 345 |
1
1. lambda$hideInputValuesWhenRepeated$17 : removed call to java/util/concurrent/atomic/AtomicReference::set → KILLED |
previousInput.set(each.input()); |
| 346 |
1
1. lambda$hideInputValuesWhenRepeated$17 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$hideInputValuesWhenRepeated$17 → KILLED |
return each; |
| 347 | } else { | |
| 348 |
1
1. lambda$hideInputValuesWhenRepeated$17 : replaced return value with null for com/github/valid8j/pcond/validator/ReportComposer$Utils::lambda$hideInputValuesWhenRepeated$17 → KILLED |
return new FormattedEntry("", each.formName(), each.indent(), each.output().orElse(null), each.requiresExplanation()); |
| 349 | } | |
| 350 | }) | |
| 351 | .collect(toList()); | |
| 352 | } | |
| 353 | | |
| 354 | | |
| 355 | } | |
| 356 | } | |
Mutations | ||
| 25 |
1.1 |
|
| 29 |
1.1 |
|
| 33 |
1.1 |
|
| 37 |
1.1 |
|
| 41 |
1.1 2.2 |
|
| 57 |
1.1 |
|
| 60 |
1.1 |
|
| 65 |
1.1 |
|
| 87 |
1.1 |
|
| 91 |
1.1 |
|
| 95 |
1.1 |
|
| 99 |
1.1 |
|
| 103 |
1.1 2.2 |
|
| 119 |
1.1 2.2 |
|
| 124 |
1.1 |
|
| 132 |
1.1 |
|
| 134 |
1.1 |
|
| 144 |
1.1 |
|
| 146 |
1.1 |
|
| 152 |
1.1 |
|
| 160 |
1.1 |
|
| 169 |
1.1 |
|
| 172 |
1.1 |
|
| 173 |
1.1 |
|
| 178 |
1.1 2.2 |
|
| 183 |
1.1 2.2 3.3 |
|
| 185 |
1.1 |
|
| 186 |
1.1 |
|
| 188 |
1.1 |
|
| 189 |
1.1 |
|
| 192 |
1.1 |
|
| 193 |
1.1 |
|
| 194 |
1.1 2.2 |
|
| 202 |
1.1 |
|
| 204 |
1.1 |
|
| 206 |
1.1 |
|
| 207 |
1.1 |
|
| 208 |
1.1 2.2 |
|
| 211 |
1.1 |
|
| 216 |
1.1 2.2 3.3 4.4 |
|
| 220 |
1.1 |
|
| 228 |
1.1 |
|
| 230 |
1.1 |
|
| 238 |
1.1 |
|
| 245 |
1.1 2.2 |
|
| 249 |
1.1 |
|
| 250 |
1.1 2.2 3.3 |
|
| 257 |
1.1 |
|
| 262 |
1.1 |
|
| 268 |
1.1 |
|
| 272 |
1.1 |
|
| 280 |
1.1 |
|
| 282 |
1.1 |
|
| 296 |
1.1 |
|
| 297 |
1.1 2.2 |
|
| 298 |
1.1 |
|
| 305 |
1.1 2.2 |
|
| 308 |
1.1 |
|
| 309 |
1.1 |
|
| 311 |
1.1 |
|
| 319 |
1.1 2.2 |
|
| 321 |
1.1 |
|
| 322 |
1.1 2.2 |
|
| 325 |
1.1 2.2 |
|
| 328 |
1.1 2.2 |
|
| 329 |
1.1 |
|
| 333 |
1.1 |
|
| 336 |
1.1 |
|
| 342 |
1.1 |
|
| 344 |
1.1 |
|
| 345 |
1.1 |
|
| 346 |
1.1 |
|
| 348 |
1.1 |