Skip to content
프로젝트

소개

코드를 다시 건전하게 만들어 보세요.

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+46
in 7 days
+405
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

deslop-please

slop test crates.io

An opinionated linter to remove sloppy code. It follows A Philosophy of Software Design: deep modules, narrow interfaces.

cargo install deslop-please

Supports Rust, TypeScript, JavaScript, Go and Python. More languages are welcome as long as they have a tree-sitter grammar.

> deslop-please

error[field-leak]: `RunQueue::items` is known outside `RunQueue`: 4 places in 2 modules
  --> src/sched/policy.rs:7:1
  = note: src/sched/policy.rs:7:1: `runqueue::sched::policy::admit`
  = note: src/sched/policy.rs:12:1: `runqueue::sched::policy::next`
  = note: src/sched/report.rs:4:1: `runqueue::sched::report::backlog`
  = note: src/sched/report.rs:8:1: `runqueue::sched::report::drained`
    runqueue::queue::ring::RunQueue
      items ◀━┳━ 2  runqueue::sched::policy
              ┗━ 2  runqueue::sched::report
      also known outside: head
      kept: limit

deslop-please: 65535 errors, well done!

Pass --lang to check one language (rust, typescript/ts/js, go, python/py):

deslop-please --lang ts

It's not my fault

Sure, let's just mute them:

deslop-please --update-allow .deslop-please.allow  
deslop-please --allow .deslop-please.allow 

Add to your AGENTS.md

-  Run [`deslop-please`](https://github.com/deterministic-machines/deslop-please) to check for sloppy code structure.
-  Errors flagged by `deslop-please` must be fixed from first principles, don't do mechanical moves to hide them.
    - `module-cycle` & `tangle`: what is the indented layer of abstraction? Which module should be at which layer?
    - `field-leak` & `shallow-module`: Why we have these fields/functions at all? What are the patterns of use? Can they be hidden behind a narrow interface? Don't fix each leak one at a time, fix them holistically.
    - Draw a diagram to help user understand the before and proposed after structure.

Why they are sloppy

They are really just one single idea: deep modules, narrow interfaces.

Deep modules hide the details from you and your agents, so you only need to care about the narrow interface.

module-cycle

module-cycle: before, modules kinds and socket use each other, though listen, Stream::new and BACKLOG_MOST only form a chain; after, BACKLOG_MOST moves into kinds and only socket uses kinds

tangle

tangle: before, Tasks in kernel and Timers in its child module timers know each other, with no module cycle; after, tick in kernel calls both and Timers no longer knows Tasks

field-leak

field-leak: before, functions in sched push to, index and bump the items and head of RunQueue; after, they call push, pop and backlog, and only RunQueue works on its fields

shallow-module

shallow-module: before, app calls 9 of the 15 functions of store; after, it calls new, load and summary, and the rest are hidden behind them

License

MIT

관련 프로젝트 살펴보기

불러오는 중…