[SonarQube][FindBugs] duplicating this literal, Stream.toList(), TODO, Unused "private" methods should be removed

This commit is contained in:
김현주
2025-07-21 15:47:38 +09:00
parent 0be90dc915
commit 3e1817a991
21 changed files with 70 additions and 74 deletions

View File

@@ -49,7 +49,7 @@ class GetNoticeDao implements GetNoticePortOut {
return uploadFile;
})
.collect(Collectors.toList()));
.toList());
return Optional.of(secArticle);
}

View File

@@ -1,6 +1,7 @@
package app.module.admin.usecase.communication.notice.getNotice.adapters.web;
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortIn;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
@@ -15,7 +16,7 @@ class GetNoticeController {
private final GetNoticePortIn getNoticePortIn;
@GetMapping(path = "/api/communication/notices/{id}")
ResponseEntity<?> operate(@PathVariable Long id) {
ResponseEntity<GetNotice> operate(@PathVariable Long id) {
return ResponseEntity.status(HttpStatus.OK)
.body(getNoticePortIn.operate(new GetNoticeCmd(id)).orElseThrow());
}

View File

@@ -29,6 +29,11 @@ public class FrontURIInterceptor implements HandlerInterceptor {
private final URIAncestryPortIn uriAncestryPortIn;
private final URITopTierPortIn topTierPortIn;
/**
* AttributeName: currentURI
*/
private static final String ATTR_NAME_URI = "currentURI";
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler)
@@ -47,7 +52,7 @@ public class FrontURIInterceptor implements HandlerInterceptor {
throw new NoMatchingURIException(String.format("매핑되는 않은 URI - %s", requestURI));
}
request.setAttribute("currentURI", currentURI);
request.setAttribute(ATTR_NAME_URI, currentURI);
return true;
}
@@ -69,8 +74,8 @@ public class FrontURIInterceptor implements HandlerInterceptor {
URITopTier topTierOutput = topTierPortIn.connect(AppType.FRONT);
modelAndView.addObject("topNode", recursiveMapping(topTierOutput));
if (modelAndView.getModelMap().getAttribute("currentURI") == null) {
modelAndView.addObject("currentURI", request.getAttribute("currentURI"));
if (modelAndView.getModelMap().getAttribute(ATTR_NAME_URI) == null) {
modelAndView.addObject(ATTR_NAME_URI, request.getAttribute(ATTR_NAME_URI));
}
modelAndView.addObject(
@@ -86,6 +91,6 @@ public class FrontURIInterceptor implements HandlerInterceptor {
output.getShowOnNavi(),
CollectionUtils.emptyIfNull(output.getChildren()).stream()
.map(this::recursiveMapping)
.collect(Collectors.toList()));
.toList());
}
}

View File

@@ -58,7 +58,7 @@ public class FrontDetailService implements UserDetailsService {
private Collection<? extends GrantedAuthority> getAuthorities(Collection<CoreRole> roles) {
return Stream.concat(getRoles(roles), getPrivileges(roles))
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toList());
.toList();
}
private Stream<String> getRoles(Collection<CoreRole> roles) {
@@ -70,17 +70,4 @@ public class FrontDetailService implements UserDetailsService {
.flatMap(roleOutput -> roleOutput.getPrivileges().stream())
.map(CorePrivilege::getId);
}
// 패스워드 만료 여부체크. 이 기능이 필요하지 않다면 항상 true 를 반환하도록 변경하면 된다.
private boolean isCredentialsNonExpired(LocalDateTime passwordUpdatedAt) {
// return passwordValidPeriodDays == -1
// || getDaysPassedFrom(passwordUpdatedAt) <= passwordValidPeriodDays;
return true;
}
// 패스워드 만료일 정보를 반환. 이 기능이 필요하지 않다면 항상 0L 을 반환하도록 변경하면 된다.
private long getDaysPassedFrom(LocalDateTime passwordUpdatedAt) {
// return Duration.between(passwordUpdatedAt, LocalDateTime.now()).toDays();
return 0L;
}
}

View File

@@ -8,19 +8,23 @@ import org.springframework.stereotype.Component;
@Component
public class AuthUtil {
public static Long getUserSeq() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return null;
private AuthUtil() {
throw new IllegalStateException("AuthUtil class");
}
Object principal = authentication.getPrincipal();
Long userseq = null;
public static Long getUserSeq() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return null;
}
if (principal instanceof UserDetails) {
userseq = ((FrontHouseholdUser) principal).getHouseholdSeq();
Object principal = authentication.getPrincipal();
Long userseq = null;
if (principal instanceof UserDetails) {
userseq = ((FrontHouseholdUser) principal).getHouseholdSeq();
}
return userseq;
}
return userseq;
}
}

View File

@@ -55,7 +55,7 @@ public class DailyExpenseController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyExpensePortIn.create(formVO);
@@ -85,7 +85,7 @@ public class DailyExpenseController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyExpensePortIn.remove(formVO);
@@ -107,7 +107,7 @@ public class DailyExpenseController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyExpensePortIn.remove(formVO);

View File

@@ -55,7 +55,7 @@ public class DailyFarmingController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyFarmingPortIn.create(formVO);
@@ -85,7 +85,7 @@ public class DailyFarmingController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyFarmingPortIn.remove(formVO);
@@ -107,7 +107,7 @@ public class DailyFarmingController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyFarmingPortIn.remove(formVO);

View File

@@ -55,7 +55,7 @@ public class DailyForestryController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyForestryPortIn.create(formVO);
@@ -85,7 +85,7 @@ public class DailyForestryController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyForestryPortIn.remove(formVO);
@@ -107,7 +107,7 @@ public class DailyForestryController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyForestryPortIn.remove(formVO);

View File

@@ -55,7 +55,7 @@ public class DailyIncomeController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyIncomePortIn.create(formVO);
@@ -85,7 +85,7 @@ public class DailyIncomeController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyIncomePortIn.remove(formVO);
@@ -107,7 +107,7 @@ public class DailyIncomeController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyIncomePortIn.remove(formVO);

View File

@@ -55,7 +55,7 @@ public class DailyPowerController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyPowerPortIn.create(formVO);
@@ -85,7 +85,7 @@ public class DailyPowerController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyPowerPortIn.remove(formVO);
@@ -107,7 +107,7 @@ public class DailyPowerController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyPowerPortIn.remove(formVO);

View File

@@ -56,7 +56,7 @@ public class DailyWorkController {
formVO.setGroupNo(Integer.parseInt(groupNo));
formVO.setId(Long.parseLong(id));
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("createFormVO: {}", formVO);
dailyWorkPortIn.create(formVO);
@@ -76,7 +76,7 @@ public class DailyWorkController {
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
, @Valid @RequestBody RemoveDailyWorkReqVO formVO, BindingResult bindingResult) {
safeLogger.debug("before formVO: {}", formVO);
safeLogger.debug("beforeFormVO: {}", formVO);
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
.body(bindingResult.getFieldErrors());
@@ -87,7 +87,7 @@ public class DailyWorkController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeFormVO: {}", formVO);
dailyWorkPortIn.remove(formVO);
@@ -110,7 +110,7 @@ public class DailyWorkController {
formVO.setSearchMonth(dailyRecord.getRecordMonth());
formVO.setGroupNo(dailyRecord.getGroupNo());
formVO.setDailyRecordSeq(dailyRecord.getId());
safeLogger.debug("formVO: {}", formVO);
safeLogger.debug("removeAllFormVO: {}", formVO);
dailyWorkPortIn.remove(formVO);

View File

@@ -50,7 +50,7 @@ class GetBanksDao implements GetBanksPortOut {
article.getCreatedBy(),
article.getUpdatedAt(),
article.getUpdatedBy()))
.collect(Collectors.toList()),
.toList(),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}

View File

@@ -31,7 +31,10 @@ import java.time.format.DateTimeFormatter;
@Controller
@RequiredArgsConstructor
class GetBankInputUIController {
/**
* 자동이체종류의 수입 코드
*/
public static final String BANK_INPUT_CODE = "code.bank.input";
private final GetPrevMonthlyInputStatusPortIn prevMonthlyInputStatusPortIn;
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
@@ -64,14 +67,14 @@ class GetBankInputUIController {
if (pastMonthlyInfo != null) {
pastList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.input"));
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(), BANK_INPUT_CODE));
}
Page<GetBanks> currentList = Page.empty();
if (currentMonthlyInfo != null) {
currentList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.input"));
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(), BANK_INPUT_CODE));
}
@@ -93,7 +96,7 @@ class GetBankInputUIController {
model.addAttribute("bankList", currentList);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.input"));
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect(BANK_INPUT_CODE));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("countList", uiCodeListPortIn.connect("code.count.unit"));
@@ -110,7 +113,7 @@ class GetBankInputUIController {
public String operateForm(Model model) {
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.input"));
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect(BANK_INPUT_CODE));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("countList", uiCodeListPortIn.connect("code.count.unit"));

View File

@@ -29,16 +29,16 @@ import java.time.format.DateTimeFormatter;
@Controller
@RequiredArgsConstructor
class GetBankOutputUIController {
/**
* 자동이체종류의 지출 코드
*/
public static final String BANK_OUTPUT_CODE = "code.bank.output";
private final GetPrevMonthlyInputStatusPortIn prevMonthlyInputStatusPortIn;
private final GetMonthlyInputStatusPortIn getMonthlyInputStatusPortIn;
private final GetBanksPortIn getBanksPortIn;
private final UICodeListPortIn uiCodeListPortIn;
@GetMapping(path = "/info/bank/create/output/{id}")
public String operate(Model model,
@PathVariable Long id
@@ -66,14 +66,14 @@ class GetBankOutputUIController {
if (pastMonthlyInfo != null) {
pastList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.output"));
new GetBanksCmd(pastMonthlyInfo.getId(), AuthUtil.getUserSeq(), BANK_OUTPUT_CODE));
}
Page<GetBanks> currentList = Page.empty();
if (currentMonthlyInfo != null) {
currentList = getBanksPortIn.operate(
pageable,
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(),"code.bank.output"));
new GetBanksCmd(currentMonthlyInfo.getId(), AuthUtil.getUserSeq(), BANK_OUTPUT_CODE));
}
@@ -95,7 +95,7 @@ class GetBankOutputUIController {
model.addAttribute("bankList", currentList);
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.output"));
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect(BANK_OUTPUT_CODE));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("countList", uiCodeListPortIn.connect("code.count.unit"));
@@ -110,7 +110,7 @@ class GetBankOutputUIController {
public String operateForm(Model model) {
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect("code.bank.output"));
model.addAttribute("transferCategoryList", uiCodeListPortIn.connect(BANK_OUTPUT_CODE));
model.addAttribute("codeRecordCropList", uiCodeListPortIn.connect("code.record.crop"));
model.addAttribute("countList", uiCodeListPortIn.connect("code.count.unit"));

View File

@@ -50,8 +50,6 @@ class GetBanksUIController {
.orElseThrow(() -> new NoSuchElementException("해당 월의 데이터가 없습니다."));
model.addAttribute("monthStatus", monthStatus);
// TODO 페키지명이 넘무 길어서 그냥
model.addAttribute("MonthStatus", MonthStatus.class);
return "info/bank/banks";

View File

@@ -44,7 +44,7 @@ class GetMonthlyInputStatussDao implements GetMonthlyInputStatussPortOut {
article.getUpdatedAt(),
article.getUpdatedBy()
))
.collect(Collectors.toList()),
.toList(),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}

View File

@@ -58,7 +58,7 @@ class GetForestProductsDao implements GetForestProductsPortOut {
article.getCreatedBy(),
article.getUpdatedAt(),
article.getUpdatedBy()))
.collect(Collectors.toList()),
.toList(),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}

View File

@@ -58,7 +58,7 @@ class GetMonthlyForestProductsDao implements GetMonthlyForestProductsPortOut {
article.getCreatedBy(),
article.getUpdatedAt(),
article.getUpdatedBy()))
.collect(Collectors.toList()),
.toList(),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}

View File

@@ -35,8 +35,6 @@ class GetMonthlysUIController {
reqVO.getSearchField(), reqVO.getSearchValue(), AuthUtil.getUserSeq()));
model.addAttribute("list", list);
// TODO 페키지명이 넘무 길어서 그냥
model.addAttribute("MonthStatus", MonthStatus.class);
return "info/monthly/monthlys";

View File

@@ -56,7 +56,7 @@ class GetNoticeDao implements GetNoticePortOut {
return uploadFile;
})
.collect(Collectors.toList()));
.toList());
return Optional.of(secArticle);
}

View File

@@ -38,7 +38,7 @@ class GetNoticesDao implements GetNoticesPortOut {
: ListUtils.emptyIfNull(
mapper.getUploadFiles(
contents.stream().map(GetNoticesDto::getId)
.collect(Collectors.toList()),
.toList(),
FileUploadType.NOTICE));
return new PageImpl<>(
@@ -60,7 +60,7 @@ class GetNoticesDao implements GetNoticesPortOut {
.filter(file -> file.getNoticeId().equals(article.getId()))
.findFirst()
.orElse(null)))
.collect(Collectors.toList()),
.toList(),
pageable,
contents.isEmpty() ? 0 : contents.get(0).getTotal());
}