The following issues were found

src/test/java/data/media/writeAsArray/ImageDeserializer.java
8 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 21

                      Image image = new Image();

        final JSONLexer lexer = parser.getLexer();
        if (lexer.token() != JSONToken.LBRACKET) {
            throw new JSONException("error");
        }
        
        int height = lexer.scanInt(',');
        int width = lexer.scanInt(',');

            

Reported by PMD.

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

Line: 25

                          throw new JSONException("error");
        }
        
        int height = lexer.scanInt(',');
        int width = lexer.scanInt(',');
        String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
        String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        

            

Reported by PMD.

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

Line: 26

                      }
        
        int height = lexer.scanInt(',');
        int width = lexer.scanInt(',');
        String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
        String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        
        lexer.nextToken(JSONToken.COMMA);

            

Reported by PMD.

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

Line: 27

                      
        int height = lexer.scanInt(',');
        int width = lexer.scanInt(',');
        String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
        String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        
        lexer.nextToken(JSONToken.COMMA);
        

            

Reported by PMD.

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

Line: 28

                      int height = lexer.scanInt(',');
        int width = lexer.scanInt(',');
        String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
        String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        
        lexer.nextToken(JSONToken.COMMA);
        
        image.setHeight(height);

            

Reported by PMD.

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

Line: 29

                      int width = lexer.scanInt(',');
        String sizeName = lexer.scanSymbolWithSeperator(parser.getSymbolTable(), ',');
        String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        
        lexer.nextToken(JSONToken.COMMA);
        
        image.setHeight(height);
        image.setWidth(width);

            

Reported by PMD.

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

Line: 31

                      String title = lexer.scanString(',');
        String uri = lexer.scanString(']');
        
        lexer.nextToken(JSONToken.COMMA);
        
        image.setHeight(height);
        image.setWidth(width);
        image.setSize(Size.valueOf(sizeName));
        image.setTitle(title);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'image' (lines '18'-'39').
Error

Line: 18

              
    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        Image image = new Image();

        final JSONLexer lexer = parser.getLexer();
        if (lexer.token() != JSONToken.LBRACKET) {
            throw new JSONException("error");
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_double_private.java
8 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: 13

              import junit.framework.TestCase;

public class WriteAsArray_double_private extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123D);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

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

                      Assert.assertEquals(vo.name, vo2.name);
    }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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.assertNotNull(error);
    }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 56

                      Assert.assertNotNull(error);
    }
    
    public static class VO {
        private double id;
        private String name;

        public double getId() {
            return id;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '27'-'31').
Error

Line: 27

                  }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '37'-'41').
Error

Line: 37

                  }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '47'-'51').
Error

Line: 47

                  }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/ReuseObject.java
8 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 11/02/2017.
 */
public class ReuseObject extends TestCase {
    public void test_reuse() throws Exception {
Model model = new Model();

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":123,\"name\":\"wangsai-silence\"}");
    parser.parseObject(model);

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 11/02/2017.
 */
public class ReuseObject extends TestCase {
    public void test_reuse() throws Exception {
Model model = new Model();

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":123,\"name\":\"wangsai-silence\"}");
    parser.parseObject(model);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                  parser.parseObject(model);
    parser.close(); // 调用close能重用buf,提升性能

    assertEquals(123, model.id);
    assertEquals("wangsai-silence", model.name);
}

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":234,\"name\":\"wenshao\"}");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                  parser.close(); // 调用close能重用buf,提升性能

    assertEquals(123, model.id);
    assertEquals("wangsai-silence", model.name);
}

{
    DefaultJSONParser parser = new DefaultJSONParser("{\"id\":234,\"name\":\"wenshao\"}");
    parser.parseObject(model);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                  parser.parseObject(model);
    parser.close(); // 调用close能重用buf,提升性能

    assertEquals(234, model.id);
    assertEquals("wenshao", model.name);
}
    }
public static class Model {
    public int id;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                  parser.close(); // 调用close能重用buf,提升性能

    assertEquals(234, model.id);
    assertEquals("wenshao", model.name);
}
    }
public static class Model {
    public int id;
    public String name;

            

Reported by PMD.

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

Line: 32

              }
    }
public static class Model {
    public int id;
    public String name;
}
}

            

Reported by PMD.

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

Line: 33

                  }
public static class Model {
    public int id;
    public String name;
}
}

            

Reported by PMD.

src/test/java/com/alibaba/json/test/A1.java
8 issues
System.out.println is used
Design

Line: 22

                  public void test_a() throws Exception {
        Object obj = JSON.parse("[{\"feature\":\"\\u3A56\\u3A26\"}]");
        String json = JSON.toJSONString(obj, SerializerFeature.BrowserCompatible);
        System.out.println(json);


    }



            

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

               */
public class A1 extends TestCase {

    public void test_a() throws Exception {
        Object obj = JSON.parse("[{\"feature\":\"\\u3A56\\u3A26\"}]");
        String json = JSON.toJSONString(obj, SerializerFeature.BrowserCompatible);
        System.out.println(json);



            

Reported by PMD.

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

Line: 19

               */
public class A1 extends TestCase {

    public void test_a() throws Exception {
        Object obj = JSON.parse("[{\"feature\":\"\\u3A56\\u3A26\"}]");
        String json = JSON.toJSONString(obj, SerializerFeature.BrowserCompatible);
        System.out.println(json);



            

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

                  }


    public void test_ser() throws Exception {
//        JSONObject obj = new JSONObject();
//
//        ByteArrayOutputStream out = new ByteArrayOutputStream();
//        ObjectOutputStream objOut = new ObjectOutputStream(out);
//        objOut.writeObject(obj);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

                      ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes2);
        ObjectInputStream objIn = new ObjectInputStream(byteIn);
        Object obj = objIn.readObject();
        assertEquals(JSONObject.class, obj.getClass());

    }
}

            

Reported by PMD.

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

Line: 45

                      ByteArrayInputStream byteIn = new ByteArrayInputStream(bytes2);
        ObjectInputStream objIn = new ObjectInputStream(byteIn);
        Object obj = objIn.readObject();
        assertEquals(JSONObject.class, obj.getClass());

    }
}

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Created by wenshao on 14/03/2017.

            

Reported by PMD.

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

Line: 12

              import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * Created by wenshao on 14/03/2017.
 */
public class A1 extends TestCase {

            

Reported by PMD.

src/test/java/com/alibaba/json/test/Issue3805.java
8 issues
Found 'DU'-anomaly for variable 'byteOut' (lines '46'-'70').
Error

Line: 46

                      converter.canRead(TestModel.class, MediaType.APPLICATION_JSON_UTF8);
        converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'byteOut' (lines '46'-'70').
Error

Line: 46

                      converter.canRead(TestModel.class, MediaType.APPLICATION_JSON_UTF8);
        converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'byteOut' (lines '46'-'70').
Error

Line: 46

                      converter.canRead(TestModel.class, MediaType.APPLICATION_JSON_UTF8);
        converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'byteOut' (lines '46'-'70').
Error

Line: 46

                      converter.canRead(TestModel.class, MediaType.APPLICATION_JSON_UTF8);
        converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;


            

Reported by PMD.

Found 'DU'-anomaly for variable 'out' (lines '47'-'70').
Error

Line: 47

                      converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;

                    @Override

            

Reported by PMD.

Found 'DU'-anomaly for variable 'out' (lines '47'-'70').
Error

Line: 47

                      converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;

                    @Override

            

Reported by PMD.

Found 'DU'-anomaly for variable 'out' (lines '47'-'70').
Error

Line: 47

                      converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;

                    @Override

            

Reported by PMD.

Found 'DU'-anomaly for variable 'out' (lines '47'-'70').
Error

Line: 47

                      converter.canWrite(TestModel.class, MediaType.APPLICATION_JSON_UTF8);

        final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
        HttpOutputMessage out = new HttpOutputMessage() {
            public HttpHeaders getHeaders() {
                return new HttpHeaders() {
                    private static final long serialVersionUID = 1L;

                    @Override

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain_EishayEncode.java
8 issues
System.out.println is used
Design

Line: 16

              public class BenchmarkMain_EishayEncode {

    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);

            

Reported by PMD.

System.out.println is used
Design

Line: 18

                  public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        

            

Reported by PMD.

System.out.println is used
Design

Line: 22

              
        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);
        }
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 44

                      long ygct = TestUtils.getYoungGCTime() - startYGCTime;
        long fgc = TestUtils.getFullGC() - startFGC;

        System.out.println("encode\t" + millis + ", ygc " + ygc + ", ygct " + ygct + ", fgc " + fgc);
        return millis;
    }

    static String encode(Object text) {
        return JSON.toJSONString(text, SerializerFeature.BeanToArray);

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 13

              
import data.media.MediaContent;

public class BenchmarkMain_EishayEncode {

    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 15

              
public class BenchmarkMain_EishayEncode {

    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();

            

Reported by PMD.

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

Line: 17

              
    public static void main(String[] args) throws Exception {
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);

            

Reported by PMD.

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

Line: 20

                      List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/BenchmarkMain_EishayEncode_WriteAsArray.java
8 issues
System.out.println is used
Design

Line: 26

                      config.put(Media.class, new MediaSerializer());
        config.put(Image.class, new ImageSerializer());
        
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);

            

Reported by PMD.

System.out.println is used
Design

Line: 28

                      
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        

            

Reported by PMD.

System.out.println is used
Design

Line: 32

              
        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);
        }
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 54

                      long ygct = TestUtils.getYoungGCTime() - startYGCTime;
        long fgc = TestUtils.getFullGC() - startFGC;

        System.out.println("encode\t" + millis + ", ygc " + ygc + ", ygct " + ygct + ", fgc " + fgc);
        return millis;
    }

    static String encode(Object text) {
        return JSON.toJSONString(text);

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 18

              import data.media.writeAsArray.MediaContentSerializer;
import data.media.writeAsArray.MediaSerializer;

public class BenchmarkMain_EishayEncode_WriteAsArray {

    public static void main(String[] args) throws Exception {
        SerializeConfig config = SerializeConfig.getGlobalInstance();
        config.put(MediaContent.class, new MediaContentSerializer());
        config.put(Media.class, new MediaSerializer());

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 20

              
public class BenchmarkMain_EishayEncode_WriteAsArray {

    public static void main(String[] args) throws Exception {
        SerializeConfig config = SerializeConfig.getGlobalInstance();
        config.put(MediaContent.class, new MediaContentSerializer());
        config.put(Media.class, new MediaSerializer());
        config.put(Image.class, new ImageSerializer());
        

            

Reported by PMD.

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

Line: 27

                      config.put(Image.class, new ImageSerializer());
        
        System.out.println(System.getProperty("java.vm.name") + " " + System.getProperty("java.runtime.version"));
        List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);

            

Reported by PMD.

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

Line: 30

                      List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
        System.out.println(arguments);

        MediaContent content = EishayDecodeBytes.instance.getContent();
        String text = encode(content);
        System.out.println(text);
        
        for (int i = 0; i < 10; ++i) {
            perf(text);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_double_public.java
8 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: 13

              import junit.framework.TestCase;

public class WriteAsArray_double_public extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123D);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

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

                      Assert.assertEquals(vo.name, vo2.name);
    }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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.assertNotNull(error);
    }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 56

                      Assert.assertNotNull(error);
    }
    
    private static class VO {
        private double id;
        private String name;

        public double getId() {
            return id;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '27'-'31').
Error

Line: 27

                  }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '37'-'41').
Error

Line: 37

                  }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '47'-'51').
Error

Line: 47

                  }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/RyuFloatBenchmark.java
8 issues
System.out.println is used
Design

Line: 12

                      float v = 0.539005056644f; //new java.util.Random().nextDouble();


        System.out.println(v);

//        for (int i = 0; i < 10; ++i) {
//            f0(v); // 741
//        }


            

Reported by PMD.

System.out.println is used
Design

Line: 31

                          Float.toString(v);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("jdk : " + millis);
    }

    public static void f1(float v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 40

                          RyuFloat.toString(v);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("ryu : " + millis);
    }
}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 6

              import com.alibaba.fastjson.util.RyuDouble;
import com.alibaba.fastjson.util.RyuFloat;

public class RyuFloatBenchmark {
    private final static int COUNT = 1000 * 1000 * 10;
    public static void main(String[] args) throws Exception {
        float v = 0.539005056644f; //new java.util.Random().nextDouble();



            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 8

              
public class RyuFloatBenchmark {
    private final static int COUNT = 1000 * 1000 * 10;
    public static void main(String[] args) throws Exception {
        float v = 0.539005056644f; //new java.util.Random().nextDouble();


        System.out.println(v);


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 25

                      }
    }

    public static void f0(float v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {
            Float.toString(v);
        }
        long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 34

                      System.out.println("jdk : " + millis);
    }

    public static void f1(float v) throws Exception {
        long start = System.currentTimeMillis();
        for (int i = 0; i < COUNT; ++i) {
            RyuFloat.toString(v);
        }
        long millis = System.currentTimeMillis() - start;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.util.RyuDouble'
Design

Line: 3

              package com.alibaba.json.test.benchmark;

import com.alibaba.fastjson.util.RyuDouble;
import com.alibaba.fastjson.util.RyuFloat;

public class RyuFloatBenchmark {
    private final static int COUNT = 1000 * 1000 * 10;
    public static void main(String[] args) throws Exception {
        float v = 0.539005056644f; //new java.util.Random().nextDouble();

            

Reported by PMD.

src/test/java/com/alibaba/json/test/benchmark/basic/FloatBenchmark.java
8 issues
System.out.println is used
Design

Line: 45

                          JSON.parseObject(json, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static void perf2() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000 * 1000; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 54

                          JSON.parseObject(json2, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static void perf3() {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000 * 1000; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 63

                          JSON.parseObject(json3, Model.class);
        }
        long millis = System.currentTimeMillis() - start;
        System.out.println("millis : " + millis);
    }

    public static class Model {
        public float v1;
        public float v2;

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 10

              /**
 * Created by wenshao on 04/08/2017.
 */
public class FloatBenchmark {
    static String json = "{\"v1\":0.012671709,\"v2\":0.6042485,\"v3\":0.13231707,\"v4\":0.80090785,\"v5\":0.6192943}";
    static String json2 = "{\"v1\":\"0.012671709\",\"v2\":\"0.6042485\",\"v3\":\"0.13231707\",\"v4\":\"0.80090785\",\"v5\":\"0.6192943\"}";
    static String json3 = "{\n" +
            "\t\"v1\":0.012671709,\n" +
            "\t\"v2\":0.6042485,\n" +

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 21

                          "\t\"v5\":0.6192943\n" +
            "}";

    public static void main(String[] args) throws Exception {
        Model model = new Model();
//        model.v1 = new Random().nextFloat();
//        model.v2 = new Random().nextFloat();
//        model.v3 = new Random().nextFloat();
//        model.v4 = new Random().nextFloat();

            

Reported by PMD.

Avoid unused local variables such as 'model'.
Design

Line: 22

                          "}";

    public static void main(String[] args) throws Exception {
        Model model = new Model();
//        model.v1 = new Random().nextFloat();
//        model.v2 = new Random().nextFloat();
//        model.v3 = new Random().nextFloat();
//        model.v4 = new Random().nextFloat();
//        model.v5 = new Random().nextFloat();

            

Reported by PMD.

Avoid unused imports such as 'java.util.Random'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;

import java.util.Random;

/**
 * Created by wenshao on 04/08/2017.
 */
public class FloatBenchmark {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'model' (lines '22'-'37').
Error

Line: 22

                          "}";

    public static void main(String[] args) throws Exception {
        Model model = new Model();
//        model.v1 = new Random().nextFloat();
//        model.v2 = new Random().nextFloat();
//        model.v3 = new Random().nextFloat();
//        model.v4 = new Random().nextFloat();
//        model.v5 = new Random().nextFloat();

            

Reported by PMD.