Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step4 carracing #5541

Merged
merged 21 commits into from
Apr 18, 2024
Merged

Step4 carracing #5541

merged 21 commits into from
Apr 18, 2024

Conversation

rkaehdaos
Copy link

No description provided.

- 이전 study test depreacated 주석처리
- pmd로 ncss 15line 강제화
- jdk21 apply
- 기존 에
* 에러 정의 차이

리플렉션을 사용하여 생성자를 호출하면, 생성자 내부에서 발생하는 예외는 InvocationTargetException에 감싸져서 발생합니다. 이 때문에 예외가 직접적으로 UnsupportedOperationException가 아니라 InvocationTargetException으로 포착되는 것입니다.

* 최적화

* Car 상수 사용 및 보완

* formatting

* 가독성

* workflow 수정

* workflow 수정

* pmdtest4에 step4 넣음

* workflow에 pmd summary 추가

* 15라인 rule은 main 코드에만 ㅋㅋ

* Extract PMD info and update step summary

* test dependon pmdmain

* pmd 실패여도 진행

* xmllint 사용 제거

* 메시지 추출 부분 수정

* 일단 원복

* awk로 개선된 스크립트

설명
파일 처리:

awk를 사용하여 <file> 태그로 시작하고 </file> 태그로 끝나는 블록을 찾습니다. 이는 awk '/<file name=/,/<\/file>/' 명령으로 처리합니다.
파일 내부 처리:

awk 스크립트는 각 파일 블록을 처리하면서 파일 이름을 추출하고, 각 위반 사항의 정보를 파싱합니다.
파일 이름은 gensub() 함수를 사용하여 추출하고, 위반의 라인 번호, 메시지, URL을 추출하여 출력합니다.
Markdown 형식:

추출된 정보는 콘솔에 출력되고 pmd_summary.md 파일에 Markdown 형식으로 기록됩니다.
최종적으로, 이 Markdown 파일은 GitHub Actions 단계 요약에 추가됩니다.
장점
성능: awk는 스트림을 처리하면서 발생하는 데이터를 효율적으로 처리할 수 있으므로, 큰 XML 파일에 대해서도 성능상의 이점이 있습니다.
간결성: awk를 사용하면 복잡한 grep 및 sed 조합을 하나의 명령으로 대체할 수 있어 스크립트가 더욱 간결해집니다.
유지 관리: 스크립트가 간결해지므로 유지 관리가 용이해지며, 변경 사항을 적용하기 쉬워집니다.

* awk로 개선된 스크립트2 - 텍스트 한정

변경된 부분 설명
태그 내용 처리 로직: <violation> 태그를 만나면 내용 캡처를 시작하고, </violation> 태그를 만나면 내용 캡처를 종료하며, 그 사이에 있는 모든 텍스트를 content 변수에 누적합니다.
텍스트 출력: 최종적으로 각 violation의 설명이 content 변수에 저장되고, 이를 Markdown 링크의 텍스트로 사용하여 출력합니다.
이 수정을 통해 PMD 요약 정보에는 각 violation의 상세 설명이 <violation> 태그 사이의 텍스트로 정확히 제공됩니다. 이 방법은 XML 데이터에서 필요한 정보만을 추출하여 보다 명확하고 유용한 요약을 생성하는 데 도움이 됩니다.

* message 수정

* workflow-PR 생성

* NCSS 5->15

* NCSS 5->15

* NCSS 15->5

* README.md 수정

* onPRTest

* onPRTest -             $GITHUB_STEP_SUMMARY

* onPRTest

* Comment SUMMARY Report on PR body check

* body-path: 'PR_summary.md'

* body-path: 'PR_summary.md'

* PUSH_summary.md 에 모으기

* PR_summary.md 에 total count 추가

* push workflow는 pr이 있으면 작동하지 않음

* pr workflow type 지정

* PR시에는 build task

* github.event.pull_request삭제 - pr workflow에서만 true 가능

* types 가독성

* graalvm 적용

* 정리

* 언어 정리

* pmd pmdtest는 전부 제외, pmdmin은 step4만

* 메서드라인은 15라인

* 문제가 없을시 pmd report 요약 액션 에러 수정

* push workflow - 문제가 없을시 pmd report 요약 액션 에러 수정

* PR 멈추기

* push test

* push test2

* error 수정: branches-ignore: ['*']

* total_violations 출력 수정

* 극단적 test

* 극단적 test2

* 극단적 test3

* PMD 리포트 요약 복원

* grep 명령 실패 허용

* jacoco summary 지워지는 거 방지

* PR workflow 활성화

---------

Co-authored-by: GeunChang Ahn <[email protected]>
* psvm 클래스 rename

* 패키지 이동

* 메서드명 변경

* CarRacingRunner 생성

* 단일책임 원칙

---------

Co-authored-by: GeunChang Ahn <[email protected]>
@rkaehdaos rkaehdaos closed this Apr 17, 2024
* conflict ㅎㅐ결

* RandomMovingStrategy 작성

* stragegy 패턴 적용

* 포맷팅
@rkaehdaos rkaehdaos reopened this Apr 17, 2024
@neojjc2 neojjc2 self-requested a review April 18, 2024 05:08
@neojjc2 neojjc2 self-assigned this Apr 18, 2024
@neojjc2
Copy link

neojjc2 commented Apr 18, 2024

#tag @neojjc2

Copy link

@neojjc2 neojjc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 근창님 🙇

4단계도 무난하게 잘 구현 해주셨습니다 💯
소소한 의견 몇 가지 드렸는데요,
마지막 단계 진행하시면서 수정 검토 해주시면 좋을 것 같네요 😄

이제 어느덧 마지막 단계만 남았습니다.
조금만 더 힘내 주세요 🙏

- [x] 단일 책임 원칙으로 메서드가 되어 있는지 확인
- [ ] 모든 로직에 단위 테스트 구현 - UI 제외
- [x] UI를 `InputView`, `ResultView`로 분리
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요구사항 및 체크사항 좋습니다 💯

// init
InputView inputView = new InputView(new Scanner(System.in));
ResultView resultView = new ResultView();
CarRacingRunner carRacingRunner = new CarRacingRunner(inputView, resultView);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미 main이 있기 때문에 CarRacingRunnerinputView, resultView에 대한 의존성을 가져갈 필요는 없을 것 같습니다 🙇

this.name = inputName;
}

public void move(MovingStrategy movingStrategy) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 💯 💯 💯 💯

private int distance = MIN_DISTANCE;
private final String name;

public Car(String inputName) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

검증 잘 해주셨습니다 👍


public class RandomMovingStrategy implements MovingStrategy {

private final Random random = new Random();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private final Random random = new Random();
private static final Random RANDOM = new Random();

@@ -0,0 +1,5 @@
package step4_winner.strategy;

public interface MovingStrategy {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FunctionalInterface가 붙여지면 더 좋을 것 같습니다 🙏
이 부분은 한번 참고만 해주시면 좋을 것 같아요.

https://tecoble.techcourse.co.kr/post/2020-07-17-Functional-Interface/

String winners = cars.stream()
.filter(car -> car.getDistance() == maxDistance)
.map(Car::getName)
.collect(Collectors.joining(", "));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요구사항 구현 잘 해주셨습니다 👍
소소한 의견이긴 한데 우승자를 구하는 핵심비즈니스 로직이 ResultView에 있는게
약간 아쉽긴 하네요 😄
뭔가 레이싱의 경기 결과를 담당하는 도메인이 생기고 그 쪽으로 위임해보시면 어떨까요??
의견 드려 봅니다 🙇

assertThat(anyCarMoved).isTrue();
}

}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트 꼼꼼하게 작성 잘 해주셨습니다 💯

@neojjc2 neojjc2 merged commit d1ae780 into next-step:rkaehdaos Apr 18, 2024
2 checks passed
@rkaehdaos rkaehdaos deleted the step4_carracing branch April 19, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants