Sample

Schnappinger/jsweet/def.dom.CanvasRenderingContext2D

Human rating uses the original dataset scale.

Human3.9
Lines96

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
18.1Δ 33.3
Scalabrino0.8160–1; higher is more readable
66.8Δ 15.5
Dorn00–1; higher is more readable
7.6Δ 43.7
Mi00–1; higher is more readable
0.7Δ 50.7
LLOC91Logical lines; fewer is more readable
26.2Δ 25.1
DeepSeek V4 Pro4.330–20; mean of three runs
1.0Δ 50.3
GPT-6.1 Sol140–20; mean of three runs
16.2Δ 35.1
BTTF0.4030–1; higher is more readable
34.0Δ 17.3
Human3.91–4; original rating
51.3

Views

Source code

package def.dom; import jsweet.util.union.Union3; public class CanvasRenderingContext2D extends def.js.Object { public HTMLCanvasElement canvas; public Union3<String,CanvasGradient,CanvasPattern> fillStyle; public String font; public double globalAlpha; public String globalCompositeOperation; public String lineCap; public double lineDashOffset; public String lineJoin; public double lineWidth; public double miterLimit; public String msFillRule; public Boolean msImageSmoothingEnabled; public double shadowBlur; public String shadowColor; public double shadowOffsetX; public double shadowOffsetY; public Union3<String,CanvasGradient,CanvasPattern> strokeStyle; public String textAlign; public String textBaseline; native public void arc(double x, double y, double radius, double startAngle, double endAngle, Boolean anticlockwise); native public void arcTo(double x1, double y1, double x2, double y2, double radius); native public void beginPath(); native public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); native public void clearRect(double x, double y, double w, double h); native public void clip(String fillRule); native public void closePath(); native public ImageData createImageData(double imageDataOrSw, double sh); native public CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1); native public CanvasPattern createPattern(HTMLImageElement image, String repetition); native public CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth, double canvasImageHeight); native public void fill(String fillRule); native public void fillRect(double x, double y, double w, double h); native public void fillText(String text, double x, double y, double maxWidth); native public ImageData getImageData(double sx, double sy, double sw, double sh); native public double[] getLineDash(); native public Boolean isPointInPath(double x, double y, String fillRule); native public void lineTo(double x, double y); native public TextMetrics measureText(String text); native public void moveTo(double x, double y); native public void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight); native public void quadraticCurveTo(double cpx, double cpy, double x, double y); native public void rect(double x, double y, double w, double h); native public void restore(); native public void rotate(double angle); native public void save(); native public void scale(double x, double y); native public void setLineDash(double[] segments); native public void setTransform(double m11, double m12, double m21, double m22, double dx, double dy); native public void stroke(); native public void strokeRect(double x, double y, double w, double h); native public void strokeText(String text, double x, double y, double maxWidth); native public void transform(double m11, double m12, double m21, double m22, double dx, double dy); native public void translate(double x, double y); public static CanvasRenderingContext2D prototype; public CanvasRenderingContext2D(){} native public void arc(double x, double y, double radius, double startAngle, double endAngle); native public void clip(); native public ImageData createImageData(double imageDataOrSw); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width, double height); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY, double width); native public void drawImage(HTMLImageElement image, double offsetX, double offsetY); native public void fill(); native public void fillText(String text, double x, double y); native public Boolean isPointInPath(double x, double y); native public void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth); native public void putImageData(ImageData imagedata, double dx, double dy, double dirtyX, double dirtyY); native public void putImageData(ImageData imagedata, double dx, double dy, double dirtyX); native public void putImageData(ImageData imagedata, double dx, double dy); native public void strokeText(String text, double x, double y); native public ImageData createImageData(ImageData imageDataOrSw, double sh); native public CanvasPattern createPattern(HTMLVideoElement image, String repetition); native public CanvasPattern createPattern(HTMLCanvasElement image, String repetition); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth, double canvasImageHeight); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth, double canvasImageHeight); native public ImageData createImageData(ImageData imageDataOrSw); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY, double canvasImageWidth); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX, double canvasOffsetY); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width, double height, double canvasOffsetX); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width, double height); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width, double height); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY, double width); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY, double width); native public void drawImage(HTMLVideoElement image, double offsetX, double offsetY); native public void drawImage(HTMLCanvasElement image, double offsetX, double offsetY); }

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.9684.694−319.595
Source linesThe number of non-empty source lines.96+38.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.737−7.106

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

Score0.816

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.213.948−5.397
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.97−2.398
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.95−1.759
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.95.944+0.931
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
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.061+0.347

Intercept 0.07 + feature contributions = -9.712 (log-odds).
Score = sigmoid(-9.712) = 0.

Score0
Score91
Run 1

This code is highly unreadable. While it is logically organized as a class definition with fields and methods, the structure is undermined by massive method overloading and repetitive parameter lists. Nesting is not an issue (flat structure), but clarity of intent is severely hampered by ambiguous parameter names like 'imageDataOrSw' and overloaded methods with no documentation. Code length is excessive and unnecessarily long due to dozens of near-duplicate overloads for drawImage, putImageData, and createImageData. Action granularity is acceptable (one declaration per line), but reading flow is poor because related overloads are scattered and interleaved rather than grouped logically. The lack of comments or separation between overload variants makes it difficult to discern which version serves what purpose.

Run 2

This is an auto-generated or machine-written type declaration file that is extremely unreadable by human standards. The structure is technically flat, but the class is a disorganized dump of fields and overloaded methods. There is no logical grouping, comments, or sectioning. Nesting is minimal, which is the only positive. Clarity of intent is low—method names follow DOM API names, but parameter names like 'imageDataOrSw' and 'dirtyX' are unclear, and the excessive overloading creates ambiguity. Code length is unnecessarily long due to repetitive overloads that could be organized or documented. Action granularity is technically one method per line, but lines are extremely long and overloaded, reducing readability. Reading flow is poor: fields are listed first, then methods, then overloads in a near-random sequence (e.g., createImageData appears repeatedly in different forms). Overall, the code is machinable but not human-friendly.

Run 3

This code is a machine-generated type definition file for the Canvas 2D API. While it has a flat structure with one method declaration per line, it suffers from severe readability issues. The main problems are extreme repetition (especially the drawImage overloads with 12+ nearly identical variants), ambiguous parameter names like 'imageDataOrSw', and poor organization where overloaded methods are scattered throughout the file rather than grouped together. The mix of type unions, native declarations, and inconsistent parameter ordering creates cognitive overhead. The code length is unnecessarily inflated by redundant overloads that could be handled with optional parameters or union types. Reading flow is disrupted by jumping between different method overloads across the file. While it's technically parseable and follows Java/JSweet conventions, it reads like auto-generated boilerplate rather than human-maintained code, making it difficult to scan or understand at a glance.

Run 1

Code Structure: Fields precede methods, but related overloads are scattered and lack functional grouping. Nesting: Completely flat declarations make individual members easy to scan. Clarity of intent: The class and most member names clearly describe a canvas API; abbreviated parameters and absent documentation obscure some signatures. Code length: Extensive repetitive overloads create substantial scanning overhead, although they serve an API-binding purpose rather than redundant implementation logic. Action granularity: Each field or method declaration occupies its own line, providing consistent granularity. Reading flow: Consistent indentation helps, but missing blank-line separators, very long signatures, and interleaved overload variants interrupt navigation. Grouping overloads together and separating functional sections would improve readability.

Run 2

Code Structure: Fields precede methods, but related overloads are scattered and the prototype and constructor interrupt the method list. Nesting: Completely flat apart from the class scope, making individual declarations easy to inspect. Clarity of intent: The class and method names clearly identify a canvas API binding, although abbreviated or overloaded parameter names and absent documentation obscure some signatures. Code length: Concise declarations suit a native binding, but numerous repetitive overloads and very long signatures make scanning tedious. Action granularity: Each line contains a single declaration, with no compound operations. Reading flow: Consistent indentation and an initially alphabetical method sequence help, but missing whitespace between sections and inconsistent overload grouping weaken navigation.

Run 3

1. Code Structure: Fields precede methods, but related overloads are scattered and lack functional grouping. 2. Nesting: Entirely flat declarations make the code easy to scan; there is no nested logic. 3. Clarity of intent: The class and method names clearly identify a canvas API binding, though abbreviated parameters and undocumented overload differences reduce clarity. 4. Code length: Individual declarations are concise, but numerous repetitive overloads and very long signatures make the class cumbersome to read. Some repetition is inherent to this binding style. 5. Action granularity: Each line contains one field, method, or constructor declaration, providing consistent granularity. 6. Reading flow: Consistent indentation helps, but missing blank lines, dispersed overload families, and interleaved image types interrupt natural navigation.