Skip to main content

open-harness-linelens

File length linter for any language. Reports files that exceed a configured line limit. Single native binary, zero runtime dependencies.

Part of the open-harness monorepo. Español abajo.

Same tool, other ecosystems: also available on npm (@open_harness/linelens) and on Packagist (open-harness/linelens). Identical binary, identical config; pick the registry that matches your stack.

Install

pip install open-harness-linelens

pip picks the right native wheel for your platform automatically (Linux x86_64, macOS arm64, macOS x86_64, Windows x86_64). Each wheel embeds the Go binary — no runtime deps.

Usage

linelens check               # scan current directory
linelens check --fail        # exit 1 on violations (CI / git hooks)
linelens check --dir ./src   # scan a specific directory
linelens check --max 200     # override the line limit
linelens check --no-color    # plain output for logs
linelens init                # generate a default linelens.json
linelens version             # print version

Configuration

Place a linelens.json at the repo root:

{
  "default": { "maxLines": 100 },
  "rules": [
    { "pattern": "**/*_test.go",     "maxLines": 300 },
    { "pattern": "**/*.spec.*",      "maxLines": 300 },
    { "pattern": "**/migrations/**", "skip": true }
  ],
  "exclude": ["node_modules", "vendor", ".git", "dist"]
}

Pattern semantics follow .gitignore style. The first matching rules entry wins; if no rule matches, default.maxLines applies.

Alternative: configure inside pyproject.toml or the dedicated linelens.json

If you prefer not to keep a separate linelens.json, add a linelens key in your package.json with the same shape:

{
  "name": "my-project",
  "linelens": {
    "default": { "maxLines": 100 },
    "rules": [{ "pattern": "**/*_test.go", "maxLines": 300 }],
    "exclude": ["node_modules", "dist"]
  }
}

Precedence: --config <path> > linelens.json > package.json key > built-in defaults. CLI flags (--max, --no-color, etc.) always win.

Integrations

# Husky pre-commit
linelens check --fail
# lefthook.yml
pre-commit:
  commands:
    linelens:
      run: linelens check --fail --no-color
# GitHub Actions
- name: Run linelens
  run: npx @open_harness/linelens check --fail

Why a line limit?

Large files concentrate too many responsibilities and become hard to read, test, and refactor. A soft cap (e.g. 100 lines, with exceptions for tests) keeps modules focused and forces responsibility-split decisions early — when they are cheap.

Exit codes

Code Meaning
0 No violations (or --fail not passed)
1 Violations found and --fail was passed, or config error

Español

Linter de longitud de archivos, agnóstico al lenguaje. Reporta los archivos que superan un límite de líneas configurable. Un solo binario nativo, cero dependencias en tiempo de ejecución.

Parte del monorepo open-harness.

Instalación

pip install open-harness-linelens

pip elige automáticamente la wheel nativa correcta para tu plataforma (Linux x86_64, macOS arm64, macOS x86_64, Windows x86_64). Cada wheel embebe el binario Go — sin deps en runtime.

Uso

linelens check               # escanea el directorio actual
linelens check --fail        # exit 1 si hay violaciones (CI / git hooks)
linelens check --dir ./src   # escanea un directorio específico
linelens check --max 200     # sobrescribe el límite de líneas
linelens check --no-color    # salida sin colores
linelens init                # genera un linelens.json por defecto
linelens version             # imprime la versión

Configuración

Colocá un linelens.json en la raíz del repo. Ver ejemplo arriba. La semántica de patrones sigue el estilo .gitignore. La primera regla coincidente en rules gana; si ninguna coincide, aplica default.maxLines.

Alternativa: configurar dentro de pyproject.toml o linelens.json

Si preferís no tener un linelens.json separado, agregá una key linelens en tu package.json con la misma forma del archivo dedicado. Precedencia: --config <path> > linelens.json > key en package.json > defaults del binario. Los flags CLI (--max, --no-color, etc.) siempre ganan.

Integraciones

Mismos snippets que arriba — sirven con Husky (.husky/pre-commit), lefthook (lefthook.yml) o GitHub Actions.

Por qué un límite de líneas

Los archivos grandes concentran demasiadas responsabilidades y son difíciles de leer, testear y refactorizar. Un tope blando (por ejemplo 100 líneas, con excepciones para tests) mantiene los módulos enfocados y obliga a tomar decisiones de partición temprano — cuando son baratas.

Códigos de salida

Código Significado
0 Sin violaciones (o no se pasó --fail)
1 Hubo violaciones con --fail, o error de configuración

License

MIT — see the main repository.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

open_harness_linelens-0.3.0-py3-none-win_amd64.whl (2.1 MB view details)

Uploaded Python 3Windows x86-64

open_harness_linelens-0.3.0-py3-none-macosx_11_0_arm64.whl (969.6 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

open_harness_linelens-0.3.0-py3-none-macosx_10_9_x86_64.whl (1.0 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file open_harness_linelens-0.3.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_linelens-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9ebb855e4062d6293ccb3b6d2bcf476446e50963bfe21f6769a873dd625ff421
MD5 092c5f6a539cec360122a773f9ed6619
BLAKE2b-256 3a119c4033353a17aea276bb19837f7f2e789bc08bd8fc819364a9d5f168df1d

See more details on using hashes here.

File details

Details for the file open_harness_linelens-0.3.0-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_linelens-0.3.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0ea86538c2e48764594988a75397325e4f260d93f247f2cf1ab202d4f313919
MD5 9b5322673a985dcb60d2bb541885491e
BLAKE2b-256 1796ec29f3385ebc0b11bd082b5392e75bc767a66f111d371bafd996105e16d1

See more details on using hashes here.

File details

Details for the file open_harness_linelens-0.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_harness_linelens-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 03abb5137df06ba5060c961eacafeae2a1fec83b60eff564a3085e12d7249c5b
MD5 5e5056c0deacc6eaa6e44ad6abaf6b3d
BLAKE2b-256 cfa3830ea32ef4650aa98b761a9785b3c9d94866de12b64f5b83ed153b74872b

See more details on using hashes here.

File details

Details for the file open_harness_linelens-0.3.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_linelens-0.3.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 058c97734c9359a2d8393e98cb062ef2f234533dff882638cfeda1336356691a
MD5 5a58b0d7b9a65c2ef7fbe1c47a88317a
BLAKE2b-256 72746efc8debdfbb466d218d98a8dc589c4c23c7d6da3d51a86ae4d2f12bdcab

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

4 files

0.3.2

4 files

0.3.1

4 files

This release

0.3.0 This release

4 files

0.2.1

4 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page