Sample

Schnappinger/junit4/org.junit.internal.TextListener

Human rating uses the original dataset scale.

Human3.96
Lines101

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
35.1Δ 45.2
Scalabrino0.7670–1; higher is more readable
53.4Δ 26.9
Dorn0.2490–1; higher is more readable
44.9Δ 35.5
Mi0.6850–1; higher is more readable
79.9Δ 0.5
LLOC43Logical lines; fewer is more readable
41.1Δ 39.3
DeepSeek V4 Pro16.670–20; mean of three runs
59.9Δ 20.5
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 6.6
BTTF0.3640–1; higher is more readable
29.7Δ 50.7
Human3.961–4; original rating
80.4

Views

Source code

package org.junit.internal; import java.io.PrintStream; import java.text.NumberFormat; import java.util.List; import org.junit.runner.Description; import org.junit.runner.Result; import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; public class TextListener extends RunListener { private final PrintStream fWriter; public TextListener(JUnitSystem system) { this(system.out()); } public TextListener(PrintStream writer) { this.fWriter = writer; } @Override public void testRunFinished(Result result) { printHeader(result.getRunTime()); printFailures(result); printFooter(result); } @Override public void testStarted(Description description) { fWriter.append('.'); } @Override public void testFailure(Failure failure) { fWriter.append('E'); } @Override public void testIgnored(Description description) { fWriter.append('I'); } /* * Internal methods */ private PrintStream getWriter() { return fWriter; } protected void printHeader(long runTime) { getWriter().println(); getWriter().println("Time: " + elapsedTimeAsString(runTime)); } protected void printFailures(Result result) { List<Failure> failures = result.getFailures(); if (failures.size() == 0) { return; } if (failures.size() == 1) { getWriter().println("There was " + failures.size() + " failure:"); } else { getWriter().println("There were " + failures.size() + " failures:"); } int i = 1; for (Failure each : failures) { printFailure(each, "" + i++); } } protected void printFailure(Failure each, String prefix) { getWriter().println(prefix + ") " + each.getTestHeader()); getWriter().print(each.getTrace()); } protected void printFooter(Result result) { if (result.wasSuccessful()) { getWriter().println(); getWriter().print("OK"); getWriter().println(" (" + result.getRunCount() + " test" + (result.getRunCount() == 1 ? "" : "s") + ")"); } else { getWriter().println(); getWriter().println("FAILURES!!!"); getWriter().println("Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()); } getWriter().println(); } /** * Returns the formatted string of the elapsed time. Duplicated from * BaseTestRunner. Fix it. */ protected String elapsedTimeAsString(long runTime) { return NumberFormat.getInstance().format((double) runTime / 1000); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3573.601−117.929
Source linesThe number of non-empty source lines.101+40.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.527−6.791

Intercept 8.87 + feature contributions = -75.45 (log-odds).
Score = sigmoid(-75.45) = 0.

Score0.767

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.96+2.583
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.102−2.575
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.96−1.782
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.117.98−1.332
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.117.961+1.099
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.100.908+1.001
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.114−0.166

Intercept 0.07 + feature contributions = -1.102 (log-odds).
Score = sigmoid(-1.102) = 0.249.

Score0.685
Score43
Run 1

The code is generally readable and well-structured. It follows a clear logical flow: testRunFinished orchestrates header, failures, and footer printing. Methods are concise, with one primary action per line in most cases. Nesting levels are shallow, maxing out at two levels inside printFailures and printFooter. Naming is mostly clear, especially method names that describe their purpose. The constructor overloading is straightforward. However, some issues affect readability: the field name fWriter uses outdated Hungarian notation, and the getWriter() method adds unnecessary indirection for private field access. The printFooter method has awkward string concatenation with a ternary operator inline, making it harder to parse. The printFailures method could use a modern string format for the failure count. The comment referencing 'BaseTestRunner. Fix it' indicates technical debt but doesn't impact current clarity. Overall, the code is maintainable and easy to follow, with minimal room for improvement.

Run 2

The code is well-structured into logical methods representing test lifecycle events, with clear separation between public callbacks and internal helpers. Nesting is minimal—only one level in conditionals and loops, maintaining flat control flow. Intent is clear through descriptive method and variable names (e.g., printFailures, elapsedTimeAsString). Code length is appropriate, with minimal duplication except for the documented elapsedTimeAsString method. Each line generally performs one action, though some print statements combine string concatenation. Reading flow is natural: header, failures, footer in sequential order. Minor critiques include the 'f' prefix notation in field names (legacy style), and the helper methods are protected rather than private for no apparent reason, which slightly obscures intent. Overall, the code is highly readable and maintainable.

Run 3

The code is well-structured, with a clear separation between public hooks and internal helper methods. Nesting is shallow, and each method performs a clear, single responsibility. The flow of execution is easy to follow: header, failures, footer. Minor deductions: the use of the cryptic 'f' prefix on the field is outdated, the duplicated time formatting comment signals unresolved tech debt, and the conditional string building in printFooter spans multiple lines, slightly disrupting readability. Overall, intent is clear and actions are appropriately granular.

Run 1

Code Structure: Well-organized listener callbacks delegate reporting to focused helper methods. Nesting: Shallow conditionals and a simple loop keep control flow easy to follow; an early return avoids unnecessary nesting. Clarity of intent: Descriptive method names clearly communicate test reporting, though fWriter, each, and the implicit milliseconds-to-seconds conversion are less explicit. Code length: Mostly concise, with minor repetition in writer access and failure-count formatting. Action granularity: Most lines perform one action, but printFailure(each, "" + i++) combines conversion, incrementing, and invocation. Reading flow: Callbacks followed by reporting helpers create a natural progression. Long concatenated output expressions and the embedded pluralization ternary slightly interrupt readability.

Run 2

Code Structure: Well organized into listener callbacks and focused output helpers, with clear separation of responsibilities. Nesting: Shallow conditionals and an early return keep control flow easy to follow. Clarity of intent: Descriptive method names make the reporting purpose obvious; fWriter, each, and the implicit milliseconds-to-seconds conversion are slightly less explicit. Code length: Concise overall, though repeated getWriter() and failures.size() calls add minor verbosity. Action granularity: Most lines perform one action, but printFailure(each, "" + i++) combines formatting, incrementing, and invocation. Reading flow: testRunFinished presents a natural header-failures-footer sequence, supported by consistently ordered helpers. Long concatenations and the inline pluralization ternary slightly interrupt otherwise smooth reading.

Run 3

Code Structure: Well organized into listener callbacks and focused output helpers, with reporting split into header, failures, and footer. Nesting: Shallow conditionals and a single loop; the early return avoids unnecessary nesting. Clarity of intent: Descriptive method names make the reporting purpose clear, although fWriter, each, and the implicit milliseconds-to-seconds conversion are less explicit. Code length: Concise overall, with minor repetition in writer access and failure-count retrieval. Action granularity: Most lines perform one action, but printFailure(each, "" + i++) combines formatting, incrementing, and a method call. Reading flow: testRunFinished presents a natural reporting sequence, and related methods are grouped logically. Long string concatenations and an inline pluralization ternary slightly interrupt readability.