mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-15 18:08:30 -07:00
Pull request: all: imp hacking, hooks
Merge in DNS/adguard-home from imp-hacking to master Squashed commit of the following: commit fcc0740526948256b5b356a3a7969e00baa35ff7 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Jun 28 18:16:57 2021 +0300 all: imp hacking, hooks
This commit is contained in:
parent
28f34ca399
commit
9d1656b5c1
23
HACKING.md
23
HACKING.md
@ -77,7 +77,8 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
||||
|
||||
* Avoid `init` and use explicit initialization functions instead.
|
||||
|
||||
* Avoid `new`, especially with structs.
|
||||
* Avoid `new`, especially with structs, unless a temporary value is needed,
|
||||
for example when checking the type of an error using `errors.As`.
|
||||
|
||||
* Check against empty strings like this:
|
||||
|
||||
@ -119,6 +120,15 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
||||
)
|
||||
```
|
||||
|
||||
Or, with a struct literal:
|
||||
|
||||
```go
|
||||
err := functionWithALongName(arg, structType{
|
||||
field1: val1,
|
||||
field2: val2,
|
||||
})
|
||||
```
|
||||
|
||||
But **never** this:
|
||||
|
||||
```go
|
||||
@ -132,8 +142,8 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
||||
as well.
|
||||
|
||||
* Don't use `fmt.Sprintf` where a more structured approach to string
|
||||
conversion could be used. For example, `net.JoinHostPort` or
|
||||
`url.(*URL).String`.
|
||||
conversion could be used. For example, `aghnet.JoinHostPort`,
|
||||
`net.JoinHostPort` or `url.(*URL).String`.
|
||||
|
||||
* Don't use naked `return`s.
|
||||
|
||||
@ -155,6 +165,9 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
||||
* Prefer constants to variables where possible. Avoid global variables. Use
|
||||
[constant errors] instead of `errors.New`.
|
||||
|
||||
* Prefer defining `Foo.String` and `ParseFoo` in terms of `Foo.MarshalText`
|
||||
and `Foo.UnmarshalText` correspondingly and not the other way around.
|
||||
|
||||
* Prefer to use named functions for goroutines.
|
||||
|
||||
* Program code lines should not be longer than one hundred (**100**) columns.
|
||||
@ -198,8 +211,8 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
||||
|
||||
### <a href="#formatting" id="formatting" name="formatting">Formatting</a>
|
||||
|
||||
* Decorate `break`, `continue`, `fallthrough`, `return`, and other terminating
|
||||
statements with empty lines unless it's the only statement in that block.
|
||||
* Decorate `break`, `continue`, `return`, and other terminating statements
|
||||
with empty lines unless it's the only statement in that block.
|
||||
|
||||
* Don't group type declarations together. Unlike with blocks of `const`s,
|
||||
where a `iota` may be used or where all constants belong to a certain type,
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
set -e -f -u
|
||||
|
||||
# Show all temporary todos to the programmer but don't fail the commit
|
||||
# if there are any, because the commit could be in a temporary branch.
|
||||
git grep -e 'TODO.*!!' -- ':!HACKING.md' ':!scripts/hooks/pre-commit' | more || :
|
||||
|
||||
if [ "$( git diff --cached --name-only -- 'client/*.js' )" ]
|
||||
then
|
||||
make js-lint js-test
|
||||
|
Loading…
Reference in New Issue
Block a user