The following issues were found

litemall-admin-api/src/test/java/org/linlinjava/litemall/admin/PermissionTest.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              public class PermissionTest {

    @Autowired
    private ApplicationContext context;

    @Test
    public void test() {
        final String basicPackage = "org.linlinjava.litemall.admin";
        List<Permission> permissionList = PermissionUtil.listPermission(context, basicPackage);

            

Reported by PMD.

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

Line: 25

                  private ApplicationContext context;

    @Test
    public void test() {
        final String basicPackage = "org.linlinjava.litemall.admin";
        List<Permission> permissionList = PermissionUtil.listPermission(context, basicPackage);
        List<PermVo> permVoList = PermissionUtil.listPermVo(permissionList);
        permVoList.stream().forEach(System.out::println);
    }

            

Reported by PMD.

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

Line: 29

                      final String basicPackage = "org.linlinjava.litemall.admin";
        List<Permission> permissionList = PermissionUtil.listPermission(context, basicPackage);
        List<PermVo> permVoList = PermissionUtil.listPermVo(permissionList);
        permVoList.stream().forEach(System.out::println);
    }
}

            

Reported by PMD.

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

Line: 29

                      final String basicPackage = "org.linlinjava.litemall.admin";
        List<Permission> permissionList = PermissionUtil.listPermission(context, basicPackage);
        List<PermVo> permVoList = PermissionUtil.listPermVo(permissionList);
        permVoList.stream().forEach(System.out::println);
    }
}

            

Reported by PMD.

litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallRegionService.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 17

              public class LitemallRegionService {

    @Resource
    private LitemallRegionMapper regionMapper;

    public List<LitemallRegion> getAll(){
        LitemallRegionExample example = new LitemallRegionExample();
        byte b = 4;
        example.or().andTypeNotEqualTo(b);

            

Reported by PMD.

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

Line: 22

                  public List<LitemallRegion> getAll(){
        LitemallRegionExample example = new LitemallRegionExample();
        byte b = 4;
        example.or().andTypeNotEqualTo(b);
        return regionMapper.selectByExample(example);
    }

    public List<LitemallRegion> queryByPid(Integer parentId) {
        LitemallRegionExample example = new LitemallRegionExample();

            

Reported by PMD.

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

Line: 28

              
    public List<LitemallRegion> queryByPid(Integer parentId) {
        LitemallRegionExample example = new LitemallRegionExample();
        example.or().andPidEqualTo(parentId);
        return regionMapper.selectByExample(example);
    }

    public LitemallRegion findById(Integer id) {
        return regionMapper.selectByPrimaryKey(id);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'criteria' (lines '38'-'53').
Error

Line: 38

              
    public List<LitemallRegion> querySelective(String name, Integer code, Integer page, Integer size, String sort, String order) {
        LitemallRegionExample example = new LitemallRegionExample();
        LitemallRegionExample.Criteria criteria = example.createCriteria();

        if (!StringUtils.isEmpty(name)) {
            criteria.andNameLike("%" + name + "%");
        }
        if (!StringUtils.isEmpty(code)) {

            

Reported by PMD.

litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
4 issues
Avoid unused private fields such as 'logger'.
Design

Line: 29

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

    @Autowired
    private LitemallUserService userService;

    @RequiresPermissions("admin:user:list")

            

Reported by PMD.

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

Line: 29

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

    @Autowired
    private LitemallUserService userService;

    @RequiresPermissions("admin:user:list")

            

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(AdminUserController.class);

    @Autowired
    private LitemallUserService userService;

    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "会员管理"}, button = "查询")
    @GetMapping("/list")
    public Object list(String username, String mobile,

            

Reported by PMD.

Rather than using a lot of String arguments, consider using a container object for those values.
Design

Line: 37

                  @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "会员管理"}, button = "查询")
    @GetMapping("/list")
    public Object list(String username, String mobile,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "desc") String order) {
        List<LitemallUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);

            

Reported by PMD.

litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminIndexController.java
4 issues
Avoid unused private fields such as 'logger'.
Design

Line: 16

              @RestController
@RequestMapping("/admin/index")
public class AdminIndexController {
    private final Log logger = LogFactory.getLog(AdminIndexController.class);

    @RequestMapping("/index")
    public Object index() {
        return ResponseUtil.ok("hello world, this is admin service");
    }

            

Reported by PMD.

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

Line: 16

              @RestController
@RequestMapping("/admin/index")
public class AdminIndexController {
    private final Log logger = LogFactory.getLog(AdminIndexController.class);

    @RequestMapping("/index")
    public Object index() {
        return ResponseUtil.ok("hello world, this is admin service");
    }

            

Reported by PMD.

The String literal 'hello world, this is admin service' appears 8 times in this file; the first occurrence is on line 20
Error

Line: 20

              
    @RequestMapping("/index")
    public Object index() {
        return ResponseUtil.ok("hello world, this is admin service");
    }

    @RequiresGuest
    @RequestMapping("/guest")
    public Object guest() {

            

Reported by PMD.

Avoid unused imports such as 'org.apache.shiro.authz.annotation'
Design

Line: 5

              
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.*;
import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

            

Reported by PMD.

litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminHistoryController.java
4 issues
Avoid unused private fields such as 'logger'.
Design

Line: 23

              @RestController
@RequestMapping("/admin/history")
public class AdminHistoryController {
    private final Log logger = LogFactory.getLog(AdminHistoryController.class);

    @Autowired
    private LitemallSearchHistoryService searchHistoryService;

    @RequiresPermissions("admin:history:list")

            

Reported by PMD.

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

Line: 23

              @RestController
@RequestMapping("/admin/history")
public class AdminHistoryController {
    private final Log logger = LogFactory.getLog(AdminHistoryController.class);

    @Autowired
    private LitemallSearchHistoryService searchHistoryService;

    @RequiresPermissions("admin:history:list")

            

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(AdminHistoryController.class);

    @Autowired
    private LitemallSearchHistoryService searchHistoryService;

    @RequiresPermissions("admin:history:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "搜索历史"}, button = "查询")
    @GetMapping("/list")
    public Object list(String userId, String keyword,

            

Reported by PMD.

Rather than using a lot of String arguments, consider using a container object for those values.
Design

Line: 31

                  @RequiresPermissions("admin:history:list")
    @RequiresPermissionsDesc(menu = {"用户管理", "搜索历史"}, button = "查询")
    @GetMapping("/list")
    public Object list(String userId, String keyword,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "desc") String order) {
        List<LitemallSearchHistory> historyList = searchHistoryService.querySelective(userId, keyword, page, limit,

            

Reported by PMD.

litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/HomeCacheManager.java
4 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: 11

              /**
 * 简单缓存的数据
 */
public class HomeCacheManager {
    public static final boolean ENABLE = false;
    public static final String INDEX = "index";
    public static final String CATALOG = "catalog";
    public static final String GOODS = "goods";


            

Reported by PMD.

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

Line: 36

                      cacheData.putAll(data);
        cacheData.put("isCache", "true");
        //设置缓存有效期为10分钟
        cacheData.put("expireTime", LocalDateTime.now().plusMinutes(10));
        cacheDataList.put(cacheKey, cacheData);
    }

    public static Map<String, Object> getCacheData(String cacheKey) {
        return cacheDataList.get(cacheKey);

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 58

                          return false;
        } else {
            LocalDateTime expire = (LocalDateTime) cacheData.get("expireTime");
            if (expire.isBefore(LocalDateTime.now())) {
                return false;
            } else {
                return true;
            }
        }

            

Reported by PMD.

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

Line: 58

                          return false;
        } else {
            LocalDateTime expire = (LocalDateTime) cacheData.get("expireTime");
            if (expire.isBefore(LocalDateTime.now())) {
                return false;
            } else {
                return true;
            }
        }

            

Reported by PMD.

litemall-db/src/test/java/org/linlinjava/litemall/db/DbConfigTest.java
4 issues
System.out.println is used
Design

Line: 21

              
    @Test
    public void test() {
        System.out.println(environment.getProperty("spring.datasource.druid.url"));
    }
}

            

Reported by PMD.

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

Line: 17

              @SpringBootTest
public class DbConfigTest {
    @Autowired
    Environment environment;

    @Test
    public void test() {
        System.out.println(environment.getProperty("spring.datasource.druid.url"));
    }

            

Reported by PMD.

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

Line: 20

                  Environment environment;

    @Test
    public void test() {
        System.out.println(environment.getProperty("spring.datasource.druid.url"));
    }
}

            

Reported by PMD.

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

Line: 8

              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-core/src/main/java/org/linlinjava/litemall/core/validator/SortValidator.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 10

              import java.util.List;

public class SortValidator implements ConstraintValidator<Sort, String> {
    private List<String> valueList;

    @Override
    public void initialize(Sort sort) {
        valueList = Lists.newArrayList();
        for (String val : sort.accepts()) {

            

Reported by PMD.

When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Error

Line: 16

                  public void initialize(Sort sort) {
        valueList = Lists.newArrayList();
        for (String val : sort.accepts()) {
            valueList.add(val.toUpperCase());
        }
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

            

Reported by PMD.

When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Error

Line: 22

              
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (!valueList.contains(s.toUpperCase())) {
            return false;
        }
        return true;
    }
}

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 22

              
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (!valueList.contains(s.toUpperCase())) {
            return false;
        }
        return true;
    }
}

            

Reported by PMD.

litemall-db/src/test/java/org/linlinjava/litemall/db/DbUtilTest.java
4 issues
JUnit tests should include assert() or fail()
Design

Line: 10

              
public class DbUtilTest {
    @Test
    public void testBackup() {
        File file = new File("test.sql");
        DbUtil.backup(file, "litemall", "litemall123456", "litemall");
    }

//    这个测试用例会重置litemall数据库,所以比较危险,请开发者注意

            

Reported by PMD.

The String literal 'litemall' appears 4 times in this file; the first occurrence is on line 12
Error

Line: 12

                  @Test
    public void testBackup() {
        File file = new File("test.sql");
        DbUtil.backup(file, "litemall", "litemall123456", "litemall");
    }

//    这个测试用例会重置litemall数据库,所以比较危险,请开发者注意
//    @Test
    public void testLoad() {

            

Reported by PMD.

Probable detached JUnit test case.
Error

Line: 17

              
//    这个测试用例会重置litemall数据库,所以比较危险,请开发者注意
//    @Test
    public void testLoad() {
        File file = new File("test.sql");
        DbUtil.load(file, "litemall", "litemall123456", "litemall");
    }
}

            

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

              
//    这个测试用例会重置litemall数据库,所以比较危险,请开发者注意
//    @Test
    public void testLoad() {
        File file = new File("test.sql");
        DbUtil.load(file, "litemall", "litemall123456", "litemall");
    }
}

            

Reported by PMD.

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

Line: 10

              import java.util.List;

public class OrderValidator implements ConstraintValidator<Order, String> {
    private List<String> valueList;

    @Override
    public void initialize(Order order) {
        valueList = Lists.newArrayList();
        for (String val : order.accepts()) {

            

Reported by PMD.

When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Error

Line: 16

                  public void initialize(Order order) {
        valueList = Lists.newArrayList();
        for (String val : order.accepts()) {
            valueList.add(val.toUpperCase());
        }
    }

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 22

              
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (!valueList.contains(s.toUpperCase())) {
            return false;
        }
        return true;
    }
}

            

Reported by PMD.

When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Error

Line: 22

              
    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if (!valueList.contains(s.toUpperCase())) {
            return false;
        }
        return true;
    }
}

            

Reported by PMD.