1 /*xml 2 <module name="Checker"> 3 <module name="TreeWalker"> 4 <module name="MatchXpath"> 5 <property name="query" 6 value="//VARIABLE_DEF[./ASSIGN/EXPR/LITERAL_NEW 7 and not(./TYPE/IDENT[@text='var'])]"/> 8 <message key="matchxpath.match" 9 value="New instances should be created via 'var' keyword 10 to avoid duplication of type reference in statement"/> 11 </module> 12 </module> 13 </module> 14 */ 15 package com.puppycrawl.tools.checkstyle.checks.coding.matchxpath; 16 17 // xdoc section -- start 18 public class Example4 { 19 public void foo() { 20 Object a = new Object(); // violation 21 var b = new Object(); 22 } 23 } 24 // xdoc section -- end