The following issues were found

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

Line: 12

              @Configuration
public class CorsConfig {
    // 当前跨域请求最大有效时长。这里默认30天
    private long maxAge = 30 * 24 * 60 * 60;

    private CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
        corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头

            

Reported by PMD.

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

Line: 12

              @Configuration
public class CorsConfig {
    // 当前跨域请求最大有效时长。这里默认30天
    private long maxAge = 30 * 24 * 60 * 60;

    private CorsConfiguration buildConfig() {
        CorsConfiguration corsConfiguration = new CorsConfiguration();
        corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址
        corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头

            

Reported by PMD.

litemall-all/src/main/java/org/linlinjava/litemall/Application.java
2 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: 13

              @MapperScan("org.linlinjava.litemall.db.dao")
@EnableTransactionManagement
@EnableScheduling
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }


            

Reported by PMD.

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

Line: 15

              @EnableScheduling
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}
            

Reported by PMD.

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

Line: 15

              @SpringBootTest
public class DbTest {
    @Test
    public void test() {
    }

}

            

Reported by PMD.

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

Line: 6

              import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
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-db/src/test/java/org/linlinjava/litemall/db/MapperReturnTest.java
2 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 20

              public class MapperReturnTest {

    @Autowired
    private LitemallSystemMapper systemMapper;

    @Test
    public void test() {
        LitemallSystem system = new LitemallSystem();
        system.setKeyName("test-system-key");

            

Reported by PMD.

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

Line: 10

              import org.linlinjava.litemall.db.domain.LitemallSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
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/annotation/support/LoginUserHandlerMethodArgumentResolver.java
2 issues
Potential violation of Law of Demeter (method chain calls)
Design

Line: 17

              
    @Override
    public boolean supportsParameter(MethodParameter parameter) {
        return parameter.getParameterType().isAssignableFrom(Integer.class) && parameter.hasParameterAnnotation(LoginUser.class);
    }

    @Override
    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container,
                                  NativeWebRequest request, WebDataBinderFactory factory) throws Exception {

            

Reported by PMD.

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

Line: 26

              
//        return new Integer(1);
        String token = request.getHeader(LOGIN_TOKEN_KEY);
        if (token == null || token.isEmpty()) {
            return null;
        }

        return UserTokenManager.getUserId(token);
    }

            

Reported by PMD.

litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/config/ShiroExceptionHandler.java
2 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 18

              @Order(value = Ordered.HIGHEST_PRECEDENCE)
public class ShiroExceptionHandler {

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

    @ExceptionHandler(AuthenticationException.class)
    @ResponseBody
    public Object unauthenticatedHandler(AuthenticationException e) {
        logger.warn(e.getMessage(), e);

            

Reported by PMD.

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

Line: 18

              @Order(value = Ordered.HIGHEST_PRECEDENCE)
public class ShiroExceptionHandler {

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

    @ExceptionHandler(AuthenticationException.class)
    @ResponseBody
    public Object unauthenticatedHandler(AuthenticationException e) {
        logger.warn(e.getMessage(), e);

            

Reported by PMD.

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

Line: 16

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

    /**
     * 测试数据
     *
     * @return 测试数据

            

Reported by PMD.

Avoid unused private fields such as 'logger'.
Design

Line: 16

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

    /**
     * 测试数据
     *
     * @return 测试数据

            

Reported by PMD.

litemall-db/src/main/java/org/linlinjava/litemall/db/dao/LitemallUserMapper.java
2 issues
This class has too many methods, consider refactoring it.
Design

Line: 8

              import org.linlinjava.litemall.db.domain.LitemallUser;
import org.linlinjava.litemall.db.domain.LitemallUserExample;

public interface LitemallUserMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_user
     *
     * @mbg.generated

            

Reported by PMD.

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

Line: 63

                   *
     * @mbg.generated
     */
    LitemallUser selectOneByExampleSelective(@Param("example") LitemallUserExample example, @Param("selective") LitemallUser.Column ... selective);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_user
     *

            

Reported by PMD.

litemall-db/src/main/java/org/linlinjava/litemall/db/dao/LitemallTopicMapper.java
2 issues
This class has too many methods, consider refactoring it.
Design

Line: 8

              import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.domain.LitemallTopicExample;

public interface LitemallTopicMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_topic
     *
     * @mbg.generated

            

Reported by PMD.

The String literal 'example' appears 6 times in this file; the first occurrence is on line 63
Error

Line: 63

                   *
     * @mbg.generated
     */
    LitemallTopic selectOneByExampleSelective(@Param("example") LitemallTopicExample example, @Param("selective") LitemallTopic.Column ... selective);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_topic
     *

            

Reported by PMD.

litemall-db/src/main/java/org/linlinjava/litemall/db/dao/LitemallSystemMapper.java
2 issues
This class has too many methods, consider refactoring it.
Design

Line: 8

              import org.linlinjava.litemall.db.domain.LitemallSystem;
import org.linlinjava.litemall.db.domain.LitemallSystemExample;

public interface LitemallSystemMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_system
     *
     * @mbg.generated

            

Reported by PMD.

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

Line: 63

                   *
     * @mbg.generated
     */
    LitemallSystem selectOneByExampleSelective(@Param("example") LitemallSystemExample example, @Param("selective") LitemallSystem.Column ... selective);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table litemall_system
     *

            

Reported by PMD.