The following issues were found

litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminDashbordController.java
6 issues
Logger should be defined private static final and have the correct class
Error

Line: 23

              @RequestMapping("/admin/dashboard")
@Validated
public class AdminDashbordController {
    private final Log logger = LogFactory.getLog(AdminDashbordController.class);

    @Autowired
    private LitemallUserService userService;
    @Autowired
    private LitemallGoodsService goodsService;

            

Reported by PMD.

Avoid unused private fields such as 'logger'.
Design

Line: 23

              @RequestMapping("/admin/dashboard")
@Validated
public class AdminDashbordController {
    private final Log logger = LogFactory.getLog(AdminDashbordController.class);

    @Autowired
    private LitemallUserService userService;
    @Autowired
    private LitemallGoodsService goodsService;

            

Reported by PMD.

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

Line: 26

                  private final Log logger = LogFactory.getLog(AdminDashbordController.class);

    @Autowired
    private LitemallUserService userService;
    @Autowired
    private LitemallGoodsService goodsService;
    @Autowired
    private LitemallGoodsProductService productService;
    @Autowired

            

Reported by PMD.

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

Line: 28

                  @Autowired
    private LitemallUserService userService;
    @Autowired
    private LitemallGoodsService goodsService;
    @Autowired
    private LitemallGoodsProductService productService;
    @Autowired
    private LitemallOrderService orderService;


            

Reported by PMD.

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

Line: 30

                  @Autowired
    private LitemallGoodsService goodsService;
    @Autowired
    private LitemallGoodsProductService productService;
    @Autowired
    private LitemallOrderService orderService;

    @GetMapping("")
    public Object info() {

            

Reported by PMD.

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

Line: 32

                  @Autowired
    private LitemallGoodsProductService productService;
    @Autowired
    private LitemallOrderService orderService;

    @GetMapping("")
    public Object info() {
        int userTotal = userService.count();
        int goodsTotal = goodsService.count();

            

Reported by PMD.

litemall-core/src/main/java/org/linlinjava/litemall/core/storage/StorageService.java
5 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 20

                  private String active;
    private Storage storage;
    @Autowired
    private LitemallStorageService litemallStorageService;

    public String getActive() {
        return active;
    }


            

Reported by PMD.

The initializer for variable 'key' is never used (overwritten on line 70)
Design

Line: 66

                      int index = originalFilename.lastIndexOf('.');
        String suffix = originalFilename.substring(index);

        String key = null;
        LitemallStorage storageInfo = null;

        do {
            key = CharUtil.getRandomString(20) + suffix;
            storageInfo = litemallStorageService.findByKey(key);

            

Reported by PMD.

The initializer for variable 'storageInfo' is never used (overwritten on line 71)
Design

Line: 67

                      String suffix = originalFilename.substring(index);

        String key = null;
        LitemallStorage storageInfo = null;

        do {
            key = CharUtil.getRandomString(20) + suffix;
            storageInfo = litemallStorageService.findByKey(key);
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'key' (lines '66'-'70').
Error

Line: 66

                      int index = originalFilename.lastIndexOf('.');
        String suffix = originalFilename.substring(index);

        String key = null;
        LitemallStorage storageInfo = null;

        do {
            key = CharUtil.getRandomString(20) + suffix;
            storageInfo = litemallStorageService.findByKey(key);

            

Reported by PMD.

Found 'DD'-anomaly for variable 'storageInfo' (lines '67'-'71').
Error

Line: 67

                      String suffix = originalFilename.substring(index);

        String key = null;
        LitemallStorage storageInfo = null;

        do {
            key = CharUtil.getRandomString(20) + suffix;
            storageInfo = litemallStorageService.findByKey(key);
        }

            

Reported by PMD.

litemall-core/src/main/java/org/linlinjava/litemall/core/config/GlobalExceptionHandler.java
5 issues
Avoid using a branching statement as the last in a loop.
Error

Line: 63

                          Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
            for (ConstraintViolation<?> item : violations) {
                String message = ((PathImpl) item.getPropertyPath()).getLeafNode().getName() + item.getMessage();
                return ResponseUtil.fail(402, message);
            }
        }
        return ResponseUtil.badArgumentValue();
    }


            

Reported by PMD.

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

Line: 24

              @Order
public class GlobalExceptionHandler {

    private Log logger = LogFactory.getLog(GlobalExceptionHandler.class);

    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public Object badArgumentHandler(IllegalArgumentException e) {
        logger.error(e.getMessage(), e);

            

Reported by PMD.

Logger should be defined private static final and have the correct class
Error

Line: 24

              @Order
public class GlobalExceptionHandler {

    private Log logger = LogFactory.getLog(GlobalExceptionHandler.class);

    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public Object badArgumentHandler(IllegalArgumentException e) {
        logger.error(e.getMessage(), e);

            

Reported by PMD.

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

Line: 24

              @Order
public class GlobalExceptionHandler {

    private Log logger = LogFactory.getLog(GlobalExceptionHandler.class);

    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseBody
    public Object badArgumentHandler(IllegalArgumentException e) {
        logger.error(e.getMessage(), e);

            

Reported by PMD.

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

Line: 60

                      logger.error(e.getMessage(), e);
        if (e instanceof ConstraintViolationException) {
            ConstraintViolationException exs = (ConstraintViolationException) e;
            Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
            for (ConstraintViolation<?> item : violations) {
                String message = ((PathImpl) item.getPropertyPath()).getLeafNode().getName() + item.getMessage();
                return ResponseUtil.fail(402, message);
            }
        }

            

Reported by PMD.

litemall-core/src/test/java/org/linlinjava/litemall/core/CoreConfigTest.java
5 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 18

              @RunWith(SpringRunner.class)
@SpringBootTest
public class CoreConfigTest {
    private final Log logger = LogFactory.getLog(CoreConfigTest.class);
    @Autowired
    Environment environment;

    @Test
    public void test() {

            

Reported by PMD.

Logger should be defined private static final and have the correct class
Error

Line: 18

              @RunWith(SpringRunner.class)
@SpringBootTest
public class CoreConfigTest {
    private final Log logger = LogFactory.getLog(CoreConfigTest.class);
    @Autowired
    Environment environment;

    @Test
    public void test() {

            

Reported by PMD.

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

Line: 20

              public class CoreConfigTest {
    private final Log logger = LogFactory.getLog(CoreConfigTest.class);
    @Autowired
    Environment environment;

    @Test
    public void test() {
        // 测试获取application-core.yml配置信息
        logger.info(environment.getProperty("litemall.express.appId"));

            

Reported by PMD.

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

Line: 23

                  Environment environment;

    @Test
    public void test() {
        // 测试获取application-core.yml配置信息
        logger.info(environment.getProperty("litemall.express.appId"));
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.springframework.test.context.junit4.SpringJUnit4ClassRunner'
Design

Line: 10

              import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.env.Environment;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;

@WebAppConfiguration
@RunWith(SpringRunner.class)

            

Reported by PMD.

litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxOrderController.java
5 issues
This class has too many methods, consider refactoring it.
Design

Line: 20

              @RestController
@RequestMapping("/wx/order")
@Validated
public class WxOrderController {
    private final Log logger = LogFactory.getLog(WxOrderController.class);

    @Autowired
    private WxOrderService wxOrderService;


            

Reported by PMD.

Avoid unused private fields such as 'logger'.
Design

Line: 21

              @RequestMapping("/wx/order")
@Validated
public class WxOrderController {
    private final Log logger = LogFactory.getLog(WxOrderController.class);

    @Autowired
    private WxOrderService wxOrderService;

    /**

            

Reported by PMD.

Logger should be defined private static final and have the correct class
Error

Line: 21

              @RequestMapping("/wx/order")
@Validated
public class WxOrderController {
    private final Log logger = LogFactory.getLog(WxOrderController.class);

    @Autowired
    private WxOrderService wxOrderService;

    /**

            

Reported by PMD.

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

Line: 24

                  private final Log logger = LogFactory.getLog(WxOrderController.class);

    @Autowired
    private WxOrderService wxOrderService;

    /**
     * 订单列表
     *
     * @param userId   用户ID

            

Reported by PMD.

Avoid unused imports such as 'org.springframework.web.bind.annotation'
Design

Line: 11

              import org.linlinjava.litemall.wx.service.WxOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;


            

Reported by PMD.

litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxBrandController.java
5 issues
Logger should be defined private static final and have the correct class
Error

Line: 29

              @RequestMapping("/wx/brand")
@Validated
public class WxBrandController {
    private final Log logger = LogFactory.getLog(WxBrandController.class);

    @Autowired
    private LitemallBrandService brandService;

    /**

            

Reported by PMD.

Avoid unused private fields such as 'logger'.
Design

Line: 29

              @RequestMapping("/wx/brand")
@Validated
public class WxBrandController {
    private final Log logger = LogFactory.getLog(WxBrandController.class);

    @Autowired
    private LitemallBrandService brandService;

    /**

            

Reported by PMD.

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

Line: 32

                  private final Log logger = LogFactory.getLog(WxBrandController.class);

    @Autowired
    private LitemallBrandService brandService;

    /**
     * 品牌列表
     *
     * @param page 分页页数

            

Reported by PMD.

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

Line: 18

              import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 专题服务

            

Reported by PMD.

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

Line: 20

              import javax.validation.constraints.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 专题服务
 */
@RestController

            

Reported by PMD.

litemall-core/src/main/java/org/linlinjava/litemall/core/util/CharUtil.java
5 issues
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: 5

              
import java.util.Random;

public class CharUtil {

    public static String getRandomString(Integer num) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();

            

Reported by PMD.

Found 'DU'-anomaly for variable 'base' (lines '8'-'16').
Error

Line: 8

              public class CharUtil {

    public static String getRandomString(Integer num) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));

            

Reported by PMD.

Found 'DU'-anomaly for variable 'random' (lines '9'-'16').
Error

Line: 9

              
    public static String getRandomString(Integer num) {
        String base = "abcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'base' (lines '19'-'27').
Error

Line: 19

                  }

    public static String getRandomNum(Integer num) {
        String base = "0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));

            

Reported by PMD.

Found 'DU'-anomaly for variable 'random' (lines '20'-'27').
Error

Line: 20

              
    public static String getRandomNum(Integer num) {
        String base = "0123456789";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < num; i++) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }

            

Reported by PMD.

litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyProperties.java
5 issues
The class 'NotifyProperties' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=4, WMC=4)
Design

Line: 10

              import java.util.Map;

@ConfigurationProperties(prefix = "litemall.notify")
public class NotifyProperties {
    private Mail mail;
    private Sms sms;

    public Mail getMail() {
        return mail;

            

Reported by PMD.

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

Line: 30

                      this.sms = sms;
    }

    public static class Mail {
        private boolean enable;
        private String host;
        private String username;
        private String password;
        private String sendfrom;

            

Reported by PMD.

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

Line: 95

                      }
    }

    public static class Sms {
        private boolean enable;
        private String active;
        private String sign;
        private Tencent tencent;
        private Aliyun aliyun;

            

Reported by PMD.

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

Line: 151

                          this.aliyun = aliyun;
        }

        public static class Tencent {
            private int appid;
            private String appkey;

            public int getAppid() {
                return appid;

            

Reported by PMD.

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

Line: 172

                          }
        }

        public static class Aliyun {
            private String regionId;
            private String accessKeyId;
            private String accessKeySecret;

            public String getRegionId() {

            

Reported by PMD.

litemall-core/src/main/java/org/linlinjava/litemall/core/storage/config/StorageProperties.java
5 issues
The class 'StorageProperties' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=10, WMC=10)
Design

Line: 6

              import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "litemall.storage")
public class StorageProperties {
    private String active;
    private Local local;
    private Aliyun aliyun;
    private Tencent tencent;
    private Qiniu qiniu;

            

Reported by PMD.

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

Line: 53

                      this.qiniu = qiniu;
    }

    public static class Local {
        private String address;
        private String storagePath;

        public String getAddress() {
            return address;

            

Reported by PMD.

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

Line: 74

                      }
    }

    public static class Tencent {
        private String secretId;
        private String secretKey;
        private String region;
        private String bucketName;


            

Reported by PMD.

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

Line: 113

                      }
    }

    public static class Aliyun {
        private String endpoint;
        private String accessKeyId;
        private String accessKeySecret;
        private String bucketName;


            

Reported by PMD.

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

Line: 152

                      }
    }

    public static class Qiniu {
        private String endpoint;
        private String accessKey;
        private String secretKey;
        private String bucketName;


            

Reported by PMD.

litemall-db/src/main/java/org/linlinjava/litemall/db/domain/OrderGoodsVo.java
5 issues
The class 'OrderGoodsVo' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=18, WMC=18)
Design

Line: 6

              import java.math.BigDecimal;
import java.util.Arrays;

public class OrderGoodsVo {
    private Integer id;
    private String goodsName;
    private String picUrl;
    private Integer goodsId;
    private Integer productId;

            

Reported by PMD.

Returning 'specifications' may expose an internal array.
Design

Line: 65

                  }

    public String[] getSpecifications() {
        return specifications;
    }

    public void setSpecifications(String[] specifications) {
        this.specifications = specifications;
    }

            

Reported by PMD.

The user-supplied array 'specifications' is stored directly.
Design

Line: 68

                      return specifications;
    }

    public void setSpecifications(String[] specifications) {
        this.specifications = specifications;
    }

    public Integer getNumber() {
        return number;

            

Reported by PMD.

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

Line: 4

              package org.linlinjava.litemall.db.domain;

import java.math.BigDecimal;
import java.util.Arrays;

public class OrderGoodsVo {
    private Integer id;
    private String goodsName;
    private String picUrl;

            

Reported by PMD.

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

Line: 68

                      return specifications;
    }

    public void setSpecifications(String[] specifications) {
        this.specifications = specifications;
    }

    public Integer getNumber() {
        return number;

            

Reported by PMD.