-
Notifications
You must be signed in to change notification settings - Fork 52
Conversation
a9e9479
to
3d50aef
Compare
defmodule Dogma.Rule.CommentFormat do | ||
use Dogma.RuleBuilder | ||
|
||
defrule Dogma.Rule.CommentFormat, [] do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comment but if there are no default config values maybe
defrule Dogma.Rule.CommentFormat do
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I should do that.
69e80b5
to
58c6ee0
Compare
de815df
to
bb95e98
Compare
Care to review? Also, do you know how to go from a module atom name to the struct for that module? i.e. assert transform(LineLength) == %LineLength{} I can't work it out. |
@lpil I think the kernel function |
Ah, thanks! I didn't think to look in kernel. :) |
Dict.put( rules, rule, config ) | ||
|
||
defp insert_rule({rule_name, config}, acc) | ||
when is_atom(rule_name) and is_list(config) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 like this approach to updating the config style. Neat way of emitting deprecations and the whole method can just be removed at the next major version bump.
One thing I'd think about though is whether it'd be better to do this as a logger.warn rather than just an IO.put. As it is a warning not just a message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the logger isn't running. I could add it but then I need to backport ExUnit.CaptureLog
, as it isn't present in 1.0 :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see. That's a shame. In any case what you've done should still be useful.
970278a
to
f37468a
Compare
|
||
defstruct unquote(opts) | ||
unquote(module_ast) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if test/2 isn't defined? Does it error on compile? (please ignore all of the following if it does error). One thought is to add a rule @behaviour so this starts something like:
quote do
defmodule unquote(name) do
alias Dogma.Error
alias Dogma.Script
@behaviour Dogma.RuleBehaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It compiles and crashes at runtime. I'll add the behaviour so it compiles with a warning.
A few comments from me but generally this approach looks really good. I like that the script module got smaller and more focussed. |
Thanks Steve! |
Dispatch to rules using a protocol.
See #171
Breaking changes ahoy.
Dogma.Rule
protocoldefrule
macroRule.Case
test macrodefrule
Rule.Case