Skip to content

A search rule is globally limited to 400 units #86

Description

@jbrown9513

MAX_UNITS = 400, applied in two places in src/units.js:

// searchUnits
const units = rank(rule, selectUnits(rule, {...}).slice(0, MAX_UNITS));

// askUnits, for ordinary file rules
for (const unit of selectUnits(rule, {...}).slice(0, MAX_UNITS)) {

Nothing reports the truncation.

An ensure_present rule over more than 400 units reads 400 and reports that nothing has the thing, even when unit 401 has it. An ensure rule over more than 400 files checks 400 and passes on the rest. This repository has 416 methods, so a method rule over the whole tree is already at the line.

Say when it stops

A rule that stops at a limit has not searched its scope, so it cannot report the same answer as one that did. It should say it stopped, and perch doctor should list it the way it lists a rule that covered nothing.

Let a rule set its own limit

The global 400 is arbitrary. A search is the most expensive thing perch does: ensure_absent over src/**/*.js with each: method asks about every method in src before it can say nothing has the thing, which is what a clean codebase hits every run. Three such rules account for most of a scan here.

- name: no-dead-command
  where: "src/**/*.js"
  each: method
  search_limit: 50
  ensure_absent: A command or flag that is parsed and then never used.

Units are already ranked before a search reads them, so a limit takes the top N rather than an arbitrary N.

Worth deciding with it: what the default should be, and whether it should be lower than 400.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: scannerSource selection, analysis, localization, and scan behaviorenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions