The following issues were found

src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilterTest.java
25 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 17

              
public class PropertyFilterTest extends TestCase {

    public void test_0() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return false;
            }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 27

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        serializer.write(a);

        String text = out.toString();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 36

                      Assert.assertEquals("{}", text);
    }
    
    public void test_toJSONString() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return false;
            }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 47

                      Assert.assertEquals("{}", JSON.toJSONString(new A(), filter));
    }

    public void test_1() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("id".equals(name)) {
                    return true;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 60

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        serializer.write(a);

        String text = out.toString();

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 69

                      Assert.assertEquals("{\"id\":0}", text);
    }

    public void test_2() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;

            

Reported by PMD.

The String literal 'name' appears 5 times in this file; the first occurrence is on line 73
Error

Line: 73

                      PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;
                }
                return false;
            }
        };

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 82

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        a.setName("chennp2008");
        serializer.write(a);


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 92

                      Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
    }

    public void test_3() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 105

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "chennp2008");
        serializer.write(map);


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/JSONReaderScanner.java
24 issues
Avoid reassigning parameters such as 'index'
Design

Line: 89

                      this(new CharArrayReader(input, 0, inputLength), features);
    }

    public final char charAt(int index) {
        if (index >= bufLength) {
            if (bufLength == -1) {
                if (index < sp) {
                    return buf[index];
                }

            

Reported by PMD.

The class 'JSONReaderScanner' has a Modified Cyclomatic Complexity of 3 (Highest = 10).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONReaderScanner extends JSONLexerBase {

    private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;

            

Reported by PMD.

This class has too many methods, consider refactoring it.
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONReaderScanner extends JSONLexerBase {

    private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;

            

Reported by PMD.

The class 'JSONReaderScanner' has a total cyclomatic complexity of 85 (highest 13).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONReaderScanner extends JSONLexerBase {

    private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;

            

Reported by PMD.

The class 'JSONReaderScanner' has a Standard Cyclomatic Complexity of 3 (Highest = 10).
Design

Line: 34

              /**
 * @author wenshao[szujobs@hotmail.com]
 */
public final class JSONReaderScanner extends JSONLexerBase {

    private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 38

              
    private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;
    private int                              bufLength;

    public JSONReaderScanner(String input){
        this(input, JSON.DEFAULT_PARSER_FEATURE);

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

                  private final static ThreadLocal<char[]> BUF_LOCAL = new ThreadLocal<char[]>();

    private Reader                           reader;
    private char[]                           buf;
    private int                              bufLength;

    public JSONReaderScanner(String input){
        this(input, JSON.DEFAULT_PARSER_FEATURE);
    }

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 40

              
    private Reader                           reader;
    private char[]                           buf;
    private int                              bufLength;

    public JSONReaderScanner(String input){
        this(input, JSON.DEFAULT_PARSER_FEATURE);
    }


            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 80

                      bp = -1;

        next();
        if (ch == 65279) { // utf8 bom
            next();
        }
    }

    public JSONReaderScanner(char[] input, int inputLength, int features){

            

Reported by PMD.

The method 'charAt(int)' has a cyclomatic complexity of 13.
Design

Line: 89

                      this(new CharArrayReader(input, 0, inputLength), features);
    }

    public final char charAt(int index) {
        if (index >= bufLength) {
            if (bufLength == -1) {
                if (index < sp) {
                    return buf[index];
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/MultiFieldIntTest_writer2.java
24 issues
System.out.println is used
Design

Line: 38

                      writer.close();
        
        String text = out.toString();
        System.out.println(text);
        List<Model> results = JSON.parseObject(text, new TypeReference<List<Model>>() {});
        
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 17

              
public class MultiFieldIntTest_writer2 extends TestCase {
    
    public void test_for_big_writer() throws Exception {
        List<Model> list = new ArrayList<Model>();
        
        for (int i = 0; i < 1024 * 10; ++i) {
            Model model = new Model();
            model.i = 0;

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      List<Model> list = new ArrayList<Model>();
        
        for (int i = 0; i < 1024 * 10; ++i) {
            Model model = new Model();
            model.i = 0;
            model.j = 1;
            model.k = 2;
            model.v = 3;
            model.l = 4;

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 43

                      
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 43

                      
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 44

                      Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 44

                      Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                      for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 45

                      for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

                          Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/DigitTest.java
24 issues
System.out.println is used
Design

Line: 36

                          f_isDigitSwitch();
            f_isDigitProhibit();

            System.out.println();
            System.out.println();
        }
    }

    public void f_isDigitBitSet() throws Exception {

            

Reported by PMD.

System.out.println is used
Design

Line: 37

                          f_isDigitProhibit();

            System.out.println();
            System.out.println();
        }
    }

    public void f_isDigitBitSet() throws Exception {
        long startNano = System.nanoTime();

            

Reported by PMD.

System.out.println is used
Design

Line: 49

                          }
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("bitset \t: " + NumberFormat.getInstance().format(nano));
    }

    public void f_isDigitRange() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 60

                          }
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("range \t: " + NumberFormat.getInstance().format(nano));
    }

    public void f_isDigitArray() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 71

                          }
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("array \t: " + NumberFormat.getInstance().format(nano));
    }

    public void f_isDigitSwitch() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 82

                          }
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("swtich \t: " + NumberFormat.getInstance().format(nano));
    }

    public void f_isDigitProhibit() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 93

                          }
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("prohi \t: " + NumberFormat.getInstance().format(nano));
    }

    private static final boolean[] digitBits = new boolean[256];
    static {
        for (char ch = '0'; ch <= '9'; ++ch) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 25

              
public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();

            

Reported by PMD.

Private field 'text' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 25

              
public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 26

              public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();
            f_isDigitArray();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2500/Issue2579.java
24 issues
System.out.println is used
Design

Line: 48

              					Assert.assertEquals(i, ((MyPoint2) obj).getBatchNumber());
				}
			} catch (JSONException e) {
				System.out.println(jsonString);
				e.printStackTrace();
				Assert.assertTrue(false);
			}
		}
	}

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 23

              public class Issue2579 extends TestCase {

	// 场景:走ASM
	public void test_for_issue1() throws Exception {
		run_test("MyPoint1");
	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 23

              public class Issue2579 extends TestCase {

	// 场景:走ASM
	public void test_for_issue1() throws Exception {
		run_test("MyPoint1");
	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 28

              	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {
		run_test("MyPoint2");
	}

	// 场景:随机顺序组合JSON字符串测试2000次
	private void run_test(String className) {

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 28

              	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {
		run_test("MyPoint2");
	}

	// 场景:随机顺序组合JSON字符串测试2000次
	private void run_test(String className) {

            

Reported by PMD.

Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings
Performance

Line: 39

              		String jsonString;
		for (int i = 1; i < 2000; i++) {
			jsonString = getString(i, className);
			jsonString = begin + jsonString + end;
			try {
				Object obj = JSON.parse(jsonString, Feature.SupportAutoType);
				if ("MyPoint1".equals(className)) {
					Assert.assertEquals(i, ((MyPoint1) obj).getBatchNumber());
				} else {

            

Reported by PMD.

Avoid printStackTrace(); use a logger call instead.
Design

Line: 49

              				}
			} catch (JSONException e) {
				System.out.println(jsonString);
				e.printStackTrace();
				Assert.assertTrue(false);
			}
		}
	}


            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 77

              			len = list.size();
			index = getRandomIndex(len);
			buffer.append(list.get(index));
			buffer.append(",");
			list.remove(index);
		}
		buffer.deleteCharAt(buffer.length() - 1);
		return buffer.toString();
	}

            

Reported by PMD.

The class 'MyPoint1' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=12, WMC=12)
Design

Line: 90

              	}

	@SuppressWarnings("serial")
	public static class MyPoint1 extends Point {
		private UUID id;
		private int batchNumber;
		private Point point = new Point();
		private String[] strArr = { "te-st", "tes-t2" };
		private Date date = new Date();

            

Reported by PMD.

Returning 'strArr' may expose an internal array.
Design

Line: 123

              		}

		public String[] getStrArr() {
			return strArr;
		}

		public void setStrArr(String[] strArr) {
			this.strArr = strArr;
		}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/Base64Test2.java
24 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              
public class Base64Test2 extends TestCase {

    public void test_base64_2() throws Exception {
        String text = "";
        for (int i = 0; i < 1000; ++i) {
            byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);

            

Reported by PMD.

The String literal 'UTF-8' appears 11 times in this file; the first occurrence is on line 14
Error

Line: 14

                  public void test_base64_2() throws Exception {
        String text = "";
        for (int i = 0; i < 1000; ++i) {
            byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 16

                      for (int i = 0; i < 1000; ++i) {
            byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 17

                          byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 17

                          byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 17

                          byte[] bytes = text.getBytes("UTF-8");
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 18

                          {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 19

                              String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                              String str = com.alibaba.json.test.Base64.encodeToString(bytes, true);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 22

                              Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            {
                String str = com.alibaba.json.test.Base64.encodeToString(bytes, false);
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str.toCharArray(), 0, str.length()), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str), "UTF-8"));
                Assert.assertEquals(text, new String(IOUtils.decodeBase64(str, 0, str.length()), "UTF-8"));
            }
            text += ((char) i);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330 extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330 extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_byte.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_byte extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_byte extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2260.java
24 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              import java.util.Calendar;

public class Issue2260 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M1 m = JSON.parseObject(json, M1.class);
        assertEquals(1950, m.date.get(Calendar.YEAR));
    }


            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 14

                  public void test_for_issue() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M1 m = JSON.parseObject(json, M1.class);
        assertEquals(1950, m.date.get(Calendar.YEAR));
    }

    public void test_for_jdk8_zdt_1() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_for_issue() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M1 m = JSON.parseObject(json, M1.class);
        assertEquals(1950, m.date.get(Calendar.YEAR));
    }

    public void test_for_jdk8_zdt_1() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 17

                      assertEquals(1950, m.date.get(Calendar.YEAR));
    }

    public void test_for_jdk8_zdt_1() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                  public void test_for_jdk8_zdt_1() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_2() throws Exception {
        String json = "{\"date\":\"1950-07-14 12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 20

                  public void test_for_jdk8_zdt_1() throws Exception {
        String json = "{\"date\":\"1950-07-14\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_2() throws Exception {
        String json = "{\"date\":\"1950-07-14 12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 23

                      assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_2() throws Exception {
        String json = "{\"date\":\"1950-07-14 12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 26

                  public void test_for_jdk8_zdt_2() throws Exception {
        String json = "{\"date\":\"1950-07-14 12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_3() throws Exception {
        String json = "{\"date\":\"1950-07-14T12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                  public void test_for_jdk8_zdt_2() throws Exception {
        String json = "{\"date\":\"1950-07-14 12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_3() throws Exception {
        String json = "{\"date\":\"1950-07-14T12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 29

                      assertEquals(1950, m.date.getYear());
    }

    public void test_for_jdk8_zdt_3() throws Exception {
        String json = "{\"date\":\"1950-07-14T12:23:34\"}";
        M2 m = JSON.parseObject(json, M2.class);
        assertEquals(1950, m.date.getYear());
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_boolean.java
24 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_boolean extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_boolean extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 22

                      assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_2() throws Exception {
        Exception error = null;

            

Reported by PMD.