소프트웨어 공학에서 메트릭(metric)은 측정 척도와 측정 방법을 함께 정한 것이다.[1][2] ISO/IEC/IEEE 24765 용어집은 품질 메트릭(quality metric)을, 어떤 항목이 주어진 품질 속성을 갖는 정도를 정량적으로 나타낸 척도로 정의한다. 소프트웨어 데이터를 받아 그 정도로 해석할 수 있는 수치 하나를 내는 함수로도 정의한다.[2]

이 용어집은 제품 자체를 재는 척도를 내부 척도(internal measure)로 정의하고, 코드 줄 수와 복잡도 척도를 그 예로 든다.[2] 내부 품질과 외부 품질은 소프트웨어 품질 모델에서 다룬다.

규모

이 용어집은 SLOC(source lines of code)를 컴파일하기 전 프로그램에 든 프로그래밍 언어 코드의 줄 수로 정의하고, LOC를 lines of code의 약어로 둔다. 이 용어집은 line of code를 주석도 빈 줄도 아닌, 인도되는(delivered) 소스 문장으로 정의한다.[2]

SonarQube Server는 물리적 줄 수(lines)와, 공백이나 탭이 아니고 주석의 일부도 아닌 글자를 하나 이상 담은 줄의 수(lines of code)를 따로 센다.[3]

복잡도

McCabe는 1976년 ICSE(International Conference on Software Engineering) 논문 “A Complexity Measure”에서 그래프 이론에 기반한 프로그램 복잡도 척도를 제안했고[4], 이 척도의 이름은 순환 복잡도(cyclomatic complexity)다.[5]

SonarSource는 2016년 12월 cognitive complexity를 내놓았다. 메서드의 제어 흐름을 이해하기 어려운 정도를 상대적으로 재려는 메트릭이다.[6] SonarSource 백서가 정한 셈법은 다음과 같다.

  • 코드의 선형 흐름을 끊는 구조마다 1을 더한다. 반복문, 조건문, catch, switch, 같은 종류의 이항 논리 연산자 열, 재귀 고리에 든 메서드, goto와 레이블로 가는 break·continue가 그런 구조다. 조기 return 같은 다른 점프에는 더하지 않는다.
  • 반복문, 조건문, catch 같은 구조가 다른 구조 안에 중첩되면 중첩 수준마다 1을 더 더한다. else if와 else는 중첩 가산을 받지 않는다.
  • 백서에 따르면 순환 복잡도는 switch의 case마다 1을 더하지만, cognitive complexity는 switch 전체에 1만 더한다. 이항 논리 연산자에서도 cognitive complexity는 연산자마다 1을 더하지 않고 같은 연산자가 이어진 열에 1만 더해, 순환 복잡도보다 덜 센다.[7]

결합

Robert C. Martin은 1994년 글 “OO Design Quality Metrics: An Analysis of Dependencies”에서 클래스 카테고리의 instability 를 정의했다. 카테고리 밖에 있으면서 카테고리 안의 클래스에 의존하는 클래스의 수를 , 카테고리 안에 있으면서 밖의 클래스에 의존하는 클래스의 수를 라 하면 다음과 같다.[8]

는 0에서 1 사이이며, 0이면 가장 안정적이고 1이면 가장 불안정하다.[8]

결합도 자체의 정의는 응집도와 결합도에서 다룬다.

결함 밀도

결함 밀도(defect density)는 작업 산출물의 규모 단위당 결함 수다.[2][9] ISO/IEC/IEEE 24765 용어집은 그 예로 코드 1000줄당 문제 보고 수를 든다.[2]

HIS 소스 코드 메트릭

HIS는 Audi, BMW Group, DaimlerChrysler, Porsche, Volkswagen 같은 독일 완성차 업체가 함께 꾸린 이니셔티브다.[10] HIS는 소프트웨어를 평가하는 기본 메트릭 세트를 문서 HIS-SC-Metriken으로 정했고, 2008년 판은 1.3.1이다.[11]

[1]
ISTQB, “ISTQB Glossary — metric.” 2026. Accessed: Oct. 03, 2026. [Online]. Available: https://glossary.istqb.org/en_US/term/metric
[2]
IEEE Computer Society, “SEVOCAB: Software and Systems Engineering Vocabulary (ISO/IEC/IEEE 24765).” 2026. Accessed: Oct. 02, 2026. [Online]. Available: https://pascal.computer.org/sev_display/index.action
[3]
SonarSource, “Understanding measures and metrics (SonarQube Server documentation).” 2026. Accessed: Oct. 04, 2026. [Online]. Available: https://docs.sonarsource.com/sonarqube-server/user-guide/code-metrics/metrics-definition
[4]
T. J. McCabe, “A complexity measure,” in Proceedings of the 2nd International Conference on Software Engineering (ICSE ’76), Oct. 1976. Accessed: Oct. 04, 2026. [Online]. Available: https://web.archive.org/web/20220608223220/https://dl.acm.org/doi/10.5555/800253.807712
[5]
A. H. Watson and T. J. McCabe, “Structured Testing: A Testing Methodology Using the Cyclomatic Complexity Metric,” NIST Special Publication 500–235, Aug. 1996. Accessed: Oct. 03, 2026. [Online]. Available: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication500-235.pdf
[6]
G. A. Campbell, “Cognitive Complexity, Because Testability != Understandability.” SonarSource, 2016. Accessed: Oct. 03, 2026. [Online]. Available: https://www.sonarsource.com/blog/cognitive-complexity-because-testability-understandability/
[7]
G. A. Campbell, “Cognitive Complexity: A new way of measuring understandability, Version 1.7,” SonarSource, White Paper, 2023. Accessed: Oct. 03, 2026. [Online]. Available: https://www.sonarsource.com/docs/CognitiveComplexity.pdf
[8]
R. C. Martin, “OO Design Quality Metrics: An Analysis of Dependencies.” 1994. Accessed: Oct. 03, 2026. [Online]. Available: https://web.archive.org/web/20030419153430/http://www.objectmentor.com:80/resources/articles/oodmetrc.pdf
[9]
ISTQB, “ISTQB Glossary — defect density.” 2026. Accessed: Oct. 03, 2026. [Online]. Available: https://glossary.istqb.org/en_US/term/defect-density
[10]
Herstellerinitiative Software (HIS), “HIS Working Group Assessment, Version 2.1.” 2006. Accessed: Oct. 02, 2026. [Online]. Available: https://web.archive.org/web/20070206024712/http://www.automotive-his.de:80/download/HIS-WG-Assessments_v21.pdf
[11]
Herstellerinitiative Software (HIS), “Softwaretest.” 2008. Accessed: Oct. 03, 2026. [Online]. Available: https://web.archive.org/web/20080424075227/http://www.automotive-his.de/softtest.htm