Commit 478d6132 authored by DeleMing's avatar DeleMing

<dev>

1. 修复当日志路径为“日期/系统简称/日志”这中格式时,启动脱敏任务失败
parent 0c577ddd
Pipeline #21878 passed with stages
in 2 minutes and 40 seconds
......@@ -24,7 +24,6 @@ import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobConf;
......@@ -104,7 +103,7 @@ public class HdfsLogDesensitization implements Serializable {
* @param hdfsUser hfs用户名 eg: hdfs
* @return hdfs日志文件的所有文件路径
*/
private List<String> filterHdfsLogFiles(String hdfsSrc, String hdfsUri, String hdfsUser) {
public List<String> filterHdfsLogFiles(String hdfsSrc, String hdfsUri, String hdfsUser) {
  • 🚫 Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. 📘

Please register or sign in to reply
if (!hdfsSrc.endsWith(GeneralConstants.FILE_SEPARATOR)) {
hdfsSrc += GeneralConstants.FILE_SEPARATOR;
}
......@@ -146,7 +145,6 @@ public class HdfsLogDesensitization implements Serializable {
} else {
log.warn("{} -- {} 时间段内无数据,请注意时间范围", jobConfig.getStartTime(), jobConfig.getEndTime());
}
return logFiles;
}
......
package com.zorkdata.desensitization.hadoop;
import com.alibaba.fastjson.JSON;
import com.zorkdata.desensitization.config.JobConfig;
import com.zorkdata.desensitization.config.JobInitConfig;
import com.zorkdata.desensitization.utils.YmlUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import java.util.List;
import java.util.Map;
/**
* @author: LiaoMingtao
* @date: 2021/3/9
*/
@Slf4j
public class HdfsLogDesensitizationTest {
@Test
public void filterHdfsLogFiles() throws Exception {
  • Define and throw a dedicated exception instead of using a generic one. 📘

Please register or sign in to reply
String[] args = new String[]{"--conf", "E:\\Codes\\fork\\transaction-log-desensitization\\src\\main\\resources\\application.yml"};
Map<String, String> conf = YmlUtils.getParams(args);
JobInitConfig jobInitConfig = new JobInitConfig(conf);
JobConfig jobConfig = new JobConfig(jobInitConfig);
HdfsLogDesensitization hdfsLogDesensitization = new HdfsLogDesensitization().initJobConfig(jobConfig);
List<String> strings = hdfsLogDesensitization
.filterHdfsLogFiles(jobConfig.getHdfsSrc(), jobConfig.getHdfsUri(), jobConfig.getHdfsUser());
log.info(JSON.toJSONString(strings));
}
}
\ No newline at end of file
  • SonarQube analysis reported 193 issues

    • 4 blocker
    • 🚫 34 critical
    • 132 major
    • 🔽 20 minor
    • 3 info

    Watch the comments in this conversation to review them.

    Top 30 extra issues

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. Remove this hard-coded password. 📘
    2. Remove this hard-coded password. 📘
    3. Remove this hard-coded password. 📘
    4. Remove this hard-coded password. 📘
    5. 🚫 Define a constant instead of duplicating this literal " {\n" 11 times. 📘
    6. 🚫 [Define a constant instead of duplicating this literal " "type": \n" 11 times. 📘
    7. 🚫 Define a constant instead of duplicating this literal " "string",\n" 6 times. 📘
    8. 🚫 Define a constant instead of duplicating this literal " "null"\n" 6 times. 📘
    9. 🚫 [Define a constant instead of duplicating this literal " ]\n" 11 times.](https://git.zorkdata.com/liaomingtao/transaction-log-desensitization/blob/478d61326d82e8a51c119d3992707d6671a3d7e0/src/main/java/com/zorkdata/desensitization/avro/AvroSchemaDef.java#L23) 📘
    10. 🚫 Define a constant instead of duplicating this literal " },\n" 9 times. 📘
    11. 🚫 Define a constant instead of duplicating this literal " "null",\n" 5 times. 📘
    12. 🚫 Define a constant instead of duplicating this literal " {\n" 5 times. 📘
    13. 🚫 Define a constant instead of duplicating this literal " "type": "map",\n" 5 times. 📘
    14. 🚫 Define a constant instead of duplicating this literal " "values": "string"\n" 3 times. 📘
    15. 🚫 Define a constant instead of duplicating this literal " }\n" 5 times. 📘
    16. 🚫 Define a constant instead of duplicating this literal "序列化失败" 13 times. 📘
    17. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    18. 🚫 Refactor this method to reduce its Cognitive Complexity from 145 to the 15 allowed. 📘
    19. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    20. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    21. 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘
    22. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    23. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    24. 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘
    25. 🚫 Define a constant instead of duplicating this literal "jobName" 6 times. 📘
    26. 🚫 Define a constant instead of duplicating this literal "2020-11-07 21:22:20" 6 times. 📘
    27. 🚫 Define a constant instead of duplicating this literal "2020-11-07 23:40:30" 6 times. 📘
    28. 🚫 Define a constant instead of duplicating this literal "YYYYMMDD-*** NodeId=, QueueId=, MsgId=*******************, Len=," 3 times. 📘
    29. 🚫 Define a constant instead of duplicating this literal "netaddr,telno,mobileno,faxno,hometelno,worktelno,fax,mobil,call" 6 times. 📘
    30. 🚫 Define a constant instead of duplicating this literal "email" 3 times. 📘
    • ... 161 more
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment