Skip to content

Commit

Permalink
Merge pull request #178 from power4j/feature/lint
Browse files Browse the repository at this point in the history
fix lint warning
  • Loading branch information
John-Chan authored Sep 5, 2023
2 parents 32f7516 + 9360085 commit 6d86e81
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.power4j.fist.boot.mybaits.crud.repository.matcher.Eq;
import com.power4j.fist.data.crud.repository.PagingAndSortingRepository;
import com.power4j.fist.data.domain.Pageable;
import com.power4j.fist.data.domain.Paged;
import com.power4j.fist.boot.mybaits.crud.repository.matcher.Eq;
import org.springframework.lang.Nullable;

import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ public void markUserAttr() {
* @return true 表示是系统数据
*/
public boolean checkSysAttr() {
return Objects.nonNull(lowAttr) && DataConstant.LOW_ATTR_VALUE_SYSTEM == lowAttr;
return Objects.equals(DataConstant.LOW_ATTR_VALUE_SYSTEM, lowAttr);
}

/**
* 检测是否用户数据
* @return true 表示是用户数据
*/
public boolean checkUserAttr() {
return Objects.nonNull(lowAttr) && DataConstant.LOW_ATTR_VALUE_USER == lowAttr;
return Objects.equals(DataConstant.LOW_ATTR_VALUE_USER, lowAttr);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package com.power4j.fist.boot.mybaits.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.power4j.fist.data.constant.DataConstant;
import com.power4j.fist.boot.mybaits.entity.AuditEntity;
import com.power4j.fist.boot.security.core.UserInfo;
import com.power4j.fist.boot.security.core.UserInfoSupplier;
import com.power4j.fist.data.constant.DataConstant;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.power4j.fist.boot.mybaits.tenant;

import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.power4j.fist.data.tenant.isolation.TenantHolder;
import com.power4j.fist.boot.security.core.SecurityConstant;
import com.power4j.fist.data.tenant.isolation.TenantHolder;
import lombok.Setter;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public static <T> PageData<T> of(Paged<T> paged) {
}

public static <T> PageData<T> of(PageDTO<T> dto) {
return new PageData(dto.getContent(), dto.getTotal(), dto.getHasNext(), dto.getPageNumber(), dto.getPageSize());
return new PageData<>(dto.getContent(), dto.getTotal(), dto.getHasNext(), dto.getPageNumber(),
dto.getPageSize());
}

public static <T> PageDTO<T> toPageDTO(PageData<T> src) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package com.power4j.fist.data.tenant;

import com.power4j.fist.data.tenant.annotation.InTenant;
import com.power4j.fist.data.tenant.isolation.TenantBroker;
import com.power4j.fist.support.spring.aop.AopUtil;
import com.power4j.fist.support.spring.spel.MethodParameterResolver;
import com.power4j.fist.support.spring.spel.SpringElUtil;
import com.power4j.fist.data.tenant.annotation.InTenant;
import com.power4j.fist.data.tenant.isolation.TenantBroker;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.util.Locale;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -54,14 +54,13 @@ private static ResourceBundleMessageSource getMessageSource() {
*/
public static <T> Set<ConstraintViolation<T>> check(T object, Class<?>... groups) {
Locale.setDefault(LocaleContextHolder.getLocale());
Validator validator = Validation.byDefaultProvider()
try (ValidatorFactory validatorFactory = Validation.byDefaultProvider()
.configure()
.messageInterpolator(
new ResourceBundleMessageInterpolator(new MessageSourceResourceBundleLocator(getMessageSource())))
.buildValidatorFactory()
.getValidator();

return validator.validate(object, groups);
.buildValidatorFactory()) {
return validatorFactory.getValidator().validate(object, groups);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.power4j.fist.autoconfigure.security;

import com.power4j.coca.kit.common.exception.RuntimeFaultException;
import com.power4j.fist.boot.security.config.ResourceServerSecurityConfig;
import com.power4j.fist.boot.security.config.JwtTokenExtractor;
import com.power4j.fist.boot.security.config.ResourceServerConfig;
import com.power4j.fist.boot.security.config.ResourceServerSecurityConfig;
import com.power4j.fist.boot.security.config.SecurityProperties;
import com.power4j.fist.boot.security.oauth2.AuthUserConverter;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* @author CJ ([email protected])
* @date 2022/3/7
Expand All @@ -37,4 +35,4 @@ void encode() {
Assertions.assertTrue(matched);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.power4j.fist.boot.autoconfigure.web;

import com.power4j.fist.boot.web.constant.HttpConstant;
import com.power4j.fist.boot.mon.info.TraceInfo;
import com.power4j.fist.boot.mon.info.TraceInfoResolver;
import com.power4j.fist.boot.web.constant.HttpConstant;
import com.power4j.fist.boot.web.servlet.mvc.formatter.LocalDateFormatter;
import com.power4j.fist.boot.web.servlet.mvc.formatter.LocalDateTimeFormatter;
import com.power4j.fist.boot.web.servlet.mvc.formatter.LocalTimeFormatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RejectedException extends RuntimeException {
@Nullable

Check notice on line 36 in fist-kit-app/fist-web/fist-support-web/src/main/java/com/power4j/fist/boot/common/error/RejectedException.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

@NotNull/@Nullable problems

The generated code will use '@org.jetbrains.annotations.Nullable' instead of '@org.springframework.lang.Nullable'
private final String hint;

private HttpStatus status = HttpStatus.OK;
private HttpStatus status;

/**
* 构造函数,不会进行国际化处理
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package com.power4j.fist.boot.mon.annotation;

import org.springframework.core.annotation.AliasFor;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;

/**
* @author CJ ([email protected])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.power4j.coca.kit.common.datetime.DateTimeKit;
import com.power4j.coca.kit.common.lang.Result;
import com.power4j.coca.kit.common.text.StringPool;
import com.power4j.fist.support.spring.aop.AopUtil;
import com.power4j.fist.boot.mon.ApiDescriptionResolver;
import com.power4j.fist.boot.mon.EventUtils;
import com.power4j.fist.boot.mon.annotation.ApiLog;
Expand All @@ -30,6 +29,7 @@
import com.power4j.fist.boot.mon.info.ExceptionTranslator;
import com.power4j.fist.boot.mon.info.HttpRequestInfo;
import com.power4j.fist.boot.security.core.UserInfoAccessor;
import com.power4j.fist.support.spring.aop.AopUtil;
import com.power4j.fist.support.spring.util.SpringEventUtil;
import com.power4j.fist.support.spring.web.servlet.util.HttpServletRequestUtil;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package com.power4j.fist.boot.mon.aspect;

import com.power4j.coca.kit.common.text.StringPool;
import com.power4j.fist.boot.mon.EventUtils;
import com.power4j.fist.boot.mon.annotation.ReportError;
import com.power4j.fist.support.spring.aop.AopUtil;
import com.power4j.fist.support.spring.spel.MethodParameterResolver;
import com.power4j.fist.support.spring.spel.SpringElUtil;
import com.power4j.fist.boot.mon.EventUtils;
import com.power4j.fist.boot.mon.annotation.ReportError;
import com.power4j.fist.support.spring.util.SpringEventUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import com.power4j.fist.boot.mon.info.InfoUtil;
import com.power4j.fist.boot.mon.info.TraceInfo;
import com.power4j.fist.boot.mon.info.TraceInfoResolver;
import com.power4j.fist.support.spring.util.ApplicationContextHolder;
import com.power4j.fist.support.spring.util.SpringEventUtil;
import com.power4j.fist.boot.web.event.error.HandlerErrorEvent;
import com.power4j.fist.boot.web.event.error.RequestInfo;
import com.power4j.fist.support.spring.util.ApplicationContextHolder;
import com.power4j.fist.support.spring.util.SpringEventUtil;
import com.power4j.fist.support.spring.web.servlet.util.HttpServletRequestUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Path;
import javax.validation.ValidationException;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -99,7 +98,7 @@ public Result<Object> handleException(BindException e) {
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Result<Object> handleException(ConstraintViolationException e) {
ConstraintViolation<?> violation = e.getConstraintViolations().iterator().next();
String path = ((Path) violation.getPropertyPath()).toString();
String path = violation.getPropertyPath().toString();
log.warn("请求参数校验失败:{}", path);
return Results.requestParameterError(violation.getMessage(), path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.power4j.fist.boot.common.error.ErrorCode;
import com.power4j.fist.support.spring.web.reactive.util.ServerHttpResponseUtil;
import com.power4j.fist.cloud.gateway.authorization.domain.AuthProblem;
import com.power4j.fist.support.spring.web.reactive.util.ServerHttpResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.reactive.ServerHttpResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import java.util.List;
Expand Down Expand Up @@ -157,7 +156,7 @@ public UserPermissionFilter userPermissionFilter() {
}

@Bean
@Order(Ordered.LOWEST_PRECEDENCE)
@Order
public AuthEndFilter authEndFilter() {
return new AuthEndFilter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package com.power4j.fist.cloud.gateway.authorization.filter.reactive.impl;

import com.power4j.fist.cloud.gateway.authorization.domain.AuthContext;
import com.power4j.fist.security.core.authorization.domain.AuthenticatedUser;
import com.power4j.fist.cloud.gateway.authorization.filter.reactive.GatewayAuthFilter;
import com.power4j.fist.security.core.authorization.service.reactive.UserService;
import com.power4j.fist.security.core.authorization.domain.AuthenticatedUser;
import com.power4j.fist.security.core.authorization.filter.reactive.ServerAuthFilterChain;
import com.power4j.fist.security.core.authorization.service.reactive.UserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Mono;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
@NonNullApi
@NonNullFields
package com.power4j.fist.cloud.gateway.authorization;
package com.power4j.fist.cloud.gateway;

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
import org.springframework.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ServerHttpRequestUtil {
*/
public Optional<String> getRemoteIp(ServerHttpRequest request) {
Optional<String> ip = HttpServletRequestUtil.getRemoteIp(request.getHeaders());
if (!ip.isPresent()) {
if (ip.isEmpty()) {
ip = Optional.ofNullable(request.getRemoteAddress())
.map(InetSocketAddress::getAddress)
.map(InetAddress::getHostAddress);
Expand Down

0 comments on commit 6d86e81

Please sign in to comment.