未验证 提交 545c0089 编写于 作者: L lqzyc 提交者: GitHub

Merge pull request #613 from LQZYC/fix

同步改动
...@@ -39,7 +39,8 @@ import java.util.regex.Pattern; ...@@ -39,7 +39,8 @@ import java.util.regex.Pattern;
public class LowerCamelCaseVariableNamingRule extends AbstractAliRule { public class LowerCamelCaseVariableNamingRule extends AbstractAliRule {
private static final String MESSAGE_KEY_PREFIX = "java.naming.LowerCamelCaseVariableNamingRule.violation.msg"; private static final String MESSAGE_KEY_PREFIX = "java.naming.LowerCamelCaseVariableNamingRule.violation.msg";
private Pattern pattern = Pattern.compile("^[a-z][a-z0-9]*([A-Z][a-z0-9]+)*(DO|DTO|VO|DAO)?$");
private Pattern pattern = Pattern.compile("^[a-z][a-z0-9]*([A-Z][a-z0-9]+)*(DO|DTO|VO|DAO|BO|DOList|DTOList|VOList|DAOList|BOList|X|Y|Z|UDF|UDAF|[A-Z])?$");
@Override @Override
public Object visit(final ASTVariableDeclaratorId node, Object data) { public Object visit(final ASTVariableDeclaratorId node, Object data) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
private String abC; private String abC;
private String AbC; private String AbC;
private String abCd; private String abCd;
private String locationA;
private void f(){ private void f(){
String s = "test"; String s = "test";
} }
...@@ -15,8 +16,8 @@ ...@@ -15,8 +16,8 @@
</code-fragment> </code-fragment>
<test-code> <test-code>
<description>Variable name should be lowerCamelCase</description> <description>Variable name should be lowerCamelCase</description>
<expected-problems>2</expected-problems> <expected-problems>1</expected-problems>
<expected-linenumbers>2,3</expected-linenumbers> <expected-linenumbers>3</expected-linenumbers>
<code-ref id="LowerCamelCaseVariableNamingRuleTest" /> <code-ref id="LowerCamelCaseVariableNamingRuleTest" />
</test-code> </test-code>
...@@ -118,7 +119,7 @@ public interface BizConstants { ...@@ -118,7 +119,7 @@ public interface BizConstants {
public class MockTest{ public class MockTest{
@Mock @Mock
void $clinit(){} void $clinit(){}
} }
]]> ]]>
</code-fragment> </code-fragment>
<test-code> <test-code>
...@@ -172,6 +173,90 @@ public interface BizConstants { ...@@ -172,6 +173,90 @@ public interface BizConstants {
<expected-problems>0</expected-problems> <expected-problems>0</expected-problems>
<code-ref id="LowerCamelCaseVariableNamingRuleTest9" /> <code-ref id="LowerCamelCaseVariableNamingRuleTest9" />
</test-code> </test-code>
<code-fragment id="LowerCamelCaseVariableNamingRuleTest10">
<![CDATA[
public class Example {
public void test(){
String myNAME = "zhangsan";
}
}
]]>
</code-fragment>
<test-code>
<description>Variable name should be lowerCamelCase10</description>
<expected-problems>1</expected-problems>
<expected-linenumbers>3</expected-linenumbers>
<code-ref id="LowerCamelCaseVariableNamingRuleTest10" />
</test-code>
<code-fragment id="LowerCamelCaseVariableNamingRuleTest11">
<![CDATA[
public class Example {
public void test(){
String myDOList = "DOList";
String myDTOList = "DTOList";
String myVOList = "VOList";
String myDAOList = "DAOList";
String myBOList = "BOList";
}
public void getScrollX(){}
public void getScrollY(){}
public void getScrollZ(){}
}
]]>
</code-fragment>
<test-code>
<description>Variable name should be lowerCamelCase11</description>
<expected-problems>0</expected-problems>
<code-ref id="LowerCamelCaseVariableNamingRuleTest11" />
</test-code>
<code-fragment id="LowerCamelCaseVariableNamingRuleTest12">
<![CDATA[
public class Example {
public void test(){
String myBO = "myBO";
}
}
]]>
</code-fragment>
<test-code>
<description>Variable name should be lowerCamelCase12</description>
<expected-problems>0</expected-problems>
<code-ref id="LowerCamelCaseVariableNamingRuleTest12" />
</test-code>
<code-fragment id="LowerCamelCaseVariableNamingRuleTest13">
<![CDATA[
public class Example {
public void test(){
String myUDF = "myUDF";
}
}
]]>
</code-fragment>
<test-code>
<description>Variable name should be lowerCamelCase13</description>
<expected-problems>0</expected-problems>
<code-ref id="LowerCamelCaseVariableNamingRuleTest13" />
</test-code>
<code-fragment id="LowerCamelCaseVariableNamingRuleTest14">
<![CDATA[
public class Example {
public void test(){
String myUDAF = "myUDAF";
}
}
]]>
</code-fragment>
<test-code>
<description>Variable name should be lowerCamelCase14</description>
<expected-problems>0</expected-problems>
<code-ref id="LowerCamelCaseVariableNamingRuleTest14" />
</test-code>
</test-data> </test-data>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册