Skip to main content

File length linter for any language — single native binary, zero runtime deps

Project description

open-harness-scopelens

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/scopelens) and on Packagist (open-harness/scopelens). Identical binary, identical config; pick the registry that matches your stack.

Install

pip install open-harness-scopelens

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

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

Configuration

Place a scopelens.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 scopelens.json

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

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

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

Integrations

# Husky pre-commit
scopelens check --fail
# lefthook.yml
pre-commit:
  commands:
    scopelens:
      run: scopelens check --fail --no-color
# GitHub Actions
- name: Run scopelens
  run: npx @open_harness/scopelens 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-scopelens

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

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

Configuración

Colocá un scopelens.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 scopelens.json

Si preferís no tener un scopelens.json separado, agregá una key scopelens en tu package.json con la misma forma del archivo dedicado. Precedencia: --config <path> > scopelens.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.

Project details


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_scopelens-0.2.0-py3-none-win_amd64.whl (2.3 MB view details)

Uploaded Python 3Windows x86-64

open_harness_scopelens-0.2.0-py3-none-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

open_harness_scopelens-0.2.0-py3-none-macosx_10_9_x86_64.whl (1.1 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file open_harness_scopelens-0.2.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_scopelens-0.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 df6cf22a8ff41da8b71d22ba50a71e15eaff29f1c40999e12c6fe7a9aef98868
MD5 1cc39c6d059239260f9133f4875f4464
BLAKE2b-256 aba0b24ad7783e27a91f5e4333f1e48d7a244b3881d432386d52df24ef711e19

See more details on using hashes here.

File details

Details for the file open_harness_scopelens-0.2.0-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_scopelens-0.2.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5108d845572aa90baab63894f73be1c7bbde4277861a0a8d3a74de4fd7f6a74d
MD5 7268c96e550a11865df505209df9168f
BLAKE2b-256 c5840bd46a166199b63973daab79418e206f9faac03f61d2258734b8433b9158

See more details on using hashes here.

File details

Details for the file open_harness_scopelens-0.2.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_harness_scopelens-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 803108eefd14710b816cdd0319d4b0097a4608d0a56bccd52049d964e72a87b8
MD5 0997a9a5cc93405f4d3e45a3ecbf9cf2
BLAKE2b-256 8241197ee875e1fd4de9a4a1840f0686cf650562b35deb651272427875f34d44

See more details on using hashes here.

File details

Details for the file open_harness_scopelens-0.2.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_scopelens-0.2.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e00e2c34a9d764a3e669e47b46903cf4065c1a2e4aa75865693413ad7597a210
MD5 e0feb2b101b7c268b2b30442c026fbe5
BLAKE2b-256 3d7eb42db5151efdb50f8f17e539e4d9f6ad5fe8052e782f80c58fb53f698c8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page