Git Product home page Git Product logo

rebar3_sheldon's Introduction

rebar3_sheldon

Hex.pm Version Hex.pm Downloads Build Status Erlang Versions

A rebar plugin for spellchecking code with Sheldon.

Build

$ rebar3 compile

Use

Add the plugin to your rebar config:

{project_plugins, [{rebar3_sheldon, "~> 0.3.1"}]}.

Then just call your plugin directly in an existing application:

$ rebar3 spellcheck
===> Fetching rebar3_sheldon
===> Compiling rebar3_sheldon
===> Youre welcome. And if he has twins, we can do all kinds of neat experiments on them.:
test/test_SUITE.erl:1: The word "Speling" in string is unknown. Maybe you wanted to use "speeling" or "speiling" or ....?
test/test_SUITE.erl:2: The word "fdfdf" in string is unknown.
test/test_SUITE.erl:3: The word "Unicode" in comment is unknown. Maybe you wanted to use "uncoded"?

Command line

Arguments List

$ rebar3 -h spellcheck
Plugin for spellcheck by sheldon
Usage: rebar3 spellcheck [-f <files>] [-i <ignore>] [-r <ignore_regex>]
                         [-d <default_dictionary>]
                         [-a <additional_dictionaries>]

  -f, --files                    List of files for spellchecker
  -i, --ignore                   List of ignore files for spellchecker
  -r, --ignore_regex             Regular exemptions for ignore lines
  -d, --default_dictionary       Set default dictionary
  -a, --additional_dictionaries  List of additional dictionaries

Short full example

$ rebar3 spellcheck -f 'src/*.erl, test/*erl' -i 'include/*.hrl' -r '[_@./#&+-=%*]' -d 'path/to/dict.txt' -a 'path/to.txt, additional_dict_1.txt'`

Config

Description

By default, the dictionary used is the one provided by sheldon. If you need to use a custom list of files for spellchecking, use the config option files. If you need to ignore some files for spellchecking, use the config option ignore. If you need to ignore some particular strings or comments in your modules, use ignore_regex to set regular expressions and ignore the lines that match them. If you want to directly replace Sheldon's dictionary with your own one, you can replace using the config option default_dictionary. If you need to expand Sheldon's dictionary with your own words, use the additional_dictionaries option pointing to your own dictionaries with which you want to expand Sheldon's.

Options

Currently supported options for spellcheck configuration through rebar.config:

Name Type Description
files [string(), ...] List of files for spellchecker
ignore [string(), ...] List of ignore files for spellchecker
ignore_regex string() Regular exemptions for ignore lines
default_dictionary string() Set default dictionary
additional_dictionaries [string(), ...] List of additional dictionaries

Default

{spellcheck, [
    {files, ["include/**/*.[he]rl",
             "include/**/*.app.src",
             "src/**/*.[he]rl",
             "src/**/*.app.src",
             "test/**/*.[he]rl",
             "test/**/*.app.src",
             "{rebar,elvis,sys}.config"]}
]}.

Example

{spellcheck, [
    {files, ["src/*.erl", "src/*/*.erl", "include/*.hrl"]},
    {ignore, ["src/*_ignore.erl"]},
    {ignore_regex, "[_@./#&+-=%*]"},
    {default_dictionary, "path/to/default_dictionary.txt"},
    {additional_dictionaries, ["path/to/custom_dictionary_1.txt", "path/to/custom_dictionary_2.txt"]}
]}.

Dependencies

Required OTP version 23 or or higher. We only provide guarantees that the system runs on OTP23+ since that's what we're testing it in, but the minimum_otp_vsn is "21" because some systems where rebar3_sheldon is integrated do require it.

rebar3_sheldon's People

Contributors

paulo-ferraz-oliveira avatar vkatsuba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

davidalphafox

rebar3_sheldon's Issues

The word XXX in string is unknown. Maybe you wanted to use XXX? 🧐

rebar3_sheldon version

Put release version here and update tag link(0.0.0) ...

OS version

Steps to reproduce

Run the spellchecker on Spillway

Current behavior

Among other warnings…

src/spillway.app.src:7: The word "Github" in string is unknown. Maybe you wanted to use "Github"?

Expected behavior

To accept Github as a valid word.

Config

{spellcheck,
 [{ignore_regex, "(eunit|~>|--|==|\\^|_|//|\\d[.]\\d)"},
  {files, ["src/*", "test/*"]},
  {additional_dictionaries, ["nextroll.dict"]}]}.

and nextroll.dict is…

AdRoll
Github
rebar3
Pena
Watters
NONINFRINGEMENT

Allow uppercase words in the dictionaries

rebar3_sheldon version

0.3.1

OS version

macOS 11.6.1

Description

  • Motivation
    When reading the dictionary associated with a project, one might sometimes find themselves for a second wondering what a word that is usually wrote in uppercase is, as you will find it in lowercase in the dictionary. For example, asts (ASTs).
  • Proposal
    Allow uppercase words in the dictionaries and lowercase (string:lowercase/1) them when reading the dictionary files.

Allow for multiple regexes instead of just one

rebar3_sheldon version

0.3.1

OS version

macOS 11.6

Description

  • 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|_|~>|…"}]}.

Add more common words to the default dictionary

rebar3_sheldon version

0.3.1

OS version

macOS 11.6

Description

  • Motivation
    There are some really common words in all Erlang projects that can totally be added to the default dictionary so we don't have to add them ourselves in each project.
  • Proposal
    Add the following words to the default dict:
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

Ignore individual words, not entire strings

rebar3_sheldon version

0.3.1

OS version

macOS 11.6

Description

  • 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]},
      …
    }]}.

Ignore more strings by default

rebar3_sheldon version

0.3.1

OS version

macOS 11.6

Description

  • 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.

Output "rebar3_sheldon analysis starting, this may take a while..." at the start of execution

rebar3_sheldon version

0.4.2

OS version

macOS 13.5.1

Description

  • Motivation

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).

  • Proposal

Give the consumer a notice about the plugin taking a while to load/execute.

Current behavior

rebar3_sheldon runs with no indication of "taking a long time".

Expected behavior

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.dialyzerorrebar3_lint`.

Config

None available.

Tag `ignore_spelling`

rebar3_sheldon version

0.3.1

OS version

Ubuntu

Description

  • Motivation
    Provide enable for users to ignore spell check for specific features.
  • Proposal
    Add support of ignoring spell check for functions by new tag -ignore_spelling([this_function/1, …]).

Current behavior

Ignore tag is not supported.

Expected behavior

Ignore tag is supported.

The plugin chokes on comments including unicode characters

rebar3_sheldon version

0.1.0

OS version

macOS 11.6

Steps to reproduce

  1. Create the following module:
-module(break).

%% this comment: ’
  1. Run rebar3 spellcheck on it

Current behavior

===> 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}]}]

Expected behavior

The command not crashing.

Extended logging

rebar3_sheldon version

0.4.2

OS version

macOS 11.6

Description

  • Motivation
    I want this plugin to be more similar to others.
    As a user, I want to know when the plugin is running.
  • Proposal
    Add an extra message on the logs when the plugin starts running, similar to what other plugins do…

Current behavior

  • If there are warnings
$ rebar3 spellcheck
===> …some bazinga…
…
$
  • If there are no warnings
$ rebar3 spellcheck
$

(Nothing is printed out)

Expected behavior

  • If there are warnings
$ rebar3 spellcheck
===> Sheldon is reading your files...
===> …some bazinga…
…
$
  • If there are no warnings
$ rebar3 spellcheck
===> Sheldon is reading your files...
$

Notes

This is how rebar3_hank does it…

    rebar_api:info("Looking for code to kill with fire...", []),

Improve documentation on configuration options

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.

More actionable output

rebar3_sheldon version

0.1.0

OS version

macOS 11.6

Description

  • Motivation
    I would like to be able to click on file names / line numbers on iTerm and open up my favorite editor to fix the issues.
    I would also like the output of this plugin to be more similar to other rebar3 commands, like xref, dialyzer, lint, format, etc…
  • Proposal
    Instead of dumping the warnings as returned by Sheldon, format them out nicely.

Current behavior

===> 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"}]},
…

Expected behavior

===> 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.

Raw output for unicode characters

rebar3_sheldon version

0.3.1

OS version

macOS 11.6

Steps to reproduce

  1. Create the following module:
-module(break).

%% this comment: ’
  1. Run rebar3 spellcheck on it

Current behavior

$ 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.

Expected behavior

$ 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.

--files on command line

rebar3_sheldon version

0.1.0

OS version

macOS 11.6

Description

  • 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.

Expected behavior

--files should override the value of the files option in rebar.config.

Add Windows CI

After fix compiling issue in sheldon on Windows it make sense add Windows CI into plugin too.

Warn on "no longer used" dictionary entries

rebar3_sheldon version

0.4.2

OS version

macOs Darwin Kernel Version 21.4.0

Description

  • Motivation

I want to keep my dictionaries as short as possible thus improving code maintenance.

  • Proposal

Warn on no-longer-used dictionary entries, with an indication of the dictionary file and line number for the warned-about entries.

Current behavior

Unused dictionary entries usually means these are ever growing.

Expected behavior

Check Proposal, above.

Config

n/a

Start use `erl_syntax` instead of `erl_scan`

rebar3_sheldon version

0.3.1

OS version

Ubuntu

Description

  • Motivation
    Add more flexibility of working with AST.
  • Proposal
    Start use 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.

Current behavior

Used erl_scan.

Expected behavior

Used erl_syntax.

Per-Project Dictionary

rebar3_sheldon version

0.1.0

OS version

macOS 11.6

Description

  • Motivation
    I want to be able to add to each of my projects a text file with extra words that are valid only for it. I want rebar3_sheldon to pick it up and add them to the global dictionary that it uses.
  • Proposal
  • Add a {custom_dictionary, "/path/to/file.dict"} option to the spellcheck section in rebar.config.
  • Pick that value up and pass it over to sheldon to combine it with the official dictionary it uses.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.