Skip to content

Commit

Permalink
Adopt Erlfmt (#33)
Browse files Browse the repository at this point in the history
This is an attempt to define some consistent formatting rules for our Erlang code.

I made some research and I tested various options, so far the one that I prefer is [erlfmt](https://github.com/WhatsApp/erlfmt) from WhatsApp. Like most non-builtin formatters, this is opinionated. But the choices they made are well thought, and seem to be a good starting point.


You have both the option to reformat the code inline:

```
rebar3 fmt
```

or check the formatting:

```
rebar3 fmt --check
```

This last command is especially useful for CI integration.
  • Loading branch information
weppos authored Mar 19, 2024
1 parent 7f6f574 commit 02b97f2
Show file tree
Hide file tree
Showing 10 changed files with 3,231 additions and 1,926 deletions.
140 changes: 78 additions & 62 deletions include/dns_records.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,40 @@
-define('__dns_records.hrl__', ok).
-include("dns_terms.hrl").

-record(dns_message, {id = dns:random_id() :: dns:message_id(),
qr = false :: 0..1 | boolean(),
oc = ?DNS_OPCODE_QUERY :: dns:opcode(),
aa = false :: 0..1 | boolean(),
tc = false :: 0..1 | boolean(),
rd = false :: 0..1 | boolean(),
ra = false :: 0..1 | boolean(),
ad = false :: 0..1 | boolean(),
cd = false :: 0..1 | boolean(),
rc = ?DNS_RCODE_NOERROR :: dns:rcode(),
qc = 0 :: 0..65535,
anc = 0 :: 0..65535,
auc = 0 :: 0..65535,
adc = 0 :: 0..65535,
questions = [] :: dns:questions(),
answers = [] :: dns:answers(),
authority = [] :: dns:authority(),
additional = [] :: dns:additional()}).
-record(dns_message, {
id = dns:random_id() :: dns:message_id(),
qr = false :: 0..1 | boolean(),
oc = ?DNS_OPCODE_QUERY :: dns:opcode(),
aa = false :: 0..1 | boolean(),
tc = false :: 0..1 | boolean(),
rd = false :: 0..1 | boolean(),
ra = false :: 0..1 | boolean(),
ad = false :: 0..1 | boolean(),
cd = false :: 0..1 | boolean(),
rc = ?DNS_RCODE_NOERROR :: dns:rcode(),
qc = 0 :: 0..65535,
anc = 0 :: 0..65535,
auc = 0 :: 0..65535,
adc = 0 :: 0..65535,
questions = [] :: dns:questions(),
answers = [] :: dns:answers(),
authority = [] :: dns:authority(),
additional = [] :: dns:additional()
}).

-record(dns_query, {name :: dns:dname(),
class = ?DNS_CLASS_IN :: dns:class(),
type :: dns:type()}).
-record(dns_query, {
name :: dns:dname(),
class = ?DNS_CLASS_IN :: dns:class(),
type :: dns:type()
}).

-record(dns_rr, {name :: dns:dname(),
class = ?DNS_CLASS_IN :: dns:class(),
type :: dns:type(),
ttl = 0 :: dns:ttl(),
data :: dns:rrdata()}).
-record(dns_rr, {
name :: dns:dname(),
class = ?DNS_CLASS_IN :: dns:class(),
type :: dns:type(),
ttl = 0 :: dns:ttl(),
data :: dns:rrdata()
}).
-record(dns_rrdata_a, {ip}).
-record(dns_rrdata_aaaa, {ip}).
-record(dns_rrdata_afsdb, {subtype, hostname}).
Expand All @@ -45,10 +51,12 @@
-record(dns_rrdata_cds, {keytag, alg, digest_type, digest}).
-record(dns_rrdata_hinfo, {cpu, os}).
-record(dns_rrdata_https, {svc_priority, target_name, svc_params}).
-record(dns_rrdata_ipseckey, {precedence,
alg,
gateway,
public_key}).
-record(dns_rrdata_ipseckey, {
precedence,
alg,
gateway,
public_key
}).
-record(dns_rrdata_key, {type, xt, name_type, sig, protocol, alg, public_key}).
-record(dns_rrdata_kx, {preference, exchange}).
-record(dns_rrdata_loc, {size, horiz, vert, lat, lon, alt}).
Expand All @@ -57,58 +65,66 @@
-record(dns_rrdata_minfo, {rmailbx, emailbx}).
-record(dns_rrdata_mr, {newname}).
-record(dns_rrdata_mx, {preference, exchange}).
-record(dns_rrdata_naptr, {order,
preference,
flags,
services,
regexp,
replacement}).
-record(dns_rrdata_naptr, {
order,
preference,
flags,
services,
regexp,
replacement
}).
-record(dns_rrdata_ns, {dname}).
-record(dns_rrdata_nsec, {next_dname, types}).
-record(dns_rrdata_nsec3, {hash_alg, opt_out, iterations, salt, hash, types}).
-record(dns_rrdata_nsec3param, {hash_alg, flags, iterations, salt}).
-record(dns_rrdata_nxt, {dname, types}).
-record(dns_rrdata_ptr, {dname}).
-record(dns_rrdata_rp, {mbox, txt}).
-record(dns_rrdata_rrsig, {type_covered,
alg,
labels,
original_ttl,
expiration,
inception,
key_tag,
signers_name,
signature}).
-record(dns_rrdata_rrsig, {
type_covered,
alg,
labels,
original_ttl,
expiration,
inception,
key_tag,
signers_name,
signature
}).
-record(dns_rrdata_rt, {preference, host}).
-record(dns_rrdata_soa, {mname,
rname,
serial,
refresh,
retry,
expire,
minimum}).
-record(dns_rrdata_soa, {
mname,
rname,
serial,
refresh,
retry,
expire,
minimum
}).
-record(dns_rrdata_spf, {spf}).
-record(dns_rrdata_srv, {priority, weight, port, target}).
-record(dns_rrdata_sshfp, {alg, fp_type, fp}).
-record(dns_rrdata_svcb, {svc_priority, target_name, svc_params}).
-record(dns_rrdata_tsig, {alg, time, fudge, mac, msgid, err, other}).
-record(dns_rrdata_txt, {txt}).

-record(dns_optrr, {udp_payload_size = 4096,
ext_rcode = ?DNS_ERCODE_NOERROR,
version = 0,
dnssec = false,
data = []}).
-record(dns_optrr, {
udp_payload_size = 4096,
ext_rcode = ?DNS_ERCODE_NOERROR,
version = 0,
dnssec = false,
data = []
}).
-record(dns_opt_llq, {opcode, errorcode, id, leaselife}).
-record(dns_opt_nsid, {data}).
-record(dns_opt_owner, {seq = 0, primary_mac, wakeup_mac, password}).
-record(dns_opt_ul, {lease}).
-record(dns_opt_ecs, {
family,
source_prefix_length,
scope_prefix_length,
address
}).
family,
source_prefix_length,
scope_prefix_length,
address
}).
-record(dns_opt_unknown, {id, bin}).

-endif.
Loading

0 comments on commit 02b97f2

Please sign in to comment.