View Javadoc
1   /*
2   MatchXpath
3   query = //LITERAL_CATCH//METHOD_CALL[.//IDENT[@text = 'printStackTrace']]/..
4   message.matchxpath.match = printStackTrace() method calls are forbidden
5   
6   
7   */
8   
9   package com.puppycrawl.tools.checkstyle.checks.coding.matchxpath;
10  
11  import java.io.IOException;
12  
13  public class InputMatchXpathForbidPrintStackTrace {
14     public void test() {
15        try {
16           throw new IOException();
17        } catch (IOException e) {
18           e.printStackTrace(); // violation
19        }
20     }
21  
22     public void test2() {
23        try {
24           throw new IOException();
25        } catch (IOException e) {
26        }
27     }
28  }