🛠️ 컨벤션 문서를 업데이트 중입니다.

🪜 Commit Message

기본적으로 Angular JS Git Commit Message Conventions를 따른다.

상세 메세지 내용은 한국어를 사용한다.

  • feat: 새로운 기능

  • fix: 버그를 수정

  • refactor: 이미 있는 코드에 대한 리팩토링

  • style: 코드 포매팅에 관한 스타일 변경

  • docs: Document 변경 사항

  • test: Test Code에 대한 commit

  • chore: 그 외의 작은 수정들


🖥️ Coding Convention

Test code Convention

테스트 작성 기준

  • F.I.R.S.T 원칙을 지킨다.

  • 단위테스트, 인수테스트, 문서화를 위한 테스트는 필수로 작성한다.

  • 인수테스트는 Given, When, Then 패턴을 따른다.

  • 인수테스트 작성시 공통된 로직은 xxSteps.kt 파일에 모아둔다.

  • 가급적 Mock 보단 Fake 객체를 활용한다.


Production code convention


Kotlin code Convention

bad

fun thisIsFunction(a: Int,
                   b: Long,
                   c: String): String {
    return ""
}

fun thisIsFunction(
        a: Int,
        b: Long,
        c: String): String {
    return ""
}

good

fun thisIsFunction(
        a: Int,
        b: Long,
        c: String
): String {
    return ""
}

parameter is in a separate line with indentation. Also, the closing parenthesis should be on a new line.

https://kotlinlang.org/docs/reference/coding-conventions.html#function-formatting

  • 매개 변수가 많은 경우 별도의 줄에서 들여쓰기를 한다. 또한 닫는 괄호도 새로운 줄에 있어야 한다.

  • 파라미터가 2개인 경우 파라미터의 개수를 기준으로 개행하는 것이 아니라, margin(120)을 기준으로 개행한다.

bad

fun thisIsFunction() = ""

fun thisIsFunction(): Unit {
}

good

fun thisIsFunction(): String {
    return ""
}

fun thisIsFunction() {
}

Always explicitly specify function return types and property types (to avoid accidentally changing the return type when the implementation changes)

https://kotlinlang.org/docs/reference/coding-conventions.html#coding-conventions-for-libraries


IDE에 Code style 적용하기

  • github에서 intellij-java-google-style.xml을 다운로드 합니다.

  • 인텔리제이 Preferences → Code Style → Scheme 옆 톱니바퀴 → Import Scheme 을 통해 사용 가능합니다.

  • Preferences → Code Style → Java 에서 직접 수정 가능합니다.