Appendix A. Kinds of annotations
Appendix A. Static analysis annotations
Appendix B. Extending static analysis tools
Appendix B. IntelliJ IDEA plugin
Appendix B. SpotBugs plugins
Appendix B. Using structural search and replacement in IntelliJ IDEA
Chapter 1. Automated testing
Chapter 1. Code assertions
Chapter 1. Code style
Chapter 1. Dynamic analysis
Chapter 1. Managing code quality
Chapter 1. Mutation coverage
Chapter 1. Static analysis
Chapter 1. Summary
Chapter 2. Expressions
Chapter 2. Mistake 2 Missing parentheses in conditions
Chapter 2. Mistake 3 Accidental concatenation instead of addition
Chapter 2. Mistake 4 Multiline string literals
Chapter 2. Mistake 5 Unary plus
Chapter 2. Mistake 6 Implicit type conversion in conditional expressions
Chapter 2. Mistake 7 Using non-short-circuit logic operators
Chapter 2. Mistake 8 Confusing && and
Chapter 2. Mistake 9 Incorrectly using variable arity calls
Chapter 2. Mistake 10 Conditional operators and variable arity calls
Chapter 2. Mistake 11 Ignoring an important return value
Chapter 2. Mistake 12 Not using a newly created object
Chapter 2. Mistake 13 Binding a method reference to the wrong method
Chapter 2. Mistake 14 Using the wrong method in a method reference
Chapter 2. Summary
Chapter 3. Mistake 16 A condition dominated by a previous condition
Chapter 3. Mistake 17 Accidental pass through in a switch statement
Chapter 3. Mistake 18 Malformed classic for loop
Chapter 3. Mistake 19 Not using the loop variable
Chapter 3. Mistake 20 Wrong loop direction
Chapter 3. Mistake 21 Loop overflow
Chapter 3. Mistake 22 Idempotent loop body
Chapter 3. Mistake 23 Incorrect initialization order
Chapter 3. Mistake 24 A missing superclass method call
Chapter 3. Mistake 25 Accidental static field declaration
Chapter 3. Program structure
Chapter 3. Summary
Chapter 4. Mistake 27 Numeric overflow
Chapter 4. Mistake 28 Rounding during integer division
Chapter 4. Mistake 29 Absolute value of Integer.MIN VALUE
Chapter 4. Mistake 30 Oddness check and negative numbers
Chapter 4. Mistake 31 Widening with precision loss
Chapter 4. Mistake 32 Unconditional narrowing
Chapter 4. Mistake 33 Negative hexadecimal values
Chapter 4. Mistake 34 Implicit type conversion in compound assignments
Chapter 4. Mistake 35 Division and compound assignment
Chapter 4. Mistake 36 Using the short type
Chapter 4. Mistake 37 Manually writing bit-manipulating algorithms
Chapter 4. Mistake 38 Forgetting about negative byte values
Chapter 4. Mistake 39 Incorrect clamping order
Chapter 4. Mistake 40 Misusing special floating-point numbers
Chapter 4. Numbers
Chapter 4. Summary
Chapter 5. Common exceptions
Chapter 5. Mistake 42 IndexOutOfBoundsException
Chapter 5. Mistake 43 ClassCastException
Chapter 5. Mistake 44 StackOverflowError
Chapter 5. Summary
Chapter 6. Mistake 46 Unexpected case conversions
Chapter 6. Mistake 47 Using String.format with the default locale
Chapter 6. Mistake 48 Mismatched format arguments
Chapter 6. Mistake 49 Using plain strings instead of regular expressions
Chapter 6. Mistake 50 Accidental use of replaceAll
Chapter 6. Mistake 51 Accidental use of escape sequences
Chapter 6. Mistake 52 Comparing strings in different case
Chapter 6. Mistake 53 Not checking the result of indexOf method
Chapter 6. Mistake 54 Mixing arguments of indexOf
Chapter 6. Strings
Chapter 6. Summary
Chapter 7. Comparing objects
Chapter 7. Mistake 56 Assuming equals() compares content
Chapter 7. Mistake 57 Using URL.equals()
Chapter 7. Mistake 58 Comparing BigDecimals with different scales
Chapter 7. Mistake 59 Using equals() on unrelated types
Chapter 7. Mistake 60 Malformed equals() implementation
Chapter 7. Mistake 61 Wrong hashCode() with array fields
Chapter 7. Mistake 62 Mismatch between equals() and hashCode()
Chapter 7. Mistake 63 Relying on a particular return value of compare()
Chapter 7. Mistake 64 Failing to return 0 when comparing equal objects
Chapter 7. Mistake 65 Using subtraction when comparing numbers
Chapter 7. Mistake 66 Ignoring possible NaN values in comparison methods
Chapter 7. Mistake 67 Failing to represent an object as a sequence of keys in a comparison method
Chapter 7. Mistake 68 Returning random numbers from the comparator
Chapter 7. Summary
Chapter 8. Collections and maps
Chapter 8. Mistake 70 Mixing up single object and collection
Chapter 8. Mistake 71 Searching for null in a null-hostile collection
Chapter 8. Mistake 72 Using null values in maps
Chapter 8. Mistake 73 Trying to modify an unmodifiable Collection
Chapter 8. Mistake 74 Using mutable objects as keys
Chapter 8. Mistake 75 Relying on HashMap and HashSet encounter order
Chapter 8. Mistake 76 Concurrent modification during the iteration
Chapter 8. Mistake 77 Mixing List.remove() overloads
Chapter 8. Mistake 78 Jumping over the next element after List.remove()
Chapter 8. Mistake 79 Reading the collection inside Collection.removeIf()
Chapter 8. Mistake 80 Concurrent modification in Map.computeIfAbsent()
Chapter 8. Mistake 81 Violating Iterator contracts
Chapter 8. Summary
Chapter 9. Library methods
Chapter 9. Mistake 83 Producing side effects in a Stream API chain
Chapter 9. Mistake 84 Consuming the stream twice
Chapter 9. Mistake 85 Using null values in a stream where it s not allowed
Chapter 9. Mistake 86 Violating the contract of Stream API operations
Chapter 9. Mistake 87 Using getClass() instead of instanceof
Chapter 9. Mistake 88 Using getClass() on enums, annotations, or classes
Chapter 9. Mistake 89 Incorrect conversion of string to boolean
Chapter 9. Mistake 90 Incorrect format specifiers in date formatting
Chapter 9. Mistake 91 Accidental invalidation of weak or soft references
Chapter 9. Mistake 92 Assuming the world is stable
Chapter 9. Mistake 93 Non-atomic access to concurrently updated data structures
Chapter 9. Summary
Chapter 10. Mistake 95 Malformed assertion method calls
Chapter 10. Mistake 96 Malformed exception test
Chapter 10. Mistake 97 Premature exit from test method
Chapter 10. Mistake 98 Ignoring the AssertionError in unit tests
Chapter 10. Mistake 99 Using assertNotEquals() to check the equality contract
Chapter 10. Mistake 100 Malformed test methods
Chapter 10. Summary
Chapter 10. Unit testing