Page MenuHomePhabricator

arc linters: Filter by name, make display one-line
ClosedPublic

Authored by avivey on Oct 14 2014, 11:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 14, 5:04 PM
Unknown Object (File)
Fri, Dec 13, 9:53 PM
Unknown Object (File)
Thu, Dec 12, 6:15 AM
Unknown Object (File)
Thu, Dec 5, 10:54 AM
Unknown Object (File)
Mon, Dec 2, 5:34 PM
Unknown Object (File)
Mon, Dec 2, 1:40 PM
Unknown Object (File)
Mon, Dec 2, 12:49 PM
Unknown Object (File)
Thu, Nov 28, 1:49 PM
Subscribers

Details

Summary

allow searching/filtering linters displayed by name.

Test Plan

$ arc linters --verbose --search JSon --search ruby (Lots of text about many linters)
$ arc linters --search JSon ruby (error message)
$ arc linters python (no results, "try --search").
$ arc linters ruby (Verbose text about the "ruby" linter).

Diff Detail

Repository
rARC Arcanist
Branch
linters
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 7823
Build 8678: [Placeholder Plan] Wait for 30 Seconds
Build 8677: arc lint + arc unit

Event Timeline

avivey retitled this revision from to arc linters: Filter by name.
avivey updated this object.
avivey edited the test plan for this revision. (Show Details)
avivey added a reviewer: epriestley.
avivey edited edge metadata.
joshuaspence edited edge metadata.

FWIW, I agree with the idea behind this diff. I would request a couple of minor changes however, although ultimately @epriestley has the final say.

src/workflow/ArcanistLintersWorkflow.php
58–59

This should maybe move to a getAllLinters method.

70–72

I think that this would be better written as:

$search = $this->getArgument('search');

if ($search) {
  $linter_info = $this->filterByNames($linter_info, $search);
}
216–230

A couple of points:

  • I don't think we should use regex matching. I'd prefer to use strpos.
  • The parameters ($linters and $search_terms) should be type-hinted as arrays.
  • I think that filterByNames($linters, array()) should return array() rather than $linters.
This revision now requires changes to proceed.Dec 30 2014, 9:05 AM
joshuaspence edited edge metadata.
avivey edited edge metadata.
  • use stripos
  • test before calling filter()
  • improve doc
  • extract getLintersInfo() out of run()
src/workflow/ArcanistLintersWorkflow.php
58–59

I'm not 100% sold on this, but I gave it a go.

joshuaspence edited edge metadata.

LGTM

src/workflow/ArcanistLintersWorkflow.php
216

These parameters should be type-hinted as you are assuming that they are arrays anyway.

avivey edited edge metadata.

Type-hint

also search full description, so "arc linters python" shows flake8, and "arc linters javascript" shows something.

The search feels a little weird to me as a default. In particular, I don't like that arc linters ruby may return a lot of results and there's no way to return exactly one hit (for example, if I'm debugging over IRC or something). What if we did something like this?

  • Default (non-verbose) output is one linter per line.
  • Arguments must match linter key case-insensitively (e.g., arc linters ruby can get info on a specific linter, even if many linters match "ruby").
  • If you still want it, put search on a --search flag? And have the error say "No linters match query exactly, try --search." or whatever.
  • Maybe arguments imply --verbose?

I don't feel strongly about this, the current signature just feels a little fuzzy and the relatively verbose default behavior of arc linters also doesn't seem especially useful.

epriestley edited edge metadata.

(Just kicking this into your queue for thoughts.)

This revision now requires changes to proceed.Aug 27 2015, 11:13 AM

The primary use-case I was thinking about is "Is there a linter installed that I can use here", so a general search is what I'm after; currently, I'd end up with arc linters | less and grep there. I'd like a --search option, which acts like this change.

I agree with your suggestions, provided we make that one line a little more informative than it currently is (i.e., replace flake8 (Flake8) with flake8 (Comprehensive Python linter) and jshint (JSHint) with jshint (Javascript)). I think I'll do that anyway.

avivey edited edge metadata.
  • Make non-verbose text one-liners
  • Use --search for search
  • make arc linters ruby show only exact match, and be verbose.

Making --search imply --verbose looks a little over-kill.

avivey retitled this revision from arc linters: Filter by name to arc linters: Filter by name, make display one-line.Aug 28 2015, 4:31 AM
avivey edited the test plan for this revision. (Show Details)
avivey edited edge metadata.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 28 2015, 10:26 AM
This revision was automatically updated to reflect the committed changes.