Commit Graph

205 Commits

Author SHA1 Message Date
Joshua Clayton
fb1198dc2f Operate on purer data sets 2016-05-23 08:22:09 -04:00
Joshua Clayton
db10b79f93 Extract results printing to separate function 2016-05-23 08:18:43 -04:00
Joshua Clayton
3f402120d9 Begin moving away from ParseResponse 2016-05-23 06:36:06 -04:00
Joshua Clayton
e006b9c2dd Fix wording around how unused finds tokens to work with 2016-05-23 05:02:54 -04:00
Joshua Clayton
6db5cb0120 Rails allowed terms covering inflections, concerns, rendering 2016-05-22 07:51:11 -04:00
Joshua Clayton
697f8b4135 Token matches can occur at the beginning or end of a file 2016-05-22 07:03:37 -04:00
Joshua Clayton
b7aefe66d0 Bump version to 0.2.0.0 2016-05-22 06:15:00 -04:00
Joshua Clayton
43edf288e2 Attempt to find and load tags automatically
Why?
====

Frequency of a tool's usage is determined by how easy it is to use the
tool. By having to pipe in ctags files all the time, and not provide any
guidance to the user, this program is merely a toy, since it's hard to
get right, and harder to explore.

This modifies the default behavior to look for a ctags file in a few
common locations, and lets the user choose a custom location if she so
chooses.

Resolves #35
2016-05-22 06:06:09 -04:00
Joshua Clayton
c5f2a38e80 Rails config: handle i18n and migration methods 2016-05-21 06:29:28 -04:00
Joshua Clayton
307dd2030f Introduce internal yaml configuration of auto low likelihood match handling
Why?
====

Handling low likelihood configuration was previously a huge pain,
because the syntax in Haskell was fairly terse. This introduces a yaml
format internally that ships with the app covering basic cases for
Rails, Phoenix, and Haskell. I could imagine getting baselines in here
for other languages and frameworks (especially ones I've used and am
comfortable with) as a baseline.

This also paves the way for searching for user-provided additions and
loading those configurations in addition to what we have here.
2016-05-21 05:34:18 -04:00
Joshua Clayton
6c9912fa29 Switch to faster/more naive implementation of String to Int conversion
Why?
====

This library converts lots of strings to positive integers
(specifically, when it's parsing output from search results). Because
these are always positive integers, we can make more assumptions about
the data and how to parse the values.

Corresponding benchmark: https://gist.github.com/joshuaclayton/767c507edf09215d08cdd79c93a5f383
2016-05-18 11:17:13 -04:00
Joshua Clayton
4c8e8b2d72 Switch to faster implementation of grouping a list
Why?
====

Immediately after searching the codebase after tokens, we group results
together based on match. This can be slow, especially within large
codebases. This improves the time taken, previously O(n^2).

Code reference: http://stackoverflow.com/a/15412231
Corresponding benchmark: https://gist.github.com/joshuaclayton/3dcde3b19e2c3006ee922053edebc417
2016-05-18 06:45:39 -04:00
Joshua Clayton
2e3bb0e67c Users opt into using the cache
Why?
====

Calculating the SHA of the entire tree can be expensive; this shifts
reading from/writing to the cache to be configured via a switch in the
CLI.

In the future, it might make sense to store metadata about the repo,
including historical time to calculate both the SHA and non-cached
versions, to compare and choose which one to do intelligently.
2016-05-18 06:44:30 -04:00
Joshua Clayton
c77cd2a8f6 Handle Ctrl-C both at top thread and forked thread for progressbar
This ensures Ctrl-C interrupts the main thread as well as kills the
forked thread rendering progress.
2016-05-16 21:52:38 -04:00
Joshua Clayton
44ab0a1435 Read unchanged results from the cache
At some point, this also needs to md5 the tags list itself and factor
that in (since if the tagging algorithm changes, and new tokens get
uncovered, it'd invalidate the cache)
2016-05-16 21:48:36 -04:00
Joshua Clayton
85df4ae01f Return ThreadId with ProgressIndicator
Why?
====

It's common to return a two-tuple of `(ThreadId, a)` when performing a
forking operation to provide a handle to the thread.
2016-05-16 06:06:51 -04:00
Joshua Clayton
8c5e94c862 Extract interrupt code 2016-05-16 05:59:32 -04:00
Joshua Clayton
fde423f272 Reset color when handling interrupt 2016-05-15 16:18:24 -04:00
Joshua Clayton
2d65555b60 Wrap cursor management into one function 2016-05-15 16:14:40 -04:00
Joshua Clayton
233f83bdf8 Have withInterruptHandler be more transparent 2016-05-15 16:02:21 -04:00
Joshua Clayton
790b62c999 Render base header as soon as we have tokens 2016-05-15 08:35:27 -04:00
Joshua Clayton
e70a7e4e0b Move line handling to occur when binding to results 2016-05-15 08:05:41 -04:00
Joshua Clayton
0e966c9302 Test Util.groupBy 2016-05-15 05:53:29 -04:00
Joshua Clayton
97f083fc2c Use regex in ag for simple words
Why?
====

ag supports using regular expressions for searches; however, the -Q
flag, which was previously always used, resulted in literal search
results.

By searching literal matches, it would potentially return too many
results. For example, with a `me` method in a controller, it'd match
words like `awesome` or `method`.

This introduces a check where, if the token being searched is only
composed of word characters (`[A-Za-z0-9_]`), it'll switch over to use
regular expressions with ag and surround the token with non-word matches
on either end. The goal here is to reduce false-positives in matches.
2016-05-14 08:14:54 -04:00
Joshua Clayton
3851c98d59 Initial Haskell support for allowed tokens
This is based off of tags generated by Hasktags:

https://hackage.haskell.org/package/hasktags
2016-05-14 06:37:48 -04:00
Joshua Clayton
bcbc1b6462 Allow search result grouping
Why?
====

Grouping results can be helpful to view information differently, e.g. to
see highest-offending files or to remove grouping entirely.

This introduces a flag to allow overriding the default group (two levels
of directory)
2016-05-14 06:36:01 -04:00
Joshua Clayton
a8a9d250e3 Parallelize search
Why?
====

Searching hundreds or thousands of tokens with ag can be slow; this
introduces parallel processing of search so results are returned more
quickly.
2016-05-13 14:46:23 -04:00
Joshua Clayton
bbb178f7d5 Extract ioOps calculation 2016-05-13 14:44:03 -04:00
Joshua Clayton
2ec73ac3b3 Consolidate progress indicator handling 2016-05-13 14:18:23 -04:00
Joshua Clayton
86cdd114d5 Be more explicit about usage during liklihood 2016-05-13 12:42:05 -04:00
Joshua Clayton
4097ac4aa8 Bump version to 0.1.1.0 2016-05-12 18:11:14 -04:00
Joshua Clayton
7f0e701823 Extract internal parsing handling to separate module
Why?
====

Parsing lines of results was somewhat unreliable, and terms with odd
characters were causing problems. This:

* extracts parsing into an Unused.Parser.Internal module for ease of
  testing
* fixes cases where certain tokens weren't matching
2016-05-12 18:02:59 -04:00
Joshua Clayton
1457bf0100 Allow Mixfile and __using__ for Elixir 2016-05-12 18:01:16 -04:00
Gabe Berke-Williams
985d876ff5 Use applicative style in Parsec
This commit also moves `eol` into the `parseTermMatch` parser, which should be
safe since `parseTermMatches` is the only place that `parseTermMatch` is used.
2016-05-12 13:59:58 -04:00
Joshua Clayton
3ff26fceea Try to point people in the right direction better 2016-05-12 06:40:29 -04:00
Joshua Clayton
7d2caa3f2d Outline the recommended way of using Unused 2016-05-12 06:38:48 -04:00
Joshua Clayton
731381a0f8 Discuss what it can be used on 2016-05-12 06:37:30 -04:00
Joshua Clayton
b90cddf460 Print message when no results are found 2016-05-12 05:25:53 -04:00
Joshua Clayton
95fc86eaef Include TravisCI build status 2016-05-11 23:24:42 -04:00
Joshua Clayton
51be1c86ae Test unused on TravisCI 2016-05-11 23:09:35 -04:00
Joshua Clayton
a18d921f6a Document installation via Homebrew 2016-05-11 22:32:19 -04:00
Joshua Clayton
9ffc78f721 Initial release v0.1.0.0 2016-05-11 21:36:21 -04:00
Joshua Clayton
ca694df50e Use void 2016-05-11 21:30:30 -04:00
Joshua Clayton
5b69d45caf Include features/ in the list of directories counting as tests 2016-05-11 11:31:52 -04:00
Joshua Clayton
19b72c123f Update readme to include information about ag 2016-05-11 11:31:52 -04:00
Joshua Clayton
8d5e13c89e Use sensible defaults for the CLI
Why?
====

By default, people want to see an actionable, comprehensive list without
having to pass any flags into the program.

Previously, to see everything with high likelihood you'd need to provide
`-a --likelihood high`. This commit changes the program so that's the default.

It also introduces a `--all-likelihoods` flag (shorthand is `-a`) to see
everything, so if you want to opt into see it, you can. Finally, this
changes `-a` (to see everything) to `-s` (to see only single
occurrences, which was the previous default).
2016-05-11 11:31:52 -04:00
Joshua Clayton
56c083097d Fix indentation 2016-05-11 10:46:18 -04:00
Joshua Clayton
9407b91b3b Update help docs 2016-05-11 09:22:29 -04:00
Joshua Clayton
cf542044df Warn on everything, error on anything 2016-05-11 05:32:42 -04:00
Joshua Clayton
4b60a06438 Resolve remaining warnings 2016-05-11 05:32:10 -04:00