Class CollectionTypeMismatchRule

All Implemented Interfaces:
AstVisitor, JavaVisitor, Rule, PropertySource

public class CollectionTypeMismatchRule extends AbstractJavaRulechainRule
Detects method calls on collections where the passed object cannot possibly be in the collection due to type mismatch. This helps catch potential programming errors where incompatible types are used with collection methods like contains(), remove(), indexOf(), etc. Examples of violations: - List<Integer> list; list.remove("string"); // String cannot be in Integer list - Map<String, Integer> map; map.get(42); // Integer key cannot be in String-keyed map
  • Constructor Details

    • CollectionTypeMismatchRule

      public CollectionTypeMismatchRule()
  • Method Details