Comments (12)
I'd like to give this a go, if still deemed valuable. I believe the proper syntax would be:
{elvis_style, no_macros, #{allowed_macros => ["EXCEPTION_1", "EXCEPTION_2"], ignore => [module_1, module_2]}}
In any case, it will surely bring up a lot of results in any given project, so either the ignore list will become huge (and every time you add a macro you have to allow it) or consumers will just disable the rule (unless you meant not having it enabled by default, which is also valid).
from elvis_core.
I would say "Go ahead, my brave fellow!!", but don't include the rule in the erl_files
ruleset just yet.
Maybe… if people want to use this rule, but still have some macros… they can put the macros in an hrl file that's not checked with this rule… Not that I like that solution, just saying that it will exist 🙈
from elvis_core.
Oh, the rule will check for macro usage, not macro definition… 🤔 … In that case, my solution doesn't work. 🤷
from elvis_core.
Yeah, seems feasible. I'll preemptively assign it to me.
from elvis_core.
There's a chance this'll eventually use some of the code from #131, since the latter messes with macro identification (we will need the list of built-in macros somewhere, right?).
from elvis_core.
Like… here, you mean?
from elvis_core.
Like… here, you mean?
Yes. I'd like it to be available by code, but we can start with that 😄
from elvis_core.
Like this then… but exported 😢
from elvis_core.
Like this then… but exported 😢
That'd be sweet. Let me ask around.
from elvis_core.
For reference...
Something (undocumented) like this is also possible
1> {ok, Epp} = epp:open("**REDACTED**/rebar3_hex/src/rebar3_hex.erl", []).
{ok,<0.84.0>}
2> epp:macro_defs(Epp).
[{{atom,'BASE_MODULE'},undefined},
{{atom,'BASE_MODULE_STRING'},undefined},
{{atom,'BEAM'},{none,[{atom,1,true}]}},
{{atom,'FILE'},
{none,[{string,1,
"**REDACTED**/rebar3_hex/src/rebar3_hex.erl"}]}},
{{atom,'FUNCTION_ARITY'},undefined},
{{atom,'FUNCTION_NAME'},undefined},
{{atom,'LINE'},{none,[{integer,1,1}]}},
{{atom,'MACHINE'},{none,[{atom,1,'BEAM'}]}},
{{atom,'MODULE'},undefined},
{{atom,'MODULE_STRING'},undefined},
{{atom,'OTP_RELEASE'},{none,[{integer,1,21}]}}]
from elvis_core.
HA! That's super-hacky… I like it. It should go into katana-code
from elvis_core.
I've moved to implement this, thus the last change ("removed their assignment now").
from elvis_core.
Related Issues (20)
- Unused Variable Names HOT 5
- no_match_in_condition reports a warning even when the condition includes a valid match
- Bug (?) in atom_naming_convention HOT 2
- Using ets:fun2ms without including ms_transform.hrl should be an error HOT 3
- New ruleset `gitignore`
- Propose `gen_server` et all "no-timeout" functions as `no_common_caveats`?
- Have a simple way to run `all` checks (even optional ones) HOT 8
- New rule: consistent file names HOT 2
- New Rule: No Import Type
- New Rule: Unsafe usage of application HOT 1
- Wildcards in no_call_functions MFA HOT 4
- Potential new rule: only call internal_export'ed functions from test code HOT 2
- No consecutive strings
- Rule: Do not use lists on start_link/3,4 and init/1 HOT 3
- no_successive_maps obsolete due to Erlang change?
- New rule: consistent deps applications HOT 3
- max_function_length counts multiple function clauses as a single function HOT 2
- Count `_to_atom` as common caveats? HOT 2
- Should `no_macros` consider `LOG_...` as allowed? HOT 3
- no_successive_maps doesn't work when nested
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elvis_core.