> ## Documentation Index
> Fetch the complete documentation index at: https://mehen.ophi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# LOC family

> Lines of code measured five ways: SLOC, PLOC, LLOC, CLOC, and blank lines.

The **Lines of Code (LOC)** family is the simplest size metric mehen reports — and one of the oldest. A
single number is misleading, so mehen separates physical lines, instruction lines, statements, comments,
and blanks.

## What mehen emits

| Key         | Page                         | Counts                                                     |
| ----------- | ---------------------------- | ---------------------------------------------------------- |
| `loc.sloc`  | [SLOC](/metrics/code/sloc)   | Every physical line, including comments and blanks.        |
| `loc.ploc`  | [PLOC](/metrics/code/ploc)   | Physical instruction lines (excludes comments and blanks). |
| `loc.lloc`  | [LLOC](/metrics/code/lloc)   | Logical lines — statements per the language's grammar.     |
| `loc.cloc`  | [CLOC](/metrics/code/cloc)   | Comment lines (line, block, and doc comments).             |
| `loc.blank` | [Blank](/metrics/code/blank) | Whitespace-only lines.                                     |
| `loc`       | —                            | Alias for `loc.sloc`.                                      |

## Worked example

```rust theme={null}
/*
Instruction: Implement factorial function
For extra credits, do not use mutable state or imperative loops.
 */

/// Factorial: n! = n*(n-1)*(n-2)*...*3*2*1
fn factorial(num: u64) -> u64 {

    // use `product` on `Iterator`
    (1..=num).product()
}
```

| Metric      | Value |
| ----------- | ----- |
| `loc.sloc`  | 11    |
| `loc.ploc`  | 3     |
| `loc.lloc`  | 1     |
| `loc.cloc`  | 6     |
| `loc.blank` | 2     |

## Why split the count

The LOC family separates concerns that "lines of code" conflates:

* **SLOC** is the simplest size signal — useful for repository-level dashboards.
* **PLOC** removes whitespace and comments and is closest to "real code".
* **LLOC** counts statements, so it is the right axis for comparing language idioms (one Python
  comprehension vs. a multi-line Rust loop).
* **CLOC** and **Blank** are reported separately because comment and whitespace ratios are themselves
  signals of style and readability.

## References

* Park, R. E. (1992). *Software Size Measurement: A Framework for Counting Source Statements.*
  CMU/SEI-92-TR-20, Software Engineering Institute, Carnegie Mellon.
  [SEI report](https://insights.sei.cmu.edu/library/software-size-measurement-a-framework-for-counting-source-statements/) —
  the standard reference for what does and does not count as a "line".
* Nguyen, V., Deeds-Rubin, S., Tan, T. & Boehm, B. (2007). *A SLOC Counting Standard.* USC Center for
  Systems and Software Engineering Technical Report.
  [USC PDF](https://csse.usc.edu/TECHRPTS/2007/usc-csse-2007-737/usc-csse-2007-737.pdf).
* Sonar: [Lines of code in metric definitions](https://docs.sonarsource.com/sonarqube-server/latest/user-guide/code-metrics/metrics-definition/).

## See also

* [Concepts → Spaces](/concepts/spaces) — how the LOC family aggregates from spaces to files.
* [Developers → How-to: implement LoC](/developers/loc) — internal implementation guide.
