Sample

Schnappinger/jsweet/def.dom.Selection

Human rating uses the original dataset scale.

Human4
Lines27

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
54.2Δ 42.2
Scalabrino0.9160–1; higher is more readable
93.5Δ 2.9
Dorn0.1460–1; higher is more readable
36.6Δ 59.7
Mi0.0160–1; higher is more readable
3.3Δ 93.1
LLOC23Logical lines; fewer is more readable
55.9Δ 40.4
DeepSeek V4 Pro16.330–20; mean of three runs
53.1Δ 43.2
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 22.6
BTTF0.5640–1; higher is more readable
51.8Δ 44.6
Human41–4; original rating
96.4

Views

Source code

package def.dom; public class Selection extends def.js.Object { public Node anchorNode; public double anchorOffset; public Node focusNode; public double focusOffset; public Boolean isCollapsed; public double rangeCount; public String type; native public void addRange(Range range); native public void collapse(Node parentNode, double offset); native public void collapseToEnd(); native public void collapseToStart(); native public Boolean containsNode(Node node, Boolean partlyContained); native public void deleteFromDocument(); native public void empty(); native public void extend(Node newNode, double offset); native public Range getRangeAt(double index); native public void removeAllRanges(); native public void removeRange(Range range); native public void selectAllChildren(Node parentNode); native public void setBaseAndExtent(Node baseNode, double baseOffset, Node extentNode, double extentOffset); native public String toString(); public static Selection prototype; public Selection(){} }

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.1090.75−35.995
Source linesThe number of non-empty source lines.27+10.8
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.519−6.779

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

Score0.916

Feature contributions

FeatureValueContribution
(log-odds)
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.112−1.079
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Indentation frequencyHow rapidly indentation changes from line to line.1−0.703
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.062+0.339
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.28+0.045
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.26.85−0.035

Intercept 0.07 + feature contributions = -1.768 (log-odds).
Score = sigmoid(-1.768) = 0.146.

Score0.016
Score23
Run 1

The code is highly readable. It has a logical structure with clear separation between properties and methods, following a consistent ordering. There is no nesting, as it's a flat class definition. The intent is unambiguous: it implements the DOM Selection interface. The code is concise; each method is declared in a single line, which is appropriate for native bindings. Action granularity is excellent, with one action per line. Reading flow is natural, with related methods grouped together and a familiar naming convention. The only minor drawback is the automatic generation artifact of an empty constructor, but this doesn't significantly impact readability.

Run 2

The code is straightforward and well-structured for a DOM API wrapper. It declares fields before methods, maintains consistent formatting, and uses clear method names that match the underlying Selection API. Nesting is non-existent, and each line represents one declaration or action. The only minor issues are the use of `double` for offsets that are typically integers in JavaScript, and `Boolean` wrapper objects instead of primitives, which could confuse readers unfamiliar with the codebase's conventions. The constructor at the end is slightly out of logical order, but this is a minor structural issue. Overall, the code is highly readable, concise, and unambiguous in its intent.

Run 3

The code demonstrates decent structure with clear separation between fields and methods. It follows Java-like conventions with public fields declared first, then methods, which aids readability. Each declaration is on its own line, maintaining good action granularity. The nesting is completely flat with no conditional blocks or loops, which is appropriate for this type of interface/type definition. Method names are descriptive and follow standard DOM API conventions, making intent clear. However, the code loses points for several reasons: the 'native' keyword without context is ambiguous, there's inconsistent use of wrapper types (Boolean vs double vs String), and no comments or documentation explaining the purpose of the class or its members. While concise, the absence of any explanatory context and the repetitive native method declarations make it feel like boilerplate code rather than thoughtfully designed code.

Run 1

Code Structure: Fields and native methods are logically grouped, although the static prototype field and constructor could be separated more clearly. Nesting: Only a single class scope, making the code easy to scan. Clarity of intent: Familiar DOM Selection terminology and descriptive method and parameter names communicate purpose well; the native-binding context is implicit. Code length: Concise declarations with no unnecessary implementation details. Action granularity: Each field or method declaration occupies its own line. Reading flow: Consistent formatting and related method names support natural reading, though blank lines between sections and conventional modifier ordering would improve presentation.

Run 2

Code Structure: Fields and native methods are logically grouped, though the trailing prototype field and constructor slightly weaken organization. Nesting: Only the class scope is present, making the code easy to scan. Clarity of intent: Descriptive names clearly identify a DOM selection API; native declarations appropriately omit implementations. Code length: Concise, with no unnecessary logic or repetition beyond the required API declarations. Action granularity: Each field or method declaration occupies its own line. Reading flow: Consistent indentation and predictable declarations support natural reading, but blank lines between member groups and conventional 'public native' modifier ordering would improve readability.

Run 3

Code Structure: Clearly organized as a compact API declaration, with fields followed by methods, though the static prototype and constructor placement slightly weaken grouping. Nesting: Flat, with no nested control flow. Clarity of intent: Descriptive class, field, and method names make the selection API understandable; native declarations appropriately omit implementation details. Code length: Concise, with little unnecessary content. Action granularity: Each field or method declaration occupies its own line. Reading flow: Consistent indentation and predictable declarations support easy scanning, but blank lines between sections and conventional 'public native' modifier ordering would improve readability.