Sample
Schnappinger/junit4/org.junit.rules.ExternalResource
Human rating uses the original dataset scale.
Scores
| Method | Score | Scale | Dataset rank (0–100) |
|---|---|---|---|
| Posnett | 1 | 0–1; higher is more readable | 93.3Δ 54.2 |
| Scalabrino | 0.899 | 0–1; higher is more readable | 89.0Δ 49.9 |
| Dorn | 0.794 | 0–1; higher is more readable | 84.5Δ 45.4 |
| Mi | 0.651 | 0–1; higher is more readable | 73.3Δ 34.2 |
| LLOC | 11 | Logical lines; fewer is more readable | 70.6Δ 31.5 |
| DeepSeek V4 Pro | 17.67 | 0–20; mean of three runs | 83.0Δ 43.9 |
| GPT-6.1 Sol | 18 | 0–20; mean of three runs | 73.8Δ 34.7 |
| BTTF | 0.74 | 0–1; higher is more readable | 89.8Δ 50.7 |
| Human | 3.46 | 1–4; original rating | 39.1 |
Views
Loading feature diagnosis…
Source regions
Feature contributions
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Source linesThe number of non-empty source lines. | 71 | +28.4 |
| Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones. | 626.834 | −20.686 |
| 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.345 | −6.517 |
Intercept 8.87 + feature contributions = 10.068 (log-odds).
Score = sigmoid(10.068) = 1.
| Score | 0.899 |
|---|
Feature contributions
| Feature | Value | Contribution (log-odds) |
|---|---|---|
| Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code. | 72 | −1.513 |
| Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *. | 0.034 | +0.61 |
| Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom. | 70.861 | +0.581 |
| Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right. | 76.958 | +0.437 |
| Indentation frequencyHow rapidly indentation changes from line to line. | 33 | +0.404 |
| Number layout frequencyHow rapidly the number of numeric values per line changes through the code. | 1 | +0.398 |
| 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. | 77.986 | +0.362 |
Intercept 0.07 + feature contributions = 1.349 (log-odds).
Score = sigmoid(1.349) = 0.794.
| Score | 0.651 |
|---|
| Score | 11 |
|---|
Run 1
The code is highly readable due to its clear structure, minimal nesting, and well-documented intent. The class follows a logical organization: the apply method delegates to a private statement method, which returns an anonymous Statement with a flat try-finally block. Action granularity is good, with one primary operation per line in the critical evaluate method. The reading flow is natural, aided by Javadoc examples and concise method names (before/after). While the anonymous inner class adds slight complexity, it is standard for JUnit rules and well-contained. Code length is appropriate, avoiding unnecessary verbosity while including essential documentation.
Run 2
The code is highly readable with a clear, logical structure. The class is well-organized, featuring a concise public API and a private helper method that encapsulates the try-finally logic to ensure proper resource cleanup. Nesting is minimal, with only one anonymous inner class and one try-finally block, both of which are common and necessary in JUnit rule implementations. Intent is clear through descriptive method names like 'before' and 'after' and concise Javadoc comments. The code length is appropriate, avoiding unnecessary verbosity while providing a complete example in the class-level Javadoc. Action granularity is excellent, with each statement on its own line and no hidden side-effects. Reading flow is natural: the public apply method leads directly to the private statement method, which contains the core execution logic. The only minor drawback is the slightly awkward 'statement(base)' return within apply, which could be simplified to return statement(base) directly.
Run 3
The code is well-structured with a clear separation of concerns: the apply method delegates to statement, which encapsulates the setup/teardown logic. Nesting is shallow, with only one anonymous inner class. Intent is explicit through meaningful method names (before, after, evaluate) and Javadoc examples. The code is concise, avoiding unnecessary boilerplate. Each logical action (before, try, evaluate, finally, after) is placed on its own line or block, improving readability. The reading flow is natural: apply -> statement -> evaluate, then before/after. Minor deductions: the Javadoc example contains a small formatting inconsistency and the @throws tag lacks a parameter description, but these do not significantly hinder comprehension.
Run 1
1. Code Structure: Well organized into rule application, statement wrapping, and lifecycle hooks; the private statement helper adds slight indirection. 2. Nesting: The anonymous class and try/finally introduce moderate but appropriate nesting. 3. Clarity of intent: Descriptive lifecycle names and documentation clearly communicate setup and teardown; the malformed @throws documentation slightly reduces clarity. 4. Code length: Implementation is concise, though the documentation example is relatively long and inconsistently formatted. 5. Action granularity: Each statement performs one clear action, with no crowded lines. 6. Reading flow: Execution reads naturally from before() through base.evaluate() to after(), and the finally block makes cleanup behavior easy to understand.
Run 2
Code Structure: Methods are logically organized, separating rule application, execution wrapping, setup, and teardown. Nesting: The anonymous Statement and try/finally introduce moderate but justified nesting. Clarity of intent: Descriptive lifecycle methods and documentation clearly communicate resource management, although the setup-failure Javadoc is malformed and the teardown guarantee could be qualified. Code length: The implementation is concise; the documentation example is useful but relatively lengthy, and the statement helper adds minor indirection. Action granularity: Each executable line performs a single clear action. Reading flow: Execution follows the natural before-test-after sequence, with finally making cleanup behavior easy to understand. Inconsistent formatting in the documentation example slightly reduces polish.
Run 3
Code Structure: Well-organized class with separate rule application, statement construction, and lifecycle hooks. Nesting: The anonymous class and try/finally introduce moderate but necessary nesting. Clarity of intent: Descriptive lifecycle names and documentation clearly explain resource setup and teardown; however, the setup-failure Javadoc is malformed, and teardown occurs only if before() succeeds. Code length: Concise implementation, though the statement() helper adds a small amount of indirection. Action granularity: Each statement performs one clear action. Reading flow: The implementation follows a natural setup-test-cleanup sequence, with hooks defined afterward. Inconsistent formatting in the documentation example slightly reduces polish.