Sample

Schnappinger/junit4/org.junit.runner.manipulation.Sorter

Human rating uses the original dataset scale.

Human3.73
Lines48

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett0.0030–1; higher is more readable
69.6Δ 27.3
Scalabrino0.8110–1; higher is more readable
64.7Δ 22.5
Dorn0.540–1; higher is more readable
62.0Δ 19.8
Mi0.1820–1; higher is more readable
14.9Δ 27.4
LLOC12Logical lines; fewer is more readable
69.1Δ 26.9
DeepSeek V4 Pro17.670–20; mean of three runs
83.0Δ 40.8
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 31.5
BTTF0.7060–1; higher is more readable
83.2Δ 40.9
Human3.731–4; original rating
42.2

Views

Source code

package org.junit.runner.manipulation; import java.util.Comparator; import org.junit.runner.Description; /** * A <code>Sorter</code> orders tests. In general you will not need * to use a <code>Sorter</code> directly. Instead, use {@link org.junit.runner.Request#sortWith(Comparator)}. * * @since 4.0 */ public class Sorter implements Comparator<Description> { /** * NULL is a <code>Sorter</code> that leaves elements in an undefined order */ public static final Sorter NULL = new Sorter(new Comparator<Description>() { public int compare(Description o1, Description o2) { return 0; } }); private final Comparator<Description> fComparator; /** * Creates a <code>Sorter</code> that uses <code>comparator</code> * to sort tests * * @param comparator the {@link Comparator} to use when sorting tests */ public Sorter(Comparator<Description> comparator) { fComparator = comparator; } /** * Sorts the test in <code>runner</code> using <code>comparator</code> */ public void apply(Object object) { if (object instanceof Sortable) { Sortable sortable = (Sortable) object; sortable.sort(this); } } public int compare(Description o1, Description o2) { return fComparator.compare(o1, o2); } }

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.816.525−26.945
Source linesThe number of non-empty source lines.48+19.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.538−6.808

Intercept 8.87 + feature contributions = -5.683 (log-odds).
Score = sigmoid(-5.683) = 0.003.

Score0.811

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.108.98+0.954
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.108.98−0.951
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.49−0.699
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.448
Indentation frequencyHow rapidly indentation changes from line to line.34+0.439
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.34−0.359
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.47.682+0.257

Intercept 0.07 + feature contributions = 0.159 (log-odds).
Score = sigmoid(0.159) = 0.54.

Score0.182
Score12
Run 1

The code is highly readable with a clear logical structure: constants, fields, constructors, and methods are well-organized. Nesting is minimal, with only one level in the NULL anonymous comparator. Javadoc explains the class purpose and methods, making intent clear. The code is concise, avoiding unnecessary verbosity while maintaining clarity. Each line performs a single action, and the reading flow is natural from class overview to implementation details. Minor deductions: the field name 'fComparator' uses an outdated Hungarian-style prefix, and the 'apply' method's 'Object' parameter is untyped, slightly reducing clarity. Overall, this is exemplary readable code.

Run 2

The code is well-structured with a clear class definition, appropriate imports, and helpful Javadoc comments. Naming is conventional, and the use of constants like NULL improves readability. Nesting is minimal, with only one level inside the anonymous Comparator. The intent of each method is clear: apply determines if sorting is applicable, while compare delegates to the held comparator. The code is concise and avoids unnecessary length. Each line generally performs a single action, and the reading flow moves naturally from constants to constructor to methods. Minor deductions: the Hungarian-style prefix 'fComparator' is somewhat dated, and the apply method's parameter type could be more specific. Overall, this is a clean and maintainable utility class.

Run 3

The code is well-structured and highly readable. It has clear separation of concerns: the Sorter class encapsulates a comparator, provides a NULL implementation, and applies sorting only if the target is Sortable. Nesting is minimal, with no deep indentation. Intent is obvious from the class name, method names, and Javadoc comments. Code length is appropriate—no unnecessary boilerplate. Each line performs a single logical action, improving granularity. Reading flow follows a natural order: constants, fields, constructors, and methods. The only minor weaknesses are the use of the outdated `f` prefix on `fComparator`, which slightly reduces clarity, and the `apply` method taking `Object` rather than a more specific type, which requires an instanceof check. Overall, the code is clean, maintainable, and easy to understand.

Run 1

Code Structure: The class is logically organized into a default sorter, comparator field, constructor, application method, and comparison method. Nesting: Minimal nesting; only a single conditional and a small anonymous comparator. Clarity of intent: The sorting and delegation behavior is clear, supported by documentation. However, names such as fComparator and o1/o2 are less descriptive, and apply's documentation refers to runner and comparator rather than its actual parameter. Code length: Concise, with no unnecessary implementation complexity. Action granularity: Each statement performs one action, making individual steps easy to follow. Reading flow: Natural progression from configuration to behavior, with consistent formatting and spacing. Minor documentation and naming issues prevent a perfect score.

Run 2

Code Structure: Well organized into a default sorter, comparator field, constructor, application method, and comparison delegation. Nesting: Shallow; only one conditional and a small anonymous comparator. Clarity of intent: Class documentation and straightforward delegation make the purpose clear, though NULL, fComparator, and o1/o2 are less descriptive names. The apply documentation references runner and comparator rather than its actual object parameter, slightly reducing clarity. Code length: Concise, with no unnecessary implementation logic. Action granularity: Each statement performs one clear action. Reading flow: Natural progression from configuration to behavior, supported by whitespace and documentation. Overall, highly readable with minor naming and documentation issues.

Run 3

Code Structure: The class is logically organized into a default sorter, comparator field, constructor, application method, and comparison delegation. Nesting: Minimal; only a simple conditional and an anonymous comparator add nesting. Clarity of intent: The class purpose and delegation are clear, supported by documentation. However, NULL, fComparator, and o1/o2 are less descriptive names, and apply's documentation references runner and comparator rather than its actual parameter. Code length: Concise, with little unnecessary code. Action granularity: Each statement performs a single clear action. Reading flow: Natural top-to-bottom organization makes behavior easy to follow, with minor documentation inconsistencies slightly reducing readability.