Skip to content
mlavrinenkoPublic

About

Language-aware file size linter powered by Tokei.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

166 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linecop

CI crates.io

Language-aware file size linter. It patrols your code base for per-language line limits, counted by tokei.

Installation

cargo install linecop
nix run github:mlavrinenko/linecop

Prebuilt binaries for x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, x86_64-apple-darwin and aarch64-apple-darwin are on the releases page. The installation page covers each path.

GitHub actions

- uses: mlavrinenko/linecop@v0.9.1
  with: { paths: src/, args: --top 10 }

The composite action installs and verifies the release binary, runs --format json, annotates over rows as errors and near rows as warnings, and writes a step summary.

Input Description
paths Path to scan, relative to the working directory. Pass one path; spaces are preserved. Default: ..
args Extra linecop arguments, whitespace-separated. Do not pass --format, -q or --quiet.
version Release tag to install, e.g. v0.9.0. Defaults to the action ref; set it for @main and SHA pins.
working-directory Directory to run linecop from, relative to the workspace. Default: ..
Output Description
violations Number of files over their limits.

The install step exits 1 for an unsupported platform or architecture, a missing or invalid release tag, or a failed download or checksum. The check step exits 2 when linecop cannot run, and otherwise passes linecop’s status through: 1 when a file is at or above the baseline, 0 when none is. Windows runners fail with a WSL hint.

Usage

linecop [PATH] [OPTIONS]  |  linecop [PATH] <COMMAND>
linecop explain <FILE> [OPTIONS]

Options

Option Description
-c, --config <FILE> Config file path, or - for stdin (default: auto-detected).
--config-search <repo|root> Where to stop looking for a config. repo (default) stops at the repository root. root walks to the filesystem root.
--no-config Skip discovery and use the built-in 500-line default, without the warning.
--limit <[LANG=]LINES> Append a rule. A bare value caps all files. LANG= caps one language.
--ignore <PATTERN> Append a .gitignore rule from the config’s root. Repeatable.
--count <total|code|code-comments> Count mode, overriding count.
-q, --quiet Suppress output (exit code only).
--format <text|json|paths> Output format (default: text).
--baseline <PERCENT> Report files at or above this percentage of their limit, 1 to 100 (default: 100).
--top <N> Show the N files with the least headroom, worst first. --baseline still decides the exit code.
--hidden Scan dot-prefixed files and directories, overriding hidden.
--color <auto|always|never> Control color output.
--no-config-warning Suppress the warning when no config file exists.

init writes version: 1 and default: 500, schema prints the JSON Schema, and explain prints the count mode, each matching rule and its group selector, then the final caps. Ignored and capless files say so. A bad path exits 2.

--limit and --ignore append rules after the config’s. A bare --limit lands before named ones, a config ignore still stops the file, and bad values exit 2.

Exit codes

Code Meaning
0 No file is at or above the baseline. With the default 100, no file is over its cap
1 At least one file is at or above the baseline. With the default 100, at least one file is over its cap
2 Operational error. The check never ran. Malformed or unreadable config, unknown language, invalid pattern, missing scan path, I/O failure or bad CLI arguments

Examples

linecop --baseline 90                 # warn at 90% of every cap
linecop --baseline 90 --top 10        # the ten closest files, worst first

--top ranks capped files by worst gauge, overage and path. --- marks over, ~~~ near, and --baseline sets the exit code. --format paths rejects the pair, and JSON adds a status.

Library

run checks a path and returns Result<bool>, explain renders one file’s caps, and check_content checks a buffer and returns Result<CheckReport>. The stable API is those, config, CheckReport, FileReport, Gauge, ScopeGauge, Format and report::print. Run cargo doc --open for the rest. The library page covers usage.

let report = linecop::check_content(path, source, &config, None, 100)?;

Configuration

linecop reads the nearest .linecop.yaml or .config/linecop.yaml, walking up to the repository root. --config-search root goes to the filesystem root, and --config skips the search.

version: 1
count: total
default:
  file: 500
restrictions:
  source:
    comment-block: 4
    comment-lines: 40
  docs:
    file: 200
groups:
  generated:
    - path: "src/generated_*.rs"
rules:
  - where: generated
    apply: ignore
  - where: languages.Markdown
    apply: docs

version defaults to 1, and linecop rejects unknown keys. A cap is a line count or { lines, bytes, message }, and false disables a measure. Rules run in order. Each match overlays its restriction on the default, and ignore stops the file. A group holds path and language selectors. Both keys in one selector have to match, and entries are alternatives. The configuration page covers scopes, root, hidden and every key. The schema page has the JSON Schema.

Agent skill

skills/linecop tells an agent to check headroom with --baseline before growing a file. The skill page covers installation.

Docs

The docs site covers installation, usage, configuration, schema, the library API, the GitHub Action, the agent skill and the changelog.

Contributing

See CONTRIBUTING.md for conventions, the gates and the release process.

License

MIT.

About

Language-aware file size linter powered by Tokei.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages