Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function clause when rule is disabled #384

Closed
anton-b opened this issue Jul 14, 2016 · 5 comments
Closed

Function clause when rule is disabled #384

anton-b opened this issue Jul 14, 2016 · 5 comments
Assignees

Comments

@anton-b
Copy link

anton-b commented Jul 14, 2016

./elvis --version
...
Version: 0.2.11

elvis.config:

[
 {
   elvis,
   [
    {config,
     [#{dirs => ["src"],
        ignore => [".*_tests"],
        filter => "*.erl",
        rules => [{elvis_style, line_length, #{limit => 120,
                                               skip_comments => false}},
                  {elvis_style, no_tabs},
                  {elvis_style, no_trailing_whitespace},
                  {elvis_style, macro_names},
                  {elvis_style, macro_module_names},
                  {elvis_style, operator_spaces},
                  {elvis_style, nesting_level, #{level => 5}},
                  {elvis_style, god_modules, #{limit => 25}},
                  {elvis_style, no_if_expression},
                  {elvis_style, invalid_dynamic_call, #{ignore => [elvis]}},
                  {elvis_style, used_ignored_variable},
                  {elvis_style, no_behavior_info},
                  {
                    elvis_style,
                    module_naming_convention,
                    #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$",
                      ignore => []}
                  },
                  {elvis_style, state_record_and_type, disable},
                  {elvis_style, dont_repeat_yourself, #{min_complexity => 21}}
                 ]
       },
      #{dirs => ["."],
        filter => "Makefile",
        rules => [{elvis_project, no_deps_master_erlang_mk, #{ignore => []}},
                  {elvis_project, protocol_for_deps_erlang_mk, #{ignore => []}}]
       },
      #{dirs => ["."],
        filter => "rebar.config",
        rules => [%%{elvis_project, no_deps_master_rebar, #{ignore => []}},
                  %%{elvis_project, protocol_for_deps_rebar, #{ignore => []}}
                 ]
       },
      #{dirs => ["."],
        filter => "elvis.config",
        rules => [{elvis_project, old_configuration_format}]
       }
     ]
    }
   ]
 }
].

Causing error:

escript: exception error: no function clause matching
                 elvis_core:ensure_config_map(elvis_style,
                                              state_record_and_type,disable) (src/elvis_core.erl, line 153)
  in function  elvis_core:apply_rule/2 (src/elvis_core.erl, line 136)
  in call from lists:foldl/3 (lists.erl, line 1262)
  in call from elvis_core:apply_rules/2 (src/elvis_core.erl, line 127)
  in call from elvis_core:'-do_rock/1-lc$^0/1-0-'/2 (src/elvis_core.erl, line 90)
  in call from elvis_core:do_rock/1 (src/elvis_core.erl, line 90)
  in call from lists:map/2 (lists.erl, line 1238)
  in call from elvis_core:rock/1 (src/elvis_core.erl, line 40)
@jfacorro
Copy link
Contributor

jfacorro commented Jul 16, 2016

@GRAB3 What Erlang/OTP version are you using?

@anton-b
Copy link
Author

anton-b commented Jul 17, 2016

Hi it is OTP 18.1 i believe installed from brew on OS X el capitan.
UPDATE: Sorry was wrong it is 18.3:

brew list erlang
/usr/local/Cellar/erlang/18.3/bin/ct_run

erl --version
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

@Euen
Copy link
Member

Euen commented Jul 19, 2016

Hi @GRAB3 I'm afraid that you can't add the atom disable in the rule if you didn't specify a ruleset previously, in your case, you can use ruleset => erl_files. And it would be something like this

[
 {
   elvis,
   [
    {config,
     [#{dirs => ["src"],
        ignore => [".*_tests"],
        filter => "*.erl",
        ruleset => erl_files,
        rules => [{elvis_style, line_length, #{limit => 120,
                                               skip_comments => false}},
                  {elvis_style, no_tabs},
                  {elvis_style, no_trailing_whitespace},
                  {elvis_style, macro_names},
                  {elvis_style, macro_module_names},
                  {elvis_style, operator_spaces},
                  {elvis_style, nesting_level, #{level => 5}},
                  {elvis_style, god_modules, #{limit => 25}},
                  {elvis_style, no_if_expression},
                  {elvis_style, invalid_dynamic_call, #{ignore => [elvis]}},
                  {elvis_style, used_ignored_variable},
                  {elvis_style, no_behavior_info},
                  {
                    elvis_style,
                    module_naming_convention,
                    #{regex => "^([a-z][a-z0-9]*_?)*(_SUITE)?$",
                      ignore => []}
                  },
                  {elvis_style, state_record_and_type, disable},
                  {elvis_style, dont_repeat_yourself, #{min_complexity => 21}}
                 ]
       },
      #{dirs => ["."],
        filter => "Makefile",
        rules => [{elvis_project, no_deps_master_erlang_mk, #{ignore => []}},
                  {elvis_project, protocol_for_deps_erlang_mk, #{ignore => []}}]
       },
      #{dirs => ["."],
        filter => "rebar.config",
        rules => [%%{elvis_project, no_deps_master_rebar, #{ignore => []}},
                  %%{elvis_project, protocol_for_deps_rebar, #{ignore => []}}
                 ]
       },
      #{dirs => ["."],
        filter => "elvis.config",
        rules => [{elvis_project, old_configuration_format}]
       }
     ]
    }
   ]
 }
].

@anton-b
Copy link
Author

anton-b commented Jul 20, 2016

Thanks works perfectly. I think, it would also be useful to mention it somewhere in documentation that ruleset => specification is mandatory for correct functioning, or mention that "old" config syntax does not support disable keyword(instead you should just not specify rule).

@Euen
Copy link
Member

Euen commented Jul 20, 2016

You're right @GRAB3 I've already added (elvis_core), thanks for the recommendation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants