|
60 | 60 |
|
61 | 61 | -type config() :: [{atom(), term()}].
|
62 | 62 |
|
| 63 | +-if(?OTP_RELEASE < 27). |
| 64 | + |
| 65 | +%% The `verify_max_module_length_docs/3` test only runs on OTP >= 27 because |
| 66 | +%% the `-moduledoc` and `-doc` attributes were introduced in OTP-27. |
| 67 | +-hank([{unnecessary_function_arguments, [{verify_max_module_length_docs, 3}]}]). |
| 68 | + |
| 69 | +-endif. |
| 70 | + |
63 | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
64 | 72 | %% Common test
|
65 | 73 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
@@ -990,50 +998,85 @@ verify_max_module_length(Config) ->
|
990 | 998 |
|
991 | 999 | PathFail = "fail_max_module_length." ++ Ext,
|
992 | 1000 |
|
993 |
| - CountAllRuleConfig = #{count_comments => true, count_whitespace => true}, |
| 1001 | + CountAllRuleConfig = |
| 1002 | + #{count_comments => true, |
| 1003 | + count_whitespace => true, |
| 1004 | + count_docs => true}, |
994 | 1005 |
|
995 |
| - ct:comment("Count whitespace and comment lines"), |
996 |
| - RuleConfig = CountAllRuleConfig#{max_length => 10}, |
| 1006 | + ct:comment("Count whitespace, comment, and documentation lines"), |
| 1007 | + RuleConfig = CountAllRuleConfig#{max_length => 18}, |
997 | 1008 |
|
998 | 1009 | [_] = elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig, PathFail),
|
999 | 1010 |
|
1000 |
| - RuleConfig1 = CountAllRuleConfig#{max_length => 14}, |
| 1011 | + RuleConfig1 = CountAllRuleConfig#{max_length => 22}, |
1001 | 1012 | [_] =
|
1002 | 1013 | elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig1, PathFail),
|
1003 | 1014 |
|
1004 |
| - RuleConfig2 = CountAllRuleConfig#{max_length => 15}, |
| 1015 | + RuleConfig2 = CountAllRuleConfig#{max_length => 23}, |
1005 | 1016 | [] = elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig2, PathFail),
|
1006 | 1017 |
|
1007 | 1018 | ct:comment("Don't count whitespace lines"),
|
1008 | 1019 | WhitespaceRuleConfig = CountAllRuleConfig#{count_whitespace => false},
|
1009 | 1020 |
|
1010 |
| - RuleConfig3 = WhitespaceRuleConfig#{max_length => 3}, |
| 1021 | + RuleConfig3 = WhitespaceRuleConfig#{max_length => 12}, |
1011 | 1022 | [_] =
|
1012 | 1023 | elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig3, PathFail),
|
1013 | 1024 |
|
1014 |
| - RuleConfig4 = WhitespaceRuleConfig#{max_length => 4}, |
| 1025 | + RuleConfig4 = WhitespaceRuleConfig#{max_length => 13}, |
1015 | 1026 | [_] =
|
1016 | 1027 | elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig4, PathFail),
|
1017 | 1028 |
|
1018 |
| - RuleConfig5 = WhitespaceRuleConfig#{max_length => 5}, |
| 1029 | + RuleConfig5 = WhitespaceRuleConfig#{max_length => 14}, |
1019 | 1030 | [] = elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig5, PathFail),
|
1020 | 1031 |
|
1021 | 1032 | ct:comment("Don't count comment or whitespace lines"),
|
1022 | 1033 | NoCountRuleConfig = WhitespaceRuleConfig#{count_comments => false},
|
1023 | 1034 |
|
1024 |
| - RuleConfig6 = NoCountRuleConfig#{max_length => 1}, |
| 1035 | + RuleConfig6 = NoCountRuleConfig#{max_length => 10}, |
1025 | 1036 | [_] =
|
1026 | 1037 | elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig6, PathFail),
|
1027 | 1038 |
|
1028 |
| - RuleConfig7 = NoCountRuleConfig#{max_length => 2}, |
| 1039 | + RuleConfig7 = NoCountRuleConfig#{max_length => 11}, |
1029 | 1040 | [_] =
|
1030 | 1041 | elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig7, PathFail),
|
1031 | 1042 |
|
1032 |
| - RuleConfig8 = NoCountRuleConfig#{max_length => 3}, |
| 1043 | + RuleConfig8 = NoCountRuleConfig#{max_length => 12}, |
1033 | 1044 | [] = elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig8, PathFail),
|
1034 | 1045 |
|
| 1046 | + ok = verify_max_module_length_docs(PathFail, CountAllRuleConfig, Config), |
| 1047 | + |
1035 | 1048 | {comment, ""}.
|
1036 | 1049 |
|
| 1050 | +%% The `verify_max_module_length_docs/3` test only runs on OTP >= 27 because |
| 1051 | +%% the `-moduledoc` and `-doc` attributes were introduced in OTP-27. |
| 1052 | +-spec verify_max_module_length_docs(file:filename(), map(), config()) -> ok. |
| 1053 | +-if(?OTP_RELEASE >= 27). |
| 1054 | + |
| 1055 | +verify_max_module_length_docs(PathFail, CountAllRuleConfig, Config) -> |
| 1056 | + ct:comment("Don't count -moduledoc and -doc attributes"), |
| 1057 | + DocsRuleConfig = CountAllRuleConfig#{count_docs => false}, |
| 1058 | + |
| 1059 | + RuleConfig9 = DocsRuleConfig#{max_length => 9}, |
| 1060 | + [_] = |
| 1061 | + elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig9, PathFail), |
| 1062 | + |
| 1063 | + RuleConfig10 = DocsRuleConfig#{max_length => 17}, |
| 1064 | + [_] = |
| 1065 | + elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig10, PathFail), |
| 1066 | + |
| 1067 | + RuleConfig11 = DocsRuleConfig#{max_length => 18}, |
| 1068 | + [] = |
| 1069 | + elvis_core_apply_rule(Config, elvis_style, max_module_length, RuleConfig11, PathFail), |
| 1070 | + |
| 1071 | + ok. |
| 1072 | + |
| 1073 | +-else. |
| 1074 | + |
| 1075 | +verify_max_module_length_docs(_PathFail, _CountAllRuleConfig, _Config) -> |
| 1076 | + ok. |
| 1077 | + |
| 1078 | +-endif. |
| 1079 | + |
1037 | 1080 | -spec verify_max_function_arity(config()) -> any().
|
1038 | 1081 | verify_max_function_arity(Config) ->
|
1039 | 1082 | Ext = proplists:get_value(test_file_ext, Config, "erl"),
|
|
0 commit comments