vkatsuba / rebar3_sheldon Goto Github PK
View Code? Open in Web Editor NEWA rebar plugin for spellchecking
License: Apache License 2.0
A rebar plugin for spellchecking
License: Apache License 2.0
rebar3_sheldon
versionOS
versionmacOS 11.6.1
asts
(ASTs
).string:lowercase/1
) them when reading the dictionary files.rebar3_sheldon
versionOS
versionUbuntu
AST
.erl_syntax
instead of erl_scan
for flexibility work with AST
- this approach should make it easy to extend functionality such as parsing custom tags in modules etc.Used erl_scan
.
Used erl_syntax
.
rebar3_sheldon
versionOS
versionmacOS 11.6
Motivation
ignore_regex
ends up being large and mostly repeated among all my projects. I would like some of those things to be ignored by default, i.e. without requiring me to add that stuff to rebar.config.
Proposal
Ignore the following strings by default:
Stuff | Dumb Regex |
---|---|
Eunit header file | eunit |
Maps in comments | => |
io:format stuff |
~[tpw] |
Variables using camelCase or PascalCase | [a-z][A-Z] |
Wildcards | [*] |
SemVer | ~> |
Versions | \\d[.]\\d |
Relative Paths | [.]/ |
Functions (e.g. something/1) | [A-Za-z0-9]/\\d |
File extensions | ^[.][a-z]+$ |
Macros | [?][A-Za-z] |
Paths | [a-z]/[a-z] |
Record names in comments | [#][a-z0-9] |
HTML in comments | <[a-z/] |
Function calls in comments | [a-z][(] |
This would be good as-is, but it would be even better if users can choose which ones of this regexes they want to include or not. Which would likely be easier to do after #25 is done.
rebar3_sheldon
versionOS
versionmacOS 11.6
-module(break).
%% this comment: ’
rebar3 spellcheck
on it$ rebar3 spellcheck
===> Analyzing applications...
===> Compiling rebar3_hank
===> That's no reason to cry. One cries because one is sad. For example, I cry because others are stupid, and that makes me sad.
src/break.erl:3: The word [195,162,194,128,194,153] in comment is unknown.
$ rebar3 spellcheck
===> Analyzing applications...
===> Compiling rebar3_hank
===> That's no reason to cry. One cries because one is sad. For example, I cry because others are stupid, and that makes me sad.
src/break.erl:3: The word "’" in comment is unknown.
rebar3_sheldon
versionPut release version here and update tag link(0.0.0) ...
OS
versionRun the spellchecker on Spillway
Among other warnings…
src/spillway.app.src:7: The word "Github" in string is unknown. Maybe you wanted to use "Github"?
To accept Github
as a valid word.
{spellcheck,
[{ignore_regex, "(eunit|~>|--|==|\\^|_|//|\\d[.]\\d)"},
{files, ["src/*", "test/*"]},
{additional_dictionaries, ["nextroll.dict"]}]}.
and nextroll.dict
is…
AdRoll
Github
rebar3
Pena
Watters
NONINFRINGEMENT
rebar3_sheldon
versionOS
versionmacOS 11.6
Motivation
I would like to run the spellchecker only for a certain subset of files, every once in a while.
Proposal
Add a --files=$REGEX
option, like the one in rebar3_format
.
--files
should override the value of the files
option in rebar.config
.
rebar3_sheldon
versionOS
versionmacOS 11.6
Motivation
Since the regex should capture many scenarios, it ends up being super large and ugly. Even if its then compiled into an ugly large one, I would like to be able to define and, more importantly, name a few ones.
Proposal
Allow users to use this:
{spellcheck,
[{ignore_regexes,
#{eunit_files => "eunit",
maps_in_comments => "=>",
io_format_stuff => "~t",
semver => "~>",
…
}]}.
instead of this:
{spellcheck,
[{ignore_regex,
"(eunit|=>|~t|_|~>|…"}]}.
After fix compiling issue in sheldon
on Windows it make sense add Windows CI into plugin too.
Please add details describing each of the options supported in the rebar.config
.
In other words, extend this section with explanations about possible values and their expected outcome for each parameter.
Also, if the plugin supports command line options, please add them to the README.
rebar3_sheldon
versionOS
versionmacOs Darwin Kernel Version 21.4.0
I want to keep my dictionaries as short as possible thus improving code maintenance.
Warn on no-longer-used dictionary entries, with an indication of the dictionary file and line number for the warned-about entries.
Unused dictionary entries usually means these are ever growing.
Check Proposal, above.
n/a
rebar3_sheldon
versionOS
versionUbuntu
-ignore_spelling([this_function/1, …]).
Ignore tag is not supported.
Ignore tag is supported.
rebar3_sheldon
versionOS
versionmacOS 11.6
rebar3_sheldon
to pick it up and add them to the global dictionary that it uses.{custom_dictionary, "/path/to/file.dict"}
option to the spellcheck
section in rebar.config
.sheldon
to combine it with the official dictionary it uses.rebar3_sheldon
versionOS
versionmacOS 11.6
===> spellcheck detect warning emits: [
…
#{filename => "rebar.config",line => 181,
reason =>
#{bazinga =>
<<"Too bad, I'll have a virgin Cuba Libre.">>,
misspelled_words =>
[#{candidates =>
["vim","vum","Am","am",
"bm","Cm","cm","Dm",
"dm","Em","em","Fm",
"fm","Gm","gm","hm",
"Im","im","km","lm",
"'m","-m","m","m.","mA",
"ma","mb","mC","mc",
"md","me","mF","mf",
"mg","mH","mh","mi",
"mk","mL","ml","mM",
"mm","mn","mo","mp",
"mR","mr","ms","mt",
"mu","mV","mv","mW",
"mw","my","nm","Om",
"om","Pm","pm","qm",
"rm","Sm","sm","Tm",
"tm","um","wm","ym",
"Av","av","bv","cv",
"Ev","fv","gv","hv",
"iv","kv","lv","Mv",
"mv","nv","qv","sv",
"tv","v","va","vb","vc",
"vd","vg","vi","vl",
"vo","vp","vr","vs",
"vt","vv"],
line_number => 1,
word => "VM"},
#{filename => "rebar.config",line => 171,
reason =>
#{bazinga =>
<<"Does it affect me? Then suffer in silence.">>,
misspelled_words =>
[#{candidates =>
["additionally",
"dictionally"],
line_number => 1,
word => "Aditionally"},
#{candidates => [],
line_number => 1,
word => "boodah.boot"}]},
…
===> you might have some spelling errors:
rebar.config:181: The word "VM" is unknown. Maybe you wanted to use "vim", "vum", …, or "vv".
rebar.config:171: The word "boodah.boot" is unknown.
rebar.config:171: The word "Aditionally" is unknown. Maybe you wanted to use "additionally", or "dictionally".
…
And to be consistent with the spirit of Sheldon… you can pick a random bazinga from the returned results and close the report with…
===> Does it affect me? Then suffer in silence.
rebar3_sheldon
versionOS
versionmacOS 13.5.1
rebar3_sheldon
tends to be slow (haven't analysed it this is an issue with implementation or the sheer volume of stuff it has to deal with).
Give the consumer a notice about the plugin taking a while to load/execute.
rebar3_sheldon
runs with no indication of "taking a long time".
rebar3 sheldon
should output (when starting) something like "rebar3_sheldon analysis starting, this may take a while...as is common for other plugins, e.g.
dialyzeror
rebar3_lint`.
None available.
rebar3_sheldon
versionOS
versionmacOS 11.6
api
arity
arities
ast
asts
config
epp
erlang
github
hrl
include_lib
gen_server
gen_statem
gen_event
mfa
nif
nif_error
otp
plugin
rebar3
todo
unicode
rebar3_sheldon
versionOS
versionmacOS 11.6
-module(break).
%% this comment: ’
rebar3 spellcheck
on it===> Uncaught error in rebar_core. Run with DIAGNOSTIC=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: badarg
===> Stack trace to the error location:
[{re,replace,
[[37,32,116,104,105,115,32,99,111,109,109,101,110,116,58,32,8217],
"%|@",[],
[global,{return,list}]],
[{file,"re.erl"},{line,398}]},
{rebar3_sheldon_ast,collect_comments,3,
[{file,"/Users/fernandobenavides/Projects/elbrujohalcon/test_app/_build/default/plugins/rebar3_sheldon/src/rebar3_sheldon_ast.erl"},
{line,86}]},
{rebar3_sheldon_ast,spellcheck,3,
[{file,"/Users/fernandobenavides/Projects/elbrujohalcon/test_app/_build/default/plugins/rebar3_sheldon/src/rebar3_sheldon_ast.erl"},
{line,23}]},
{rebar3_sheldon_prv,do,1,
[{file,"/Users/fernandobenavides/Projects/elbrujohalcon/test_app/_build/default/plugins/rebar3_sheldon/src/rebar3_sheldon_prv.erl"},
{line,58}]},
{rebar_core,do,2,
[{file,"/home/runner/work/rebar3/rebar3/src/rebar_core.erl"},
{line,155}]},
{rebar3,run_aux,2,
[{file,"/home/runner/work/rebar3/rebar3/src/rebar3.erl"},{line,182}]},
{rebar3,main,1,
[{file,"/home/runner/work/rebar3/rebar3/src/rebar3.erl"},{line,66}]},
{escript,run,2,[{file,"escript.erl"},{line,758}]}]
The command not crashing.
rebar3_sheldon
versionOS
versionmacOS 11.6
Motivation
ignore_regex
is good to avoid analyzing small strings based on their content (i.e. strings with paths, versions, etc…) but sometimes it ignores too much. For instance, if I want to skip the io:format
modifiers (like ~tp
or ~B
) by adding ~[tB]
to ignore_regex
, I end up skipping the analysis of the whole string. And those strings in particular (error messages, for instance), are one of the most important ones to spell-check.
Proposal
Instead of (…or maybe besides) passing ignore_regex
to Sheldon to ignore strings entirely, use it on the results that Sheldon returns, to discard those where the word matches the regex.
If we implement #25 using maps, we can even make that structure more complex and allow the user to define what they want, e.g.…
{spellcheck,
[{ignore_regexes,
#{eunit_files => #{regex => "eunit", applies_to => [entire, strings]},
maps_in_comments => #{regex => "=>", applies_to => [entire, comments]},
io_format_stuff => #{regex => "~[tpBw]", applies_to => [words_in, strings]},
semver => #{regex => "~>", applies_to => [entire, strings]},
paths => #{regex => "[a-z]/[a-z]", applies_to => [words_in, strings_or_comments]},
…
}]}.
rebar3_sheldon
versionOS
versionmacOS 11.6
$ rebar3 spellcheck
===> …some bazinga…
…
$
$ rebar3 spellcheck
$
(Nothing is printed out)
$ rebar3 spellcheck
===> Sheldon is reading your files...
===> …some bazinga…
…
$
$ rebar3 spellcheck
===> Sheldon is reading your files...
$
This is how rebar3_hank
does it…
rebar_api:info("Looking for code to kill with fire...", []),
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.