Sample

int-150ab3369af7-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines115

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.8190–1; higher is more readable
Dorn0.7440–1; higher is more readable
Mi0.1950–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.630–1; higher is more readable

Views

Source code

package org.springframework.orm; import org.jspecify.annotations.Nullable; import org.springframework.dao.DataRetrievalFailureException; /** * Exception thrown if a mapped object could not be retrieved via its identifier. * Provides information about the persistent class and the identifier. * * @author Juergen Hoeller * @since 13.10.2003 */ @SuppressWarnings("serial") public class ObjectRetrievalFailureException extends DataRetrievalFailureException { private final @Nullable Object persistentClass; private final @Nullable Object identifier; /** * Create a general ObjectRetrievalFailureException with the given message, * without any information on the affected object. * @param msg the detail message * @param cause the source exception */ public ObjectRetrievalFailureException(@Nullable String msg, Throwable cause) { super(msg, cause); this.persistentClass = null; this.identifier = null; } /** * Create a new ObjectRetrievalFailureException for the given object, * with the default "not found" message. * @param persistentClass the persistent class * @param identifier the ID of the object that should have been retrieved */ public ObjectRetrievalFailureException(Class<?> persistentClass, Object identifier) { this(persistentClass, identifier, "Object of class [" + persistentClass.getName() + "] with identifier [" + identifier + "]: not found", null); } /** * Create a new ObjectRetrievalFailureException for the given object, * with the given explicit message and exception. * @param persistentClass the persistent class * @param identifier the ID of the object that should have been retrieved * @param msg the detail message * @param cause the source exception */ public ObjectRetrievalFailureException( Class<?> persistentClass, @Nullable Object identifier, String msg, @Nullable Throwable cause) { super(msg, cause); this.persistentClass = persistentClass; this.identifier = identifier; } /** * Create a new ObjectRetrievalFailureException for the given object, * with the default "not found" message. * @param persistentClassName the name of the persistent class * @param identifier the ID of the object that should have been retrieved */ public ObjectRetrievalFailureException(String persistentClassName, Object identifier) { this(persistentClassName, identifier, "Object of class [" + persistentClassName + "] with identifier [" + identifier + "]: not found", null); } /** * Create a new ObjectRetrievalFailureException for the given object, * with the given explicit message and exception. * @param persistentClassName the name of the persistent class * @param identifier the ID of the object that should have been retrieved * @param msg the detail message * @param cause the source exception */ public ObjectRetrievalFailureException( String persistentClassName, @Nullable Object identifier, @Nullable String msg, @Nullable Throwable cause) { super(msg, cause); this.persistentClass = persistentClassName; this.identifier = identifier; } /** * Return the persistent class of the object that was not found. * If no Class was specified, this method returns null. */ public @Nullable Class<?> getPersistentClass() { return (this.persistentClass instanceof Class<?> clazz ? clazz : null); } /** * Return the name of the persistent class of the object that was not found. * Will work for both Class objects and String names. */ public @Nullable String getPersistentClassName() { if (!((this.persistentClass instanceof Class<?> clazz))) {} else { return clazz.getName(); } return (this.persistentClass != null ? this.persistentClass.toString() : null); } /** * Return the identifier of the object that was not found. */ public @Nullable Object getIdentifier() { return this.identifier; } }

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.1892.128−62.44
Source linesThe number of non-empty source lines.115+46
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.839−7.258

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

Score0.819

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.109−2.823
Indentation frequencyHow rapidly indentation changes from line to line.72+1.753
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.114.568+1.192
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.109.948−0.992
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.109.966+0.97
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.499
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 1.066 (log-odds).
Score = sigmoid(1.066) = 0.744.

Score0.195
Score21
Run 1

The code has clear Javadoc documentation and logical class structure, which aids understanding. However, several issues reduce readability. The constructors are repetitive; the message-building logic is duplicated instead of being centralized. The method `getPersistentClassName()` contains an awkward empty if-block with an else statement, which is confusing and poorly structured. It could be simplified to a single conditional expression. Field declarations use line breaks unnecessarily, increasing length without adding clarity. While the code is generally flat and not deeply nested, the inconsistent formatting and redundant logic interrupt the reading flow. Overall, the intent is clear but the implementation could be more concise and straightforward.

Run 2

The code is well-structured with clear class documentation and organized constructors. It maintains flat nesting and follows Spring conventions. However, there are readability issues: the empty if block in getPersistentClassName() with inverted logic (`if (!(...)) {} else { return ...; }`) is unnecessarily convoluted and breaks the natural reading flow. The repeated pattern of 'Object of class [...] with identifier [...]: not found' across constructors adds minor duplication. Some constructor signatures span multiple lines, slightly affecting scanability. Overall, the intent is clear and methods are concise, but the awkward conditional and minor repetition prevent a higher score.

Run 3

The code is highly readable with clear structure and intent. It follows a standard pattern for exception classes—well-organized constructors, consistent field declarations, and meaningful Javadoc. Nesting is minimal; the only method with conditional logic (getPersistentClassName) uses a slightly awkward empty-if/else construct that reduces clarity. Code length is appropriate for the number of constructors, though some duplication exists in the two 'default message' paths. Action granularity is good—each assignment or return is on its own line. Reading flow is natural: fields, constructors, then accessors. Minor deduction for the odd empty if block and minor constructor duplication, but overall the code is clean, maintainable, and easy to understand.

Run 1

Code Structure: Clearly organized into fields, constructors, and accessors, with related overloads grouped together. Nesting: Almost entirely flat, though getPersistentClassName introduces an unnecessary empty conditional branch. Clarity of intent: Descriptive names, Javadoc, and nullability annotations explain the exception's purpose well; storing either a Class or String in an Object field slightly obscures its representation. Code length: Reasonable for the supported overloads, but repetitive documentation and duplicated message construction add verbosity. Action granularity: Each assignment and return performs a single clear action; multiline constructor calls remain easy to follow. Reading flow: Generally natural and consistent, but the negated instanceof check, excessive parentheses, and empty if followed by else interrupt comprehension. A direct positive instanceof check would improve readability.

Run 2

1. Code Structure: Fields, constructors, and accessors are logically grouped, with helpful documentation. 2. Nesting: Almost entirely flat, although getPersistentClassName uses an awkward negated condition with an empty branch and an else. 3. Clarity of intent: Descriptive names and Javadocs clearly explain the exception's purpose; storing either a Class or String in an Object field slightly obscures its representation. 4. Code length: Reasonably concise, but repeated constructor documentation and message construction add verbosity. 5. Action granularity: Statements generally perform one action per line; constructor delegation and ternary returns remain understandable. 6. Reading flow: Consistent formatting and constructor delegation support natural reading, but the empty conditional branch, redundant parentheses, and long message expressions interrupt it. Replacing the negated empty branch with a straightforward positive instanceof check would noticeably improve readability.

Run 3

Code Structure: Fields, constructors, and getters are logically grouped, with consistent documentation. Nesting: Mostly flat, with only a shallow conditional. Clarity of intent: Descriptive names and Javadoc clearly explain the exception's purpose, though storing either a Class or String in an Object field weakens explicitness. Code length: Reasonably concise, but repeated constructor documentation and message construction add some redundancy. Action granularity: Statements generally perform one action per line; the empty if block and adjoining else are an awkward exception. Reading flow: Constructor delegation and straightforward getters read naturally, but getPersistentClassName disrupts the flow with a negated instanceof check, redundant parentheses, and an empty branch. A direct positive instanceof conditional would be substantially clearer.