Sample

Schnappinger/junit4/junit.framework.Assert

Human rating uses the original dataset scale.

Human3.96
Lines339

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
28.8Δ 48.3
Scalabrino0.8520–1; higher is more readable
75.3Δ 1.7
Dorn0.0280–1; higher is more readable
25.1Δ 52.0
Mi0.8320–1; higher is more readable
98.3Δ 21.3
LLOC104Logical lines; fewer is more readable
23.6Δ 53.5
DeepSeek V4 Pro17.330–20; mean of three runs
73.9Δ 3.1
GPT-6.1 Sol180–20; mean of three runs
73.8Δ 3.3
BTTF0.530–1; higher is more readable
46.5Δ 30.5
Human3.961–4; original rating
77.1

Views

Source code

package junit.framework; /** * A set of assert methods. Messages are only displayed when an assert fails. * * @deprecated Please use {@link org.junit.Assert} instead. */ @Deprecated public class Assert { /** * Protect constructor since it is a static only class */ protected Assert() { } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError with the given message. */ static public void assertTrue(String message, boolean condition) { if (!condition) { fail(message); } } /** * Asserts that a condition is true. If it isn't it throws * an AssertionFailedError. */ static public void assertTrue(boolean condition) { assertTrue(null, condition); } /** * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError with the given message. */ static public void assertFalse(String message, boolean condition) { assertTrue(message, !condition); } /** * Asserts that a condition is false. If it isn't it throws * an AssertionFailedError. */ static public void assertFalse(boolean condition) { assertFalse(null, condition); } /** * Fails a test with the given message. */ static public void fail(String message) { if (message == null) { throw new AssertionFailedError(); } throw new AssertionFailedError(message); } /** * Fails a test with no message. */ static public void fail() { fail(null); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, Object expected, Object actual) { if (expected == null && actual == null) { return; } if (expected != null && expected.equals(actual)) { return; } failNotEquals(message, expected, actual); } /** * Asserts that two objects are equal. If they are not * an AssertionFailedError is thrown. */ static public void assertEquals(Object expected, Object actual) { assertEquals(null, expected, actual); } /** * Asserts that two Strings are equal. */ static public void assertEquals(String message, String expected, String actual) { if (expected == null && actual == null) { return; } if (expected != null && expected.equals(actual)) { return; } String cleanMessage = message == null ? "" : message; throw new ComparisonFailure(cleanMessage, expected, actual); } /** * Asserts that two Strings are equal. */ static public void assertEquals(String expected, String actual) { assertEquals(null, expected, actual); } /** * Asserts that two doubles are equal concerning a delta. If they are not * an AssertionFailedError is thrown with the given message. If the expected * value is infinity then the delta value is ignored. */ static public void assertEquals(String message, double expected, double actual, double delta) { if (Double.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { failNotEquals(message, new Double(expected), new Double(actual)); } } /** * Asserts that two doubles are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ static public void assertEquals(double expected, double actual, double delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two floats are equal concerning a positive delta. If they * are not an AssertionFailedError is thrown with the given message. If the * expected value is infinity then the delta value is ignored. */ static public void assertEquals(String message, float expected, float actual, float delta) { if (Float.compare(expected, actual) == 0) { return; } if (!(Math.abs(expected - actual) <= delta)) { failNotEquals(message, new Float(expected), new Float(actual)); } } /** * Asserts that two floats are equal concerning a delta. If the expected * value is infinity then the delta value is ignored. */ static public void assertEquals(float expected, float actual, float delta) { assertEquals(null, expected, actual, delta); } /** * Asserts that two longs are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, long expected, long actual) { assertEquals(message, Long.valueOf(expected), Long.valueOf(actual)); } /** * Asserts that two longs are equal. */ static public void assertEquals(long expected, long actual) { assertEquals(null, expected, actual); } /** * Asserts that two booleans are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, boolean expected, boolean actual) { assertEquals(message, Boolean.valueOf(expected), Boolean.valueOf(actual)); } /** * Asserts that two booleans are equal. */ static public void assertEquals(boolean expected, boolean actual) { assertEquals(null, expected, actual); } /** * Asserts that two bytes are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, byte expected, byte actual) { assertEquals(message, Byte.valueOf(expected), Byte.valueOf(actual)); } /** * Asserts that two bytes are equal. */ static public void assertEquals(byte expected, byte actual) { assertEquals(null, expected, actual); } /** * Asserts that two chars are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, char expected, char actual) { assertEquals(message, Character.valueOf(expected), Character.valueOf(actual)); } /** * Asserts that two chars are equal. */ static public void assertEquals(char expected, char actual) { assertEquals(null, expected, actual); } /** * Asserts that two shorts are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, short expected, short actual) { assertEquals(message, Short.valueOf(expected), Short.valueOf(actual)); } /** * Asserts that two shorts are equal. */ static public void assertEquals(short expected, short actual) { assertEquals(null, expected, actual); } /** * Asserts that two ints are equal. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertEquals(String message, int expected, int actual) { assertEquals(message, Integer.valueOf(expected), Integer.valueOf(actual)); } /** * Asserts that two ints are equal. */ static public void assertEquals(int expected, int actual) { assertEquals(null, expected, actual); } /** * Asserts that an object isn't null. */ static public void assertNotNull(Object object) { assertNotNull(null, object); } /** * Asserts that an object isn't null. If it is * an AssertionFailedError is thrown with the given message. */ static public void assertNotNull(String message, Object object) { assertTrue(message, object != null); } /** * Asserts that an object is null. If it isn't an {@link AssertionError} is * thrown. * Message contains: Expected: <null> but was: object * * @param object Object to check or <code>null</code> */ static public void assertNull(Object object) { if (object != null) { assertNull("Expected: <null> but was: " + object.toString(), object); } } /** * Asserts that an object is null. If it is not * an AssertionFailedError is thrown with the given message. */ static public void assertNull(String message, Object object) { assertTrue(message, object == null); } /** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ static public void assertSame(String message, Object expected, Object actual) { if (expected == actual) { return; } failNotSame(message, expected, actual); } /** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ static public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); } /** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown with the * given message. */ static public void assertNotSame(String message, Object expected, Object actual) { if (expected == actual) { failSame(message); } } /** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ static public void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); } static public void failSame(String message) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected not same"); } static public void failNotSame(String message, Object expected, Object actual) { String formatted = (message != null) ? message + " " : ""; fail(formatted + "expected same:<" + expected + "> was not:<" + actual + ">"); } static public void failNotEquals(String message, Object expected, Object actual) { fail(format(message, expected, actual)); } public static String format(String message, Object expected, Object actual) { String formatted = ""; if (message != null && message.length() > 0) { formatted = message + " "; } return formatted + "expected:<" + expected + "> but was:<" + actual + ">"; } }

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.7855.142−259.22
Source linesThe number of non-empty source lines.339+135.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.449−6.674

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

Score0.852

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.340−11.002
Indentation frequencyHow rapidly indentation changes from line to line.235+7.391
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.236−4.995
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.338.93+4.328
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.98.976+0.792
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.98.976−0.527
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.058+0.378

Intercept 0.07 + feature contributions = -3.565 (log-odds).
Score = sigmoid(-3.565) = 0.028.

Score0.832
Score104
Run 1

The code is highly readable. It follows a clear, consistent structure with each assertion method having overloads for message/no-message variants. Nesting is minimal, with early returns/throws avoiding deep indentation. Method names and Javadoc comments make intent explicit. The code is concise, with straightforward delegation between overloads. Each line generally performs one action, and control flow reads naturally. Minor deductions: slight duplication across primitive type overloads and occasional verbose parameter lists, but these are typical for assertion utility classes and do not meaningfully hinder clarity.

Run 2

The code is highly readable. It is a utility class of assertion methods with a clear, logical structure: a protected constructor, then a sequence of overloaded assertion methods (assertTrue, assertFalse, fail, assertEquals for various types, assertNull, assertNotNull, assertSame, assertNotSame) and helper methods at the end. Nesting is minimal, with early returns reducing indentation. Each method has a single, obvious purpose and is concise; most methods are 1-5 lines. Action granularity is one action per line, making the flow natural. The use of method overloading and delegation (e.g., assertTrue(boolean) calls assertTrue(String, boolean)) keeps the code DRY and easy to follow. Javadoc comments are present and clear, explaining each method's behavior. The only minor drawbacks are the repetitive nature of many overloaded methods (which is inherent to the API) and a slight inconsistency in method ordering (assertNotNull appears before assertNull), but overall the code is exceptionally clear and well-organized.

Run 3

The code is a clear, well-structured legacy JUnit Assert class with consistent formatting and straightforward logic. Organization is logical, grouping related overloaded methods together, and nesting is minimal (usually one level). Intent is clearly documented with Javadoc on every method. Code length is moderate, with some repetitive overloads, but this is typical for assertion APIs. Action granularity is good: each method performs one clear assertion or delegates to another. Reading flow is natural, with method names and parameters following standard conventions. Minor readability drawbacks include repetitive boilerplate across primitive types, slightly overloaded method signatures (e.g., two String-parameter assertEquals overloads), and the deprecated legacy style. Overall, it is easy to read and understand, even for someone unfamiliar with the codebase, but the redundancy prevents a higher score.

Run 1

Code Structure: Assertion methods are logically grouped, related overloads are adjacent, and shared failure helpers reduce duplication. Nesting: Shallow conditionals and early returns keep control flow flat. Clarity of intent: Descriptive method names, consistent parameters, and documentation clearly communicate purpose; negated floating-point comparisons require slightly more attention. Code length: Individual methods are concise, but numerous overloads and repetitive documentation make the class lengthy, largely justified by its API. Action granularity: Each statement generally performs one clear action, with straightforward delegation and no crowded multi-statement lines. Reading flow: Consistent formatting and predictable overload patterns make navigation natural. Minor distractions include inconsistent modifier ordering, reversed overload ordering in some groups, and repeated message-formatting logic.

Run 2

Code Structure: Assertion methods are logically grouped, overloads are adjacent, and shared failure helpers reduce duplication. Nesting: Control flow is shallow, with simple conditionals and early returns. Clarity of intent: Descriptive method and parameter names, supported by Javadoc, make the purpose clear; negated floating-point comparisons require slightly more thought. Code length: Individual methods are concise, but numerous overloads and repetitive documentation make the class lengthy. Action granularity: Lines generally contain a single statement or clear operation, without compressed multi-action code. Reading flow: Consistent formatting and predictable delegation make navigation natural, though inconsistent modifier ordering and occasional differences in overload ordering slightly weaken consistency.

Run 3

Code Structure: Related assertions and their overloads are grouped logically, with shared failure helpers reducing duplication. Nesting: Methods remain flat, using simple conditionals and early returns rather than deep nesting. Clarity of intent: Descriptive method and parameter names, supported by Javadoc, make behavior clear; negated floating-point comparisons require slightly more attention. Code length: Individual methods are concise, although numerous overloads and repetitive documentation make the class lengthy. Action granularity: Statements generally perform one clear action per line, with delegating overloads easy to understand. Reading flow: Consistent formatting and predictable overload patterns support natural scanning, though inconsistent modifier ordering and the reversed overload order in some null checks slightly weaken consistency.