mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-14 18:51:34 +03: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 `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:
|
* 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:
|
But **never** this:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
@ -132,8 +142,8 @@ attributes to make it work in Markdown renderers that strip "id". -->
|
|||||||
as well.
|
as well.
|
||||||
|
|
||||||
* Don't use `fmt.Sprintf` where a more structured approach to string
|
* Don't use `fmt.Sprintf` where a more structured approach to string
|
||||||
conversion could be used. For example, `net.JoinHostPort` or
|
conversion could be used. For example, `aghnet.JoinHostPort`,
|
||||||
`url.(*URL).String`.
|
`net.JoinHostPort` or `url.(*URL).String`.
|
||||||
|
|
||||||
* Don't use naked `return`s.
|
* 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
|
* Prefer constants to variables where possible. Avoid global variables. Use
|
||||||
[constant errors] instead of `errors.New`.
|
[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.
|
* Prefer to use named functions for goroutines.
|
||||||
|
|
||||||
* Program code lines should not be longer than one hundred (**100**) columns.
|
* 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>
|
### <a href="#formatting" id="formatting" name="formatting">Formatting</a>
|
||||||
|
|
||||||
* Decorate `break`, `continue`, `fallthrough`, `return`, and other terminating
|
* Decorate `break`, `continue`, `return`, and other terminating statements
|
||||||
statements with empty lines unless it's the only statement in that block.
|
with empty lines unless it's the only statement in that block.
|
||||||
|
|
||||||
* Don't group type declarations together. Unlike with blocks of `const`s,
|
* 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,
|
where a `iota` may be used or where all constants belong to a certain type,
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
set -e -f -u
|
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' )" ]
|
if [ "$( git diff --cached --name-only -- 'client/*.js' )" ]
|
||||||
then
|
then
|
||||||
make js-lint js-test
|
make js-lint js-test
|
||||||
|
Loading…
Reference in New Issue
Block a user