The following issues were found

src/test/java/com/alibaba/json/test/jackson/JacksonInnerClassTest.java
5 issues
JUnit tests should include assert() or fail()
Design

Line: 11

              
public class JacksonInnerClassTest extends TestCase {

    public void test_0() throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);

        mapper.readValue("{a:3}", Map.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: 11

              
public class JacksonInnerClassTest extends TestCase {

    public void test_0() throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);

        mapper.readValue("{a:3}", Map.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: 18

                      mapper.readValue("{a:3}", Map.class);
    }
    
    public void test_1() throws Exception {
        Model model = new Model();
        model.id = 1001;
        ObjectMapper mapper = new ObjectMapper();
        String text = mapper.writeValueAsString(model);


            

Reported by PMD.

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

Line: 18

                      mapper.readValue("{a:3}", Map.class);
    }
    
    public void test_1() throws Exception {
        Model model = new Model();
        model.id = 1001;
        ObjectMapper mapper = new ObjectMapper();
        String text = mapper.writeValueAsString(model);


            

Reported by PMD.

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

Line: 32

                      public Model() {

        }
        public int id;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/test/DetectProhibitChar.java
5 issues
Overridable method 'addProhibitChar' called during object construction
Error

Line: 46

                  }

    public DetectProhibitChar(char prohibits[]){
        addProhibitChar(prohibits);
    }

    /**
     * 增加一个跳越字符
     * 

            

Reported by PMD.

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

Line: 39

               */
public class DetectProhibitChar {

    byte[] masks = new byte[1024 * 8];

    public DetectProhibitChar(){

    }


            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 45

              
    }

    public DetectProhibitChar(char prohibits[]){
        addProhibitChar(prohibits);
    }

    /**
     * 增加一个跳越字符

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 73

                      }
    }

    public void addProhibitChar(char prohibits[]) {
        if (prohibits != null) {
            for (char c : prohibits) {
                addProhibitChar(c);
            }
        }

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 92

                      return (i != 0);
    }

    public boolean hasProhibitChar(char cs[]) {
        if (cs != null) {
            for (char c : cs) {
                if (isProhibitChar(c)) {
                    return true;
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/DateTest.java
5 issues
System.out.println is used
Design

Line: 27

                      long time = System.currentTimeMillis();
        for (Codec codec : decoders) {
            String text = codec.encode(new java.sql.Date(time));
            System.out.println(codec.getName() + " : " + text);
            // codec.decodeObject(text, java.sql.Date.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: 16

              
public class DateTest extends TestCase {

    public void test_0() throws Exception {
        List<Codec> decoders = new ArrayList<Codec>();
        decoders.add(new FastjsonCodec());
        decoders.add(new JacksonCodec());
        decoders.add(new SimpleJsonCodec());
        // decoders.add(new JsonLibDecoderImpl());

            

Reported by PMD.

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

Line: 16

              
public class DateTest extends TestCase {

    public void test_0() throws Exception {
        List<Codec> decoders = new ArrayList<Codec>();
        decoders.add(new FastjsonCodec());
        decoders.add(new JacksonCodec());
        decoders.add(new SimpleJsonCodec());
        // decoders.add(new JsonLibDecoderImpl());

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 26

              
        long time = System.currentTimeMillis();
        for (Codec codec : decoders) {
            String text = codec.encode(new java.sql.Date(time));
            System.out.println(codec.getName() + " : " + text);
            // codec.decodeObject(text, java.sql.Date.class);
        }
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'time' (lines '24'-'30').
Error

Line: 24

                      // decoders.add(new JsonLibDecoderImpl());
        decoders.add(new GsonCodec());

        long time = System.currentTimeMillis();
        for (Codec codec : decoders) {
            String text = codec.encode(new java.sql.Date(time));
            System.out.println(codec.getName() + " : " + text);
            // codec.decodeObject(text, java.sql.Date.class);
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/hibernate/data/Product.java
5 issues
Do not use the short type
Performance

Line: 28

                   private String productScale;
     private String productVendor;
     private String productDescription;
     private short quantityInStock;
     private double buyPrice;
     private double msrp;
     private Set<OrderDetail> orderDetails = new HashSet<OrderDetail>(0);

    public Product() {

            

Reported by PMD.

Do not use the short type
Performance

Line: 118

                  }
    
    @Column(name="quantityInStock", nullable=false)
    public short getQuantityInStock() {
        return this.quantityInStock;
    }
    
    public void setQuantityInStock(short quantityInStock) {
        this.quantityInStock = quantityInStock;

            

Reported by PMD.

Do not use the short type
Performance

Line: 122

                      return this.quantityInStock;
    }
    
    public void setQuantityInStock(short quantityInStock) {
        this.quantityInStock = quantityInStock;
    }
    
    @Column(name="buyPrice", nullable=false, precision=22, scale=0)
    public double getBuyPrice() {

            

Reported by PMD.

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

Line: 19

              @Table(name="Product"
    ,catalog="classicmodels"
)
public class Product  implements java.io.Serializable {


     private String productCode;
     private String productName;
     private String productLine;

            

Reported by PMD.

Avoid long parameter lists.
Design

Line: 48

                      this.buyPrice = buyPrice;
        this.msrp = msrp;
    }
    public Product(String productCode, String productName, String productLine, String productScale, String productVendor, String productDescription, short quantityInStock, double buyPrice, double msrp, Set<OrderDetail> orderDetails) {
       this.productCode = productCode;
       this.productName = productName;
       this.productLine = productLine;
       this.productScale = productScale;
       this.productVendor = productVendor;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/FieldDeserializerTest3.java
5 issues
Avoid throwing raw exception types.
Design

Line: 54

                      }

        public void setValue(String value) {
            throw new RuntimeException();
        }

    }

}

            

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: 13

              
public class FieldDeserializerTest3 extends TestCase {

    public void test_error_1() throws Exception {
        Exception error = null;
        try {
            String input = "{\"value\":null}";
            int featureValues = 0;
            DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),

            

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

                      Assert.assertNotNull(error);
    }

    public void test_error_2() throws Exception {
        Exception error = null;
        try {
            String input = "{,,\"value\":null}";
            int featureValues = 0;
            DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '14'-'24').
Error

Line: 14

              public class FieldDeserializerTest3 extends TestCase {

    public void test_error_1() throws Exception {
        Exception error = null;
        try {
            String input = "{\"value\":null}";
            int featureValues = 0;
            DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '30'-'40').
Error

Line: 30

                  }

    public void test_error_2() throws Exception {
        Exception error = null;
        try {
            String input = "{,,\"value\":null}";
            int featureValues = 0;
            DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/str/StringTest_02.java
5 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: 14

              
public class StringTest_02 extends TestCase {

    public void test_string() throws Exception {
        char[] chars = new char[1024];
        Arrays.fill(chars, '0');
        StringBuilder buf = new StringBuilder();
        buf.append("[\"");
        for (int i = 0; i < 16; ++i) {

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      buf.append("[\"");
        for (int i = 0; i < 16; ++i) {
            buf.append("\\\"");
            buf.append(new String(chars));
        }
        buf.append("\"]");
        
        String text = buf.toString();
        JSONArray array = (JSONArray) JSON.parse(text);

            

Reported by PMD.

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

Line: 27

                      
        String text = buf.toString();
        JSONArray array = (JSONArray) JSON.parse(text);
        Assert.assertEquals(1, array.size());
        
        String item = (String) array.get(0);
        Assert.assertEquals(16 * 1024 + 16, item.length());
        
        for (int i = 0; i < 16; ++i) {

            

Reported by PMD.

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

Line: 29

                      JSONArray array = (JSONArray) JSON.parse(text);
        Assert.assertEquals(1, array.size());
        
        String item = (String) array.get(0);
        Assert.assertEquals(16 * 1024 + 16, item.length());
        
        for (int i = 0; i < 16; ++i) {
            Assert.assertTrue(item.charAt(i * 1025) == '\"');
            for (int j = 0; j < 1024; ++j) {

            

Reported by PMD.

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

Line: 30

                      Assert.assertEquals(1, array.size());
        
        String item = (String) array.get(0);
        Assert.assertEquals(16 * 1024 + 16, item.length());
        
        for (int i = 0; i < 16; ++i) {
            Assert.assertTrue(item.charAt(i * 1025) == '\"');
            for (int j = 0; j < 1024; ++j) {
                Assert.assertTrue(item.charAt(i * 1025 + j + 1) == '0');    

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/stream/StreamWriterTest_writeArray2.java
5 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: 12

              
public class StreamWriterTest_writeArray2 extends TestCase {

    public void test_0() throws Exception {
        StringWriter out = new StringWriter();

        SerializeWriter writer = new SerializeWriter(out, 10);
        Assert.assertEquals(10, writer.getBufferLength());


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 20

              
        int blockSize = 21;
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            char[] chars = new char[blockSize];
            for (int i = 0; i < blockSize; ++i) {
                chars[i] = ch;
            }
            writer.write(chars, 0, chars.length);
        }

            

Reported by PMD.

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

Line: 29

                      writer.close();

        String text = out.toString();
        Assert.assertEquals(26 * blockSize, text.length());

        for (int i = 0; i < 26; ++i) {
            for (int j = 0; j < blockSize; ++j) {
                Assert.assertEquals(text.charAt(i * blockSize + j), (char) ('a' + i));
            }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'chars' (lines '20'-'22').
Error

Line: 20

              
        int blockSize = 21;
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            char[] chars = new char[blockSize];
            for (int i = 0; i < blockSize; ++i) {
                chars[i] = ch;
            }
            writer.write(chars, 0, chars.length);
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'chars' (lines '22'-'22').
Error

Line: 22

                      for (char ch = 'a'; ch <= 'z'; ++ch) {
            char[] chars = new char[blockSize];
            for (int i = 0; i < blockSize; ++i) {
                chars[i] = ch;
            }
            writer.write(chars, 0, chars.length);
        }
        writer.close();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_13.java
5 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: 18

              
public class SerializeWriterTest_13 extends TestCase {

    public void test_default() throws Exception {
        Assert.assertEquals("{\"\":\"\"}", //
                            JSON.toJSONStringZ(Collections.singletonMap("", ""), //
                                               SerializeConfig.getGlobalInstance()));
    }


            

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: 24

                                                             SerializeConfig.getGlobalInstance()));
    }

    public void test_single() throws Exception {
        Assert.assertEquals("{'':''}", //
                            JSON.toJSONStringZ(Collections.singletonMap("", ""), //
                                               SerializeConfig.getGlobalInstance(), SerializerFeature.UseSingleQuotes));
    }


            

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: 30

                                                             SerializeConfig.getGlobalInstance(), SerializerFeature.UseSingleQuotes));
    }

    public void test_writer() throws Exception {
        SerializeWriter out = new SerializeWriter(3);

        try {
            JSONSerializer serializer = new JSONSerializer(out);


            

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: 43

                      }
    }

    public void test_writer_single() throws Exception {
        SerializeWriter out = new SerializeWriter(3);
        out.config(SerializerFeature.UseSingleQuotes, true);

        try {
            JSONSerializer serializer = new JSONSerializer(out);

            

Reported by PMD.

Avoid unused imports such as 'java.io.StringWriter'
Design

Line: 3

              package com.alibaba.json.bvt.serializer;

import java.io.StringWriter;
import java.util.Collections;

import junit.framework.TestCase;

import org.junit.Assert;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/str/EmptyStringTest.java
5 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: 10

               * Created by wenshao on 13/03/2017.
 */
public class EmptyStringTest extends TestCase {
    public void test_for_emptyString() throws Exception {
        SolutionIdentifier solutionIdentifier = JSON.parseObject("{\"id\":\"\"}", SolutionIdentifier.class);
        assertNull(solutionIdentifier.id);
    }

    public static class SolutionIdentifier {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class EmptyStringTest extends TestCase {
    public void test_for_emptyString() throws Exception {
        SolutionIdentifier solutionIdentifier = JSON.parseObject("{\"id\":\"\"}", SolutionIdentifier.class);
        assertNull(solutionIdentifier.id);
    }

    public static class SolutionIdentifier {
        public Id id;
    }

            

Reported by PMD.

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

Line: 16

                  }

    public static class SolutionIdentifier {
        public Id id;
    }

    public static class Id {
        public String id;
    }

            

Reported by PMD.

It is somewhat confusing to have a field name matching the declaring class name
Error

Line: 20

                  }

    public static class Id {
        public String id;
    }
}

            

Reported by PMD.

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

Line: 20

                  }

    public static class Id {
        public String id;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/taobao/MTopTest.java
5 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: 19

              
public class MTopTest extends TestCase {

    public void test_for_mtop() throws Exception {
        P0 p = new P0();
        p.model = new Model();

        ContextValueFilter valueFilter = new ContextValueFilter() {


            

Reported by PMD.

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

Line: 39

                                  Assert.assertEquals(SerializerFeature.WriteMapNullValue.mask, context.getFeatures());
                    
                    Field field = context.getField();
                    Assert.assertNotNull(field.getAnnotation(UrlIdentify.class));
                    Assert.assertNotNull(context.getAnnation(UrlIdentify.class));
                    
                    return value;
                }


            

Reported by PMD.

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

Line: 68

              
    }

    public static class Model {

        private int    id;
        private String url;

        public String getUrl() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'valueFilter' (lines '23'-'50').
Error

Line: 23

                      P0 p = new P0();
        p.model = new Model();

        ContextValueFilter valueFilter = new ContextValueFilter() {

            @Override
            public Object process(BeanContext context, Object object, String name, Object value) {



            

Reported by PMD.

Found 'DU'-anomaly for variable 'valueFilter' (lines '23'-'50').
Error

Line: 23

                      P0 p = new P0();
        p.model = new Model();

        ContextValueFilter valueFilter = new ContextValueFilter() {

            @Override
            public Object process(BeanContext context, Object object, String name, Object value) {



            

Reported by PMD.