1
1
defmodule HarnessDotfiles do
2
+ @ schema [
3
+ coveralls_skip_files: [
4
+ doc: """
5
+ A list of file regex patterns to ignore for coveralls coverage checking.
6
+ """ ,
7
+ type: { :list , :string } ,
8
+ default: [ "^test" , "^deps" , "^.harness" ]
9
+ ] ,
10
+ coveralls_minimum_coverage: [
11
+ doc: """
12
+ The minimum percentage of coverage to require for a successful coveralls
13
+ coverage report.
14
+ """ ,
15
+ type: { :custom , __MODULE__ , :parse_number , [ ] } ,
16
+ default: 100
17
+ ] ,
18
+ explicit_credo_checks: [
19
+ doc: """
20
+ A list of explicit checks to pass to the credo `:checks` configuration.
21
+ Checks in this list will merge on top of the defaults provided in the
22
+ `.credo.exs` template provided by this harness package. To disable a
23
+ check, add an element to the list: `{CheckName, false}`.
24
+ """ ,
25
+ type: { :list , { :custom , __MODULE__ , :parse_tuple , [ ] } } ,
26
+ default: [ ]
27
+ ] ,
28
+ excluded_paths_for_modulename_matches_filename: [
29
+ doc: """
30
+ A list of elixir Regexs used to ignore files and directories from the
31
+ Convene ModulenameMatchesFilename check. Useful for ignoring directories
32
+ containing modules with Phoenix naming conventions.
33
+ """ ,
34
+ type: { :list , { :custom , __MODULE__ , :parse_regex , [ ] } } ,
35
+ default: [ ]
36
+ ] ,
37
+ asdf_elixir_version: [
38
+ doc: """
39
+ The version of elixir to use, as passed to `asdf`.
40
+ """ ,
41
+ type: :string ,
42
+ default: "1.11.2-otp-23"
43
+ ] ,
44
+ asdf_erlang_version: [
45
+ doc: """
46
+ The version of erlang to use, as passed to `asdf`.
47
+ """ ,
48
+ type: :string ,
49
+ default: "23.2"
50
+ ] ,
51
+ asdf_other_versions: [
52
+ doc: """
53
+ Other versions to include in the local `.tool-versions` file used by
54
+ `asdf`. E.g. `["nodejs 12.13.1"]` will add Node to the local `asdf`
55
+ requirements.
56
+ """ ,
57
+ type: { :list , :string } ,
58
+ default: [ ]
59
+ ] ,
60
+ formatter_deps: [
61
+ doc: """
62
+ The list of dependencies from which to import formatter config. Some
63
+ dependencies like `:projection` or `:phoenix` export formatter
64
+ configuration, like which functions or macros should be allowed to not
65
+ have parentheses.
66
+ """ ,
67
+ type: { :list , :atom } ,
68
+ default: [ ]
69
+ ] ,
70
+ formatter_locals_without_parens: [
71
+ doc: """
72
+ A keyword list of function/macro names and arities allowed to not have
73
+ parentheses in the local project. E.g. `[foo: 2]` will allow calls to
74
+ `foo/2` to not need parentheses, as in `foo :bar, :baz`.
75
+ """ ,
76
+ type: :keyword_list ,
77
+ default: [ ]
78
+ ]
79
+ ]
80
+
2
81
@ moduledoc """
3
82
A harness for a common collection of dotfiles
83
+
84
+ The options are:
85
+
86
+ #{ NimbleOptions . docs ( @ schema ) }
4
87
"""
5
88
6
89
@ behaviour Harness.Pkg
7
90
8
- defstruct coveralls_skip_files: [ "^test" , "^deps" , "^.harness" ] ,
9
- coveralls_minimum_coverage: 100 ,
10
- explicit_credo_checks: [ ] ,
11
- excluded_paths_for_modulename_matches_filename: [ ] ,
12
- asdf_elixir_version: "1.11.2-otp-23" ,
13
- asdf_erlang_version: "23.2" ,
14
- asdf_other_versions: [ ] ,
15
- formatter_deps: [ ] ,
16
- formatter_locals_without_parens: [ ]
91
+ defstruct ~w[
92
+ coveralls_skip_files
93
+ coveralls_minimum_coverage
94
+ explicit_credo_checks
95
+ excluded_paths_for_modulename_matches_filename
96
+ asdf_elixir_version
97
+ asdf_erlang_version
98
+ asdf_other_versions
99
+ formatter_deps
100
+ formatter_locals_without_parens
101
+ ] a
17
102
103
+ @ doc false
18
104
@ impl Harness.Pkg
19
105
def cast ( opts ) do
20
- struct ( __MODULE__ , opts )
106
+ struct ( __MODULE__ , NimbleOptions . validate! ( opts , @ schema ) )
21
107
end
22
108
109
+ @ doc false
23
110
@ impl Harness.Pkg
24
111
def links ( _config ) do
25
112
~w[
@@ -29,4 +116,29 @@ defmodule HarnessDotfiles do
29
116
coveralls.json
30
117
]
31
118
end
119
+
120
+ @ doc false
121
+ def parse_number ( number ) when is_number ( number ) do
122
+ { :ok , number }
123
+ end
124
+
125
+ def parse_number ( unknown ) do
126
+ { :error , "must be a number (integer or float), got: #{ inspect ( unknown ) } " }
127
+ end
128
+
129
+ @ doc false
130
+ def parse_tuple ( tuple ) when is_tuple ( tuple ) do
131
+ { :ok , tuple }
132
+ end
133
+
134
+ def parse_tuple ( unknown ) do
135
+ { :error , "must be a tuple, got: #{ inspect ( unknown ) } " }
136
+ end
137
+
138
+ @ doc false
139
+ def parse_regex ( % Regex { } = regex ) , do: { :ok , regex }
140
+
141
+ def parse_regex ( unknown ) do
142
+ { :error , "must be a regex, got: #{ inspect ( unknown ) } " }
143
+ end
32
144
end
0 commit comments