Sample

int-f9da8df983a7-I13

Lower every eligible classic and enhanced for loop to a while loop

Matched original source

Lines54

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8330–1; higher is more readable
Dorn0.830–1; higher is more readable
Mi0.5650–1; higher is more readable
LLOC13Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol18.670–20; mean of three runs
BTTF0.780–1; higher is more readable

Views

Source code

package org.springframework.test.web.servlet.result; import org.hamcrest.Matcher; import org.springframework.test.web.servlet.ResultMatcher; import org.springframework.web.servlet.ModelAndView; import static org.hamcrest.MatcherAssert.assertThat; import static org.springframework.test.util.AssertionErrors.assertEquals; import static org.springframework.test.util.AssertionErrors.fail; /** * Factory for assertions on the selected view. * * <p>An instance of this class is typically accessed via * {@link MockMvcResultMatchers#view}. * * @author Rossen Stoyanchev * @since 3.2 */ public class ViewResultMatchers { /** * Protected constructor. * Use {@link MockMvcResultMatchers#view()}. */ protected ViewResultMatchers() { } /** * Assert the selected view name with the given Hamcrest {@link Matcher}. */ public ResultMatcher name(Matcher<? super String> matcher) { return result -> { ModelAndView mav = result.getModelAndView(); if (mav == null) { fail("No ModelAndView found"); } assertThat("View name", mav.getViewName(), matcher); }; } /** * Assert the selected view name. */ public ResultMatcher name(String expectedViewName) { return result -> { ModelAndView mav = result.getModelAndView(); if (mav == null) { fail("No ModelAndView found"); } assertEquals("View name", expectedViewName, mav.getViewName()); }; } }

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.1111.713−36.687
Source linesThe number of non-empty source lines.54+21.6
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.984−7.476

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

Score0.833

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.55−0.911
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
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.964+0.532
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.72.6+0.367
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.53.813+0.342
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.079+0.177

Intercept 0.07 + feature contributions = 1.587 (log-odds).
Score = sigmoid(1.587) = 0.83.

Score0.565
Score13
Run 1

The code demonstrates excellent readability. Structure is logical with clear package, imports, and class organization. Nesting is minimal - only a single-level lambda with a null check. Intent is unambiguous through descriptive method names and Javadoc. Code length is concise, avoiding unnecessary boilerplate. Action granularity is appropriate - each assertion is on its own line. Reading flow is natural, following a predictable pattern. Minor deductions: protected constructor could be private, and the null check is slightly repetitive across methods, but these are negligible.

Run 2

The code is well-structured, with a clear class purpose and focused methods. Nesting is minimal, using simple null checks. Intent is explicit through descriptive method names and Javadoc. The code is concise, each lambda handles one responsibility, and action granularity is appropriate. Reading flow is natural, from null check to assertion. Minor deductions: the duplicated null check in both overloaded methods could be extracted, and static imports mixed with regular imports slightly reduce clarity. Overall, highly readable.

Run 3

The code is highly readable. It has a clear, logical structure with concise Javadoc explaining the purpose of the class and each method. There is minimal nesting — only a single conditional check inside each lambda. Intent is unambiguous, as method names and parameters clearly describe what is being asserted. Code length is appropriate, with no unnecessary repetition beyond the small duplicated null check. Each lambda contains one action per line: fetching the ModelAndView, failing if null, and performing the assertion. The reading flow is natural, moving from public API to implementation detail, and the use of static imports keeps assertions clean. Overall, this is production-quality, well-documented code that is easy to follow and maintain.

Run 1

Code Structure: The class is logically organized around two closely related assertion overloads, with a clearly documented constructor. Nesting: Each method has only a lambda and a simple null check, keeping nesting shallow. Clarity of intent: Descriptive method parameters, Javadoc, and assertion messages make the purpose clear; the abbreviation 'mav' is slightly less explicit than 'modelAndView'. Code length: The implementation is concise, though the repeated retrieval and null check introduce minor duplication. Action granularity: Each statement performs one action, with no compressed multi-statement lines. Reading flow: Both methods follow the same natural sequence—retrieve, validate, assert. Import grouping and excess blank lines could be polished, but readability is excellent overall.

Run 2

Code Structure: The class is logically organized, with a constructor followed by two related assertion overloads. Nesting: Lambdas contain only a single shallow conditional, keeping control flow easy to follow. Clarity of intent: Descriptive method parameters, assertion messages, and Javadoc clearly explain the purpose; the abbreviation 'mav' is slightly less explicit. Code length: The implementation is concise, though the ModelAndView retrieval and null check are duplicated. Action granularity: Each statement performs one clear action on its own line. Reading flow: Both methods follow the same natural retrieve-check-assert sequence. Minor formatting issues, including tightly grouped imports and extra blank lines, slightly reduce polish.

Run 3

Code Structure: A focused class with two logically organized overloads and useful documentation. Nesting: Shallow lambda bodies contain only a simple null-check conditional. Clarity of intent: Descriptive method signatures, assertion messages, and Javadoc clearly communicate view-name validation; the abbreviation 'mav' is slightly less explicit. Code length: Concise overall, although both overloads repeat the ModelAndView lookup and null check. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: Both methods follow the natural sequence of retrieving, validating, and asserting. Minor import spacing and extra blank lines slightly reduce formatting consistency.