Usage
Scan a code base and read the report.
Manual contents
linecop takes a path, counts the files it recognizes, and checks each file against the caps in the nearest config. The default report lists the files that breach a cap. --top and --baseline change which rows appear without changing the cap.
The command
linecop [OPTIONS] [PATH] [COMMAND]PATH is the directory to scan. It defaults to the config’s root when the config sets one, else the current directory. --config names a config file, or - reads one from stdin. --no-config skips discovery and starts from the built-in 500-line default.
Discovery looks for .linecop.yaml or .config/linecop.yaml, starting at the scan path and walking up. It stops at the repository root by default. --config-search root walks to the filesystem root instead. --no-config-warning suppresses the warning printed when no config exists.
Options
| Option | Value | What it does |
|---|---|---|
-c, --config | PATH | Config file, or - for stdin. |
--config-search | repo, root | How far discovery walks for a config. |
--no-config | Skip discovery and use the built-in 500-line default. | |
--limit | [LANG=]LINES | Append a line limit. A bare value caps every file, and Rust=300 caps one language. |
--ignore | PATTERN | Append an ignore pattern, matched from the config’s root. Negation is not supported. |
--count | total, code, code-comments | Count mode, overriding the config. |
-q, --quiet | Suppress stdout. The exit code still reports the result. | |
--format | text, json, paths | Output format. The default is text. |
--color | auto, always, never | Color output. The default is auto. |
--no-config-warning | Suppress the warning when no config exists. | |
--hidden | Scan dot-prefixed paths, overriding the config. VCS metadata stays excluded. | |
--baseline | 1-100 | Report files at or above this percentage of their cap. The default is 100. |
--top | N | Show the N files with the least headroom, worst gauge first. |
-h, --help | Print help. -h prints the summary. | |
-V, --version | Print the version. |
linecop rejects --top with --format paths, and that pair exits with code 2. A bare --limit may appear once, and each language gets one limit.
Exit codes
| Code | Meaning |
|---|---|
0 | Every capped file is below the reporting line. |
1 | At least one file is over its cap, or at the baseline when --baseline is below 100. |
2 | The run could not happen. A bad config, a missing path, an unsupported value, or an I/O failure. |
Formats
The text format prints one row per reported file. --- marks a file over its cap, ~~~ marks a file at or above the baseline, and a file below the baseline has no mark.
linecop --baseline 85--- docs/guide.md: 20 lines (limit: 12, +8 over)
--- src/checkout.rs: 30 lines (limit: 20, +10 over; split the module)
~~~ src/render.rs: 18 lines (limit: 20, 90% of limit; split the module)
3 file(s) reported. Consider refactoring.
+18 lines over limit.
A clean tree prints the success line and exits 0. This capture comes from examples/clean:
linecopAll files within size limits.
--format json prints an array of files. Each entry carries path, language, status, and a scopes array. A line cap adds lines, limit, and baseline-limit. A byte cap adds bytes, max_bytes, and baseline-max-bytes. A cap message adds message. The array holds the files that breach the reporting line, or the files selected by --top.
{
"path": "./docs/guide.md",
"language": "Markdown",
"lines": 20,
"limit": 12,
"baseline-limit": 10,
"status": "over",
"scopes": []
}
--format paths prints only the paths, one per line, for a pipe or a file list:
linecop --format pathsdocs/guide.md
src/checkout.rs
Examples
Rank the closest files and report the ones at 85% of a cap:
linecop --top 5 --baseline 85--- docs/guide.md: 20 lines (limit: 12, +8 over)
--- src/checkout.rs: 30 lines (limit: 20, +10 over; split the module)
~~~ src/render.rs: 18 lines (limit: 20, 90% of limit; split the module)
src/parse.rs: 12 lines (limit: 20, 60% of limit)
4 closest files; 2 over limit.
Explain one file without scanning the rest:
linecop explain src/checkout.rssrc/checkout.rs Rust
count: total
default: file.lines = 40
rule 3: where languages.Rust -> source
source: comment-block.lines = 4, comment-lines.lines = 12, file.lines = 20
effective: comment-block.lines = 4, comment-lines.lines = 12, file.lines = 20
Cap Rust at 300 lines and keep a vendor tree out of the scan:
linecop --limit Rust=300 --ignore "vendor/**" .Count code lines only:
linecop --count code .Read a config from stdin:
cat .linecop.yaml | linecop --config -Include dot-prefixed directories:
linecop --hidden .Start a config and print the schema:
linecop init
linecop schemaFull help
Captured linecop --help
Patrols your code base to enforce line count limits.
Usage: linecop [OPTIONS] [PATH] [COMMAND]
Commands:
init Generate a starter .linecop.yaml in the target directory
schema Print the JSON Schema for .linecop.yaml configuration
explain Explain how one file's caps resolve
help Print this message or the help of the given subcommand(s)
Arguments:
[PATH]
Directory to scan (default: the config's `root`, else the current directory)
Options:
-c, --config <CONFIG>
Path to the config file, or `-` for stdin (default: auto-detected)
--config-search <CONFIG_SEARCH>
How far up to look for the config: to the repository root, or to the filesystem root
Possible values:
- repo: Stop after the repository root; with no repository, at the working directory
- root: Walk to the filesystem root, ignoring repository markers
[default: repo]
--no-config
Skip config discovery and use the built-in 500-line default
--limit <LANG=LINES>
Append a line limit: `[LANG=]LINES`; bare caps every file
--ignore <PATTERN>
Append an ignore pattern, matched from the config's root
--count <COUNT>
Count mode, overriding the config
Possible values:
- total: Count all lines (code + comments + blanks)
- code: Count only code lines
- code-comments: Count code + comment lines (exclude blanks)
-q, --quiet
Suppress output (exit code only)
--format <FORMAT>
Output format
Possible values:
- text: Human-readable text output
- json: JSON array of breaching files
- paths: Paths only, one per line (for piping to other tools)
[default: text]
--color <COLOR>
Control color output
[default: auto]
[possible values: auto, always, never]
--no-config-warning
Suppress the warning when no config file is found
--hidden
Scan hidden files and directories (dot-prefixed), overriding the config
--baseline <BASELINE>
Report files at or above this percentage of their limit (1-100)
[default: 100]
--top <N>
Show the N files with the least headroom, worst gauge first
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
The configuration page covers the file these options read. The schema page covers editor support.