<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
    <test-code>
        <description><![CDATA[
member level, final statics should be all caps
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 private static final String foo = "2";
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
member level, non-finals shouldn't have underscores
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 private int foo_bar = 2;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
local level, non-finals shouldn't have underscores
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void foo() {
    String foo_bar = "2";
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
method level, non-finals shouldn't have underscores
     ]]></description>
        <expected-problems>2</expected-problems>
        <code><![CDATA[
public class Foo {
 private void foo(boolean foo, String bar, String foo_bar, int bar_foo) {
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
constructor level, non-finals shouldn't have underscores
     ]]></description>
        <expected-problems>2</expected-problems>
        <code><![CDATA[
public class Foo {
 private Foo(boolean foo, String bar, String foo_bar, int bar_foo) {
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
member level, variables names should start with lowercase character
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 private int Ubar = 2;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
local level, variables names should start with lowercase character
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void foo() {
  int Ubar = 2;
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
method level, variables names should start with lowercase character
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void foo(int Ubar) {
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
constructor level, variables names should start with lowercase character
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public Foo(int Ubar) {
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
all is well
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 private int bar = 2;
 private static final int FOO_BAR = 2;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
local finals are ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 private void bar() {
  final int STATE_READING = 0;
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
serialVersionUID is OK
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
  static final long serialVersionUID = 423343L;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
interface fields are tested
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public interface Foo {
  int foo = 42;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
final non-statics need not be all caps
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
  final int foo = 42;
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
variables in inner classes should not trigger problems in parent declaration
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 private static final Bar BAR = new FooBar() { public foo(String arg) { } };
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Rule property control 
     ]]></description>
        <expected-problems>5</expected-problems>
        <code><![CDATA[
public class Foo {
  static int s_foo = 42;
  int m_foo = 42;
  private Foo(int p_foo) {
   int l_foo = 42;
  }
  private void foo(int p_foo) {
  }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Check prefixes
     ]]></description>
        <rule-property name="staticPrefix">s_</rule-property>
        <rule-property name="memberPrefix">m_</rule-property>
        <rule-property name="localPrefix">l_</rule-property>
        <rule-property name="parameterPrefix">p_</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
  static int s_foo = 42;
  int m_foo = 42;
  private Foo(int p_foo) {
   int l_foo = 42;
  }
  private void foo(int p_foo) {
  }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Check suffixes
     ]]></description>
        <rule-property name="staticSuffix">_s</rule-property>
        <rule-property name="memberSuffix">_m</rule-property>
        <rule-property name="localSuffix">_l</rule-property>
        <rule-property name="parameterSuffix">_p</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
  static int foo_s = 42;
  int foo_m = 42;
  private Foo(int foo_p) {
   int foo_l = 42;
  }
  private void foo(int foo_p) {
  }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Check members disabled
     ]]></description>
        <rule-property name="checkMembers">false</rule-property>
        <expected-problems>3</expected-problems>
        <code><![CDATA[
public class Foo {
  static int foo_s = 42;
  int foo_m = 42;
  private Foo(int foo_p) {
   int foo_l = 42;
  }
  private void foo(int foo_p) {
  }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Check locals disabled
     ]]></description>
        <rule-property name="checkLocals">false</rule-property>
        <expected-problems>4</expected-problems>
        <code><![CDATA[
public class Foo {
  static int foo_s = 42;
  int foo_m = 42;
  private Foo(int foo_p) {
   int foo_l = 42;
  }
  private void foo(int foo_p) {
  }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
Check parameters disabled
     ]]></description>
        <rule-property name="checkParameters">false</rule-property>
        <expected-problems>3</expected-problems>
        <code><![CDATA[
public class Foo {
  static int foo_s = 42;
  int foo_m = 42;
  private Foo(int foo_p) {
   int foo_l = 42;
  }
  private void foo(int foo_p) {
  }
}
     ]]></code>
    </test-code>
       <test-code>
    	<description><![CDATA[
False - with non primitive fields (Bug 2225474)	
	]]></description>
	<expected-problems>1</expected-problems>
	<code><![CDATA[
public class X {
	public final static String foo = "3";
}
	]]></code>
    </test-code>
    <test-code>
        <description>#1058 False positive for VariableNamingConventions</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Test {
    private static final RemoteRepository REMOTE = new RemoteRepository<>();
}
        ]]></code>
        <source-type>java 1.7</source-type>
    </test-code>
    <test-code>
        <description>#1293 Disable VariableNamingConventions for native methods</description>
        <rule-property name="checkNativeMethodParameters">false</rule-property>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class X {
    private native void stream_dip_set_data(long stream, long dip_x,
        long dip_z);
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1293 Disable VariableNamingConventions for native methods - prevent false negative</description>
        <rule-property name="checkNativeMethodParameters">true</rule-property>
        <expected-problems>2</expected-problems>
        <expected-linenumbers>2,3</expected-linenumbers>
        <code><![CDATA[
public class X {
    private native void stream_dip_set_data(long stream, long dip_x,
        long dip_z);
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1346 VariableNamingConventions do not work for method parameters</description>
        <rule-property name="checkParameters">true</rule-property>
        <rule-property name="checkNativeMethodParameters">false</rule-property>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>3</expected-linenumbers>
        <code><![CDATA[
public class X {
    private long horsTout;
    public void setHorsTout(long hors_tout) {
        this.horsTout = hors_tout;
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1349 VariableNamingConventions : underscore in final but at first position ?</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class X {
    private final String _projection;
    private final String _projectionID;
}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1399 False positive for VariableNamingConventions with annotation @interface</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public @interface Relation {
    int NO_REVERSE_RELATION = -1;
}
        ]]></code>
    </test-code>
</test-data>
