Skip to content

cognitive-complexity eslint plugin을 추가합니다#154

Open
keemhyunseok wants to merge 6 commits intomainfrom
feature/153
Open

cognitive-complexity eslint plugin을 추가합니다#154
keemhyunseok wants to merge 6 commits intomainfrom
feature/153

Conversation

@keemhyunseok
Copy link
Contributor

Related Issue

#153

Describe your changes

  • 기존 eslint-plugin-sonarjs는 복잡도 점수만 알려줌. 왜 복잡도가 높은지에 대한 정보가 부족
image
  • 왜 복잡도가 높은지에 대한 설명과 일부 패턴들에 대한 리펙토링 제안을하는 기능을 제공하는 lint로 확장
image
  • 다만 린트로 상시 활성화하기에는 ide에서 화면에 너무 많은 정보가 노출되기 때문에 두 확장기능을 옵션으로 제공
  • lint에서 제공하는 복잡도가 높은 이유, 리팩토링제안은 llm이 코드를 작성할 때 context로 활용하게하는 용도로 사용

keemhyunseok and others added 3 commits March 6, 2026 20:44
함수의 Cognitive Complexity가 임계값을 초과하면 라인별 점수 상세와
리팩토링 제안을 포함하여 보고하는 ESLint 룰을 추가합니다.

- SonarSource Cognitive Complexity 스펙 기반 점수 계산
- 라인별 점수 기여도 상세 (한글 안내)
- 6종 리팩토링 제안 (suggestions 옵션으로 활성화)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- README.md 규칙 테이블에 cognitive-complexity 항목 추가
- docs/cognitive-complexity.md 사용법 및 옵션 설명 문서 작성

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
점수 상세 표시를 breakdown 옵션으로 제어할 수 있도록 변경 (기본값: false)
@keemhyunseok keemhyunseok self-assigned this Mar 11, 2026
@keemhyunseok keemhyunseok requested a review from a team as a code owner March 11, 2026 12:08
@npayfebot
Copy link
Contributor

npayfebot commented Mar 11, 2026

✅ Changeset detected

Latest commit: cb37de6

@naverpay/eslint-plugin package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@naverpay/eslint-plugin 🐛 Patch
@naverpay/eslint-config 🐛 Patch
powered by: naverpay changeset detect-add actions

@keemhyunseok
Copy link
Contributor Author

@yceffort-naver 님 요거 카나리배포 가능한가요?

@yceffort-naver
Copy link
Contributor

/canary-publish

@yceffort-naver
Copy link
Contributor

세팅을 했었던 것 같은데 기억이 ㅋㅋㅋㅋ

@yceffort-naver
Copy link
Contributor

이거 제가 집가서 세팅하고 알려드릴게용😕

@keemhyunseok
Copy link
Contributor Author

ㅋㅋㅋ 감삼다

@yceffort-naver
Copy link
Contributor

/canary-publish

@npayfebot
Copy link
Contributor

Published Canary Packages

@naverpay/eslint-plugin@2.3.1-canary.260311-4046028

Comment on lines +61 to +88
switch (description) {
case 'if':
return 'if문'
case 'else if':
return 'else if문'
case 'else':
return 'else문'
case 'for':
return 'for문'
case 'for-in':
return 'for-in문'
case 'for-of':
return 'for-of문'
case 'while':
return 'while문'
case 'do-while':
return 'do-while문'
case 'switch':
return 'switch문'
case 'catch':
return 'catch문'
case 'ternary':
return '삼항 연산자'
case 'break to label':
return '라벨 break문'
case 'continue to label':
return '라벨 continue문'
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

요거 그냥 영어로 하시는건 어떄여?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

제가 디버깅하면서 편하게 보려고 한글로 했는데 어차피 주용도는 llm이 보는거니까.. context절약할겸 영어로 하는게 맞는거같습니다!!

91044d1

Choose a reason for hiding this comment

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

방금 말씀하신거 보니까 생각나는 논문이 있네요 ㅋㅋㅋ
https://arxiv.org/abs/2502.15603

  • 다국어 LLM은 입력/출력 언어와 무관하게, 내부적으로 영어 중심의 표현 공간에서 의미적 결정을 내린다.
  • LLM은 어떤 언어로 입력하든 내부적으로 영어로사고한다
  • 의미 있는 단어는 중간 레이어에서 영어로 먼저 선택된 뒤 마지막에 목표 언어로 변환 된다
  • 영어로 만든 벡터가 더 잘동작한다
  • 다국어 데이터를 많이 학습할수록 위 경향은 줄어들지만, 사라지지는 않는다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이제 영어는 모든 자연어의 어셈블리

Copy link
Contributor

Choose a reason for hiding this comment

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

네이티브 영어가 곧 권력이다

@yceffort-naver
Copy link
Contributor

function foo(a, b, c) {
      if (a) {
          return 1
      } else if (b) {
          if (c) {
              return 2
          }
      }
  }

이거는 4점 이맞죠? 현재 구현상으로는 3점이 될거같은데..

toKorean 변환 함수 제거 및 description 값을 그대로 노출하도록 수정
점수 상세 라벨(점수 상세 → Score breakdown), 중첩 표기(중첩 N단계 → nesting depth N) 영어 통일
sonarjs 스펙상 else if 자체는 nesting 증가 없지만,
else if body 내부 구문은 nesting+1 레벨에서 평가해야 함
@keemhyunseok
Copy link
Contributor Author

function foo(a, b, c) {
      if (a) {
          return 1
      } else if (b) {
          if (c) {
              return 2
          }
      }
  }

이거는 4점 이맞죠? 현재 구현상으로는 3점이 될거같은데..

sonarjs보니 4점이 맞네요,, 구현 버그가 있어서 수정했습니다

Copy link
Contributor

@yceffort-naver yceffort-naver left a comment

Choose a reason for hiding this comment

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

ㄱㄱㅅ

@keemhyunseok
Copy link
Contributor Author

테스트 좀만 해보고 머지하겠숩니다

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.

4 participants