Sample

Schnappinger/junit4/org.junit.experimental.results.PrintableResult

Human rating uses the original dataset scale.

Human3.97
Lines63

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
59.2Δ 24.1
Scalabrino0.8350–1; higher is more readable
71.2Δ 12.1
Dorn0.8560–1; higher is more readable
93.4Δ 10.1
Mi0.6550–1; higher is more readable
74.6Δ 8.7
LLOC14Logical lines; fewer is more readable
66.8Δ 16.5
DeepSeek V4 Pro180–20; mean of three runs
91.4Δ 8.1
GPT-6.1 Sol190–20; mean of three runs
92.6Δ 9.2
BTTF0.6890–1; higher is more readable
78.2Δ 5.1
Human3.971–4; original rating
83.3

Views

Source code

package org.junit.experimental.results; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.List; import org.junit.internal.TextListener; import org.junit.runner.JUnitCore; import org.junit.runner.Request; import org.junit.runner.Result; import org.junit.runner.notification.Failure; /** * A test result that prints nicely in error messages. * This is only intended to be used in JUnit self-tests. * For example: * * <pre> * assertThat(testResult(HasExpectedException.class), isSuccessful()); * </pre> */ public class PrintableResult { private Result result; /** * The result of running JUnit on {@code type} */ public static PrintableResult testResult(Class<?> type) { return testResult(Request.aClass(type)); } /** * The result of running JUnit on Request {@code request} */ public static PrintableResult testResult(Request request) { return new PrintableResult(new JUnitCore().run(request)); } /** * A result that includes the given {@code failures} */ public PrintableResult(List<Failure> failures) { this(new FailureList(failures).result()); } private PrintableResult(Result result) { this.result = result; } /** * Returns the number of failures in this result. */ public int failureCount() { return result.getFailures().size(); } @Override public String toString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); new TextListener(new PrintStream(stream)).testRunFinished(result); return stream.toString(); } }

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.1329.884−43.886
Source linesThe number of non-empty source lines.63+25.2
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.626−6.939

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

Score0.835

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.63−1.194
Indentation frequencyHow rapidly indentation changes from line to line.47+0.889
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.73.968+0.532
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.61.907+0.456
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.81+0.386
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.071+0.248

Intercept 0.07 + feature contributions = 1.784 (log-odds).
Score = sigmoid(1.784) = 0.856.

Score0.655
Score14
Run 1

The code is well-structured with clear separation between constructors, static factory methods, and instance methods. It is flat, with no nested blocks beyond the class scope. Intents are evident from descriptive method names and Javadocs. The length is concise, each line performs a single logical action, and reading flow follows a natural progression from API entry points (testResult) to constructors and public methods. Minor deductions: the private constructor is slightly hidden after the public one, which disrupts flow slightly. Overall, the code is highly readable and maintainable.

Run 2

The code is highly readable with clear structure and purpose. The class has a single responsibility with well-named methods and descriptive Javadoc comments. The nesting is flat, with only one level in most methods. The code length is appropriate, and each line performs a single action. The reading flow is natural, following a logical progression from public API to private constructor to utility methods. The static factory methods provide clear intent, and the toString method is concise. Minor deductions: the public constructor with List<Failure> could benefit from a slightly clearer name, and the private constructor doesn't validate nulls, but these are minor issues in an otherwise exemplary piece of code.

Run 3

The code is highly readable due to its clear structure and logical organization. The class has a single responsibility with well-named methods and minimal nesting. Each method is concise and performs one action, contributing to natural reading flow. The static factory methods provide clear intent for creating test results, and the private constructor maintains encapsulation. The toString method's implementation is straightforward. Minor deductions could come from the slight indirection with the FailureList class, but overall the code is clean, well-documented, and easy to understand.

Run 1

Code Structure: Logically organized into factory methods, constructors, and result-access/output methods. Nesting: Flat, with no nested control flow. Clarity of intent: Descriptive names and concise Javadoc clearly explain the class's purpose and usage. Code length: Short and focused, with minimal boilerplate or repetition. Action granularity: Most lines perform one action; chained construction and calls in testResult and toString compress several operations but remain understandable. Reading flow: Natural progression from creating results to inspecting and formatting them. Minor readability limitations include the generic field name result and the implicit role of TextListener in producing the string representation.

Run 2

Code Structure: Well-organized class with factory methods, constructors, and result-access methods grouped logically. Nesting: Flat methods with no nested control flow. Clarity of intent: Descriptive names and focused Javadoc clearly explain the class and its methods; the chained listener invocation in toString requires slight familiarity with JUnit. Code length: Concise implementation with little unnecessary code. Action granularity: Generally one action per line, though nested construction and method calls combine several operations in individual expressions. Reading flow: Natural progression from creating results to inspecting and formatting them, supported by consistent formatting and spacing.

Run 3

Code Structure: Clearly organized into factory methods, constructors, and result-access methods, with focused responsibilities. Nesting: Flat method bodies with no nested control flow. Clarity of intent: Descriptive names and concise Javadoc explain the class and its intended use; the TextListener-based formatting is slightly less obvious without JUnit knowledge. Code length: Compact, with no unnecessary implementation detail or repetition. Action granularity: Statements occupy separate lines, although chained calls combine object creation and execution in a few expressions. Reading flow: Natural progression from creating results to inspecting and formatting them, supported by consistent formatting and spacing.