1 /* 2 MethodName 3 format = (default)^[a-z][a-zA-Z0-9]*$ 4 allowClassName = true 5 applyToPublic = (default)true 6 applyToProtected = (default)true 7 applyToPackage = (default)true 8 applyToPrivate = false 9 10 11 */ 12 13 package com.puppycrawl.tools.checkstyle.checks.naming.methodname; 14 15 /** 16 * Test input for MethodNameCheck specifically 17 * whether the method name equals the class name. 18 * 19 * @author Travis Schneeberger 20 */ 21 public class InputMethodNameEqualClassName3 { 22 23 //illegal name 24 // violation below 'Name 'InputMethodNameEqualClassName3' must match pattern' 25 public int InputMethodNameEqualClassName3() { 26 return 0; 27 } 28 29 //illegal name 30 private int PRIVATEInputMethodNameEqualClassName() { 31 return 0; 32 } 33 34 class Inner { 35 //illegal name 36 public int Inner() { // violation 'Name 'Inner' must match pattern' 37 return 0; 38 } 39 40 // ok name - name of the outter class's ctor 41 // violation below 'Name 'InputMethodNameEqualClassName3' must match pattern' 42 public int InputMethodNameEqualClassName3() { 43 return 0; 44 } 45 } 46 47 public void anotherMethod() { 48 new InputMethodNameEqualClassName() { 49 50 //illegal name 51 // violation below 'Name 'InputMethodNameEqualClassName3' must match pattern' 52 public int InputMethodNameEqualClassName3() { 53 return 1; 54 } 55 }; 56 } 57 } 58 59 interface SweetInterface3 { 60 61 //illegal name 62 int SweetInterface(); // violation 'Name 'SweetInterface' must match pattern' 63 } 64 65 class Outer3 { 66 67 //illegal name 68 public void Outer() { // violation 'Name 'Outer' must match pattern' 69 70 } 71 }