Starrier/commons

View on GitHub

Showing 59 of 59 total issues

Method getIpAddress has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

public static String getIpAddress(HttpServletRequest request) {
String ip = request.getHeader(X_FORWARDED_FOR);
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader(PROXY_CLIENT_IP);
Severity: Minor
Found in src/main/java/org/starrier/common/utils/HttpUtils.java - About 3 hrs to fix

DateUtils has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

public class DateUtils implements Converter<String, Date> {
 
public static final String FULL_TIME_PATTERN = "yyyyMMddHHmmss";
public static final String FULL_TIME_SPLIT_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final String CST_TIME_PATTERN = "EEE MMM dd HH:mm:ss zzz yyyy";
Severity: Minor
Found in src/main/java/org/starrier/common/utils/DateUtils.java - About 2 hrs to fix

    JacksonUtils has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class JacksonUtils {
     
    private static final Logger LOGGER = LoggerFactory.getLogger(JacksonUtils.class);
     
    /**
    Severity: Minor
    Found in src/main/java/org/starrier/common/utils/json/JacksonUtils.java - About 2 hrs to fix

      Method parseStringToLong has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      @ExceptionZero
      public static long parseStringToLong(String dateStr) {
      dateStr = dateStr.trim();
      Calendar cal = Calendar.getInstance();
      if (dateStr.length() == 19 || dateStr.length() == 23) {
      Severity: Minor
      Found in src/main/java/org/starrier/common/utils/DateUtils.java - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        if (dateStr.length() == 19 || dateStr.length() == 23) {
         
        cal.set(Integer.parseInt(dateStr.substring(0, 4)),
        Integer.parseInt(dateStr.substring(5, 7)) - 1,
        Integer.parseInt(dateStr.substring(8, 10)),
        Severity: Major
        Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
        src/main/java/org/starrier/common/utils/DateUtils.java on lines 266..275

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        } else if (dateStr.length() == 14) {
        cal.set(Integer.parseInt(dateStr.substring(0, 4)),
        Integer.parseInt(dateStr.substring(4, 6)) - 1,
        Integer.parseInt(dateStr.substring(6, 8)),
        Integer.parseInt(dateStr.substring(8, 10)),
        Severity: Major
        Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
        src/main/java/org/starrier/common/utils/DateUtils.java on lines 248..258

        Method checkSensitiveWord has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        private static int checkSensitiveWord(String txt, int beginIndex, int matchType) {
        //敏感词结束标识位:用于敏感词只有1位的情况
        boolean flag = false;
        //匹配标识数默认为0
        int matchFlag = 0;
        Severity: Minor
        Found in src/main/java/org/starrier/common/utils/SensitiveWordUtil.java - About 1 hr to fix

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        private static class Builder {
        private Integer code;
        private String message;
        private String url;
        private Object data;
        src/main/java/org/starrier/common/result/Result.java on lines 133..162

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

        private static class Builder {
        private Integer code;
        private String message;
        private String url;
        private Object data;
        Severity: Major
        Found in src/main/java/org/starrier/common/result/Result.java and 1 other location - About 1 hr to fix
        src/main/java/org/starrier/common/result/ReactiveResult.java on lines 129..158

        Method handleLimit has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        @Around("@annotation(LoginLimit)")
        public Object handleLimit(ProceedingJoinPoint joinPoint) {
         
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        final Method method = methodSignature.getMethod();

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          public static long getDayStartTime(String date) {
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(parseStringToLong(date));
          cal.set(Calendar.HOUR_OF_DAY, 0);
          cal.set(Calendar.SECOND, 0);
          Severity: Major
          Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
          src/main/java/org/starrier/common/utils/DateUtils.java on lines 211..219

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          public static long getDayEndTime(String date) {
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(parseStringToLong(date));
          cal.set(Calendar.HOUR_OF_DAY, 23);
          cal.set(Calendar.SECOND, 59);
          Severity: Major
          Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
          src/main/java/org/starrier/common/utils/DateUtils.java on lines 193..201

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          } else if (dateStr.length() == 8) {
          cal.set(Integer.parseInt(dateStr.substring(0, 4)),
          Integer.parseInt(dateStr.substring(4, 6)) - 1,
          Integer.parseInt(dateStr.substring(6, 8)), 0, 0, 0);
          cal.set(Calendar.MILLISECOND, 0);
          Severity: Major
          Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
          src/main/java/org/starrier/common/utils/DateUtils.java on lines 275..281

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          } else if (dateStr.length() == 10 || dateStr.length() == 11) {
          cal.set(Integer.parseInt(dateStr.substring(0, 4)),
          Integer.parseInt(dateStr.substring(5, 7)) - 1,
          Integer.parseInt(dateStr.substring(8, 10)), 0, 0, 0);
          cal.set(Calendar.MILLISECOND, 0);
          Severity: Major
          Found in src/main/java/org/starrier/common/utils/DateUtils.java and 1 other location - About 1 hr to fix
          src/main/java/org/starrier/common/utils/DateUtils.java on lines 281..287

          Method initSensitiveWordMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          @SuppressWarnings({"rawtypes", "unchecked"})
          private static void initSensitiveWordMap(Set<String> sensitiveWordSet) {
          //初始化敏感词容器,减少扩容操作
          sensitiveWordMap = new HashMap<>(sensitiveWordSet.size());
          String key;
          Severity: Minor
          Found in src/main/java/org/starrier/common/utils/SensitiveWordUtil.java - About 1 hr to fix

          Method getIpAddress has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          public static String getIpAddress(HttpServletRequest request) {
          String ip = request.getHeader("x-forwarded-for");
           
          if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
          ip = request.getHeader("Proxy-Client-IP");
          Severity: Minor
          Found in src/main/java/org/starrier/common/utils/IpUtil.java - About 1 hr to fix

          Method getIpAddress has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          public static String getIpAddress(HttpServletRequest request) {
          String ip = request.getHeader(X_FORWARDED_FOR);
          if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
          if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
          ip = request.getHeader(PROXY_CLIENT_IP);
          Severity: Minor
          Found in src/main/java/org/starrier/common/utils/HttpUtils.java - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            private static Date plusOrMinusDays(Date date, int days, Integer type) {
            if (null == date) {
            return null;
            }
             
             
            Severity: Major
            Found in src/main/java/org/starrier/common/utils/JodaTimeUtil.java and 1 other location - About 1 hr to fix
            src/main/java/org/starrier/common/utils/JodaTimeUtil.java on lines 258..271

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            private static Date plusOrMinusMonths(Date date, int months, Integer type) {
            if (null == date) {
            return null;
            }
             
             
            Severity: Major
            Found in src/main/java/org/starrier/common/utils/JodaTimeUtil.java and 1 other location - About 1 hr to fix
            src/main/java/org/starrier/common/utils/JodaTimeUtil.java on lines 163..176

            Method pressText has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            public static void pressText(String pressText, String targetImage, String fontName, Integer fontStyle,
            Color color, Integer fontSize, Integer x, Integer y) {
            Severity: Major
            Found in src/main/java/org/starrier/common/picture/WaterMarkUtils.java - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language