Skip to content

Commit f034630

Browse files
committed
ci(linting): update pre-commit hooks and add ignore for readme
1 parent b083b33 commit f034630

File tree

3 files changed

+83
-48
lines changed

3 files changed

+83
-48
lines changed

.pre-commit-config.yaml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,60 @@
1+
exclude: '^package.json|package-lock.json|.*?\.tsv$'
2+
fail_fast: true
13
repos:
2-
- repo: https://github.com/Contrast-Labs/detect-secrets
3-
rev: v1.1.2
4+
- repo: https://github.com/commitizen-tools/commitizen
5+
rev: v2.42.1
6+
hooks:
7+
- id: commitizen
8+
stages: [commit-msg]
9+
- repo: https://github.com/Yelp/detect-secrets
10+
rev: v1.4.0
411
hooks:
512
- id: detect-secrets
6-
name: Detect secrets
7-
language: python
8-
entry: detect-secrets-hook
913
args: ['--baseline', '.secrets.baseline']
14+
exclude: package.lock.json
15+
stages: [commit]
1016
- repo: https://github.com/golangci/golangci-lint
11-
rev: v1.49.0
17+
rev: v1.52.2
1218
hooks:
1319
- id: golangci-lint
14-
- repo: https://github.com/Bahjat/pre-commit-golang
20+
stages: [commit]
21+
- repo: https://github.com/Bahjat/pre-commit-golang
1522
rev: v1.0.3 # pragma: allowlist secret
1623
hooks:
1724
- id: go-unit-tests
25+
stages: [commit]
1826
- repo: https://github.com/pre-commit/pre-commit-hooks
19-
rev: v4.3.0
27+
rev: v4.4.0
2028
hooks:
2129
- id: check-json
22-
- id: check-added-large-files
30+
stages: [commit]
31+
#- id: no-commit-to-branch
32+
# args: ['--branch', 'main']
33+
# stages: [commit]
2334
- id: pretty-format-json
35+
args: ['--autofix']
36+
stages: [commit]
2437
- id: check-merge-conflict
38+
stages: [commit]
2539
- id: check-yaml
40+
stages: [commit]
2641
- repo: https://github.com/igorshubovych/markdownlint-cli
27-
rev: v0.32.2
42+
rev: v0.33.0
2843
hooks:
2944
- id: markdownlint-fix
30-
- repo: https://github.com/koalaman/shellcheck-precommit
31-
rev: v0.8.0
45+
stages: [commit]
46+
args: ["--ignore", "README.md"] # This is a generated file
47+
- repo: https://github.com/shellcheck-py/shellcheck-py
48+
rev: v0.9.0.2
49+
hooks:
50+
- id: shellcheck
51+
stages: [commit]
52+
- repo: https://github.com/pre-commit/mirrors-eslint
53+
rev: 'v8.36.0'
54+
hooks:
55+
- id: eslint
56+
stages: [commit]
57+
- repo: https://github.com/dnephin/pre-commit-golang
58+
rev: 'v0.5.1'
3259
hooks:
33-
- id: shellcheck
60+
- id: go-mod-tidy

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.1.2",
2+
"version": "1.4.0",
33
"plugins_used": [
44
{
55
"name": "ArtifactoryDetector"

README.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# stream
2+
23
--
34
import "."
45

@@ -49,16 +50,18 @@ var ErrFnRequired = fmt.Errorf("nil InterceptFunc, Fn is required")
4950
```go
5051
func Any[T any](ctx context.Context, in <-chan T) <-chan any
5152
```
53+
5254
Any accepts an incoming data channel and converts the channel to a readonly
5355
channel of the `any` type.
5456

5557
#### func Distribute
5658

5759
```go
5860
func Distribute[T any](
59-
ctx context.Context, in <-chan T, out ...chan<- T,
61+
ctx context.Context, in <-chan T, out ...chan<- T,
6062
)
6163
```
64+
6265
Distribute accepts an incoming data channel and distributes the data among the
6366
supplied outgoing data channels using a dynamic select statement.
6467

@@ -71,6 +74,7 @@ ensure that the goroutine is properly terminated.
7174
```go
7275
func Drain[T any](ctx context.Context, in <-chan T)
7376
```
77+
7478
Drain accepts a channel and drains the channel until the channel is closed or
7579
the context is canceled.
7680

@@ -79,6 +83,7 @@ the context is canceled.
7983
```go
8084
func FanIn[T any](ctx context.Context, in ...<-chan T) <-chan T
8185
```
86+
8287
FanIn accepts incoming data channels and forwards returns a single channel that
8388
receives all the data from the supplied channels.
8489

@@ -90,9 +95,10 @@ ensure that the goroutine is terminated.
9095

9196
```go
9297
func FanOut[T any](
93-
ctx context.Context, in <-chan T, out ...chan<- T,
98+
ctx context.Context, in <-chan T, out ...chan<- T,
9499
)
95100
```
101+
96102
FanOut accepts an incoming data channel and copies the data to each of the
97103
supplied outgoing data channels.
98104

@@ -104,11 +110,12 @@ ensure that the goroutine is properly terminated.
104110

105111
```go
106112
func Intercept[T, U any](
107-
ctx context.Context,
108-
in <-chan T,
109-
fn InterceptFunc[T, U],
113+
ctx context.Context,
114+
in <-chan T,
115+
fn InterceptFunc[T, U],
110116
) <-chan U
111117
```
118+
112119
Intercept accepts an incoming data channel and a function literal that accepts
113120
the incoming data and returns data of the same type and a boolean indicating
114121
whether the data should be forwarded to the output channel. The function is
@@ -119,9 +126,10 @@ not canceled or the incoming channel remains open.
119126

120127
```go
121128
func Pipe[T any](
122-
ctx context.Context, in <-chan T, out chan<- T,
129+
ctx context.Context, in <-chan T, out chan<- T,
123130
)
124131
```
132+
125133
Pipe accepts an incoming data channel and pipes it to the supplied outgoing data
126134
channel.
127135

@@ -133,25 +141,25 @@ that the goroutine is properly terminated.
133141

134142
```go
135143
type DurationScaler struct {
136-
// Interval is the number the current step must be divisible by in order
137-
// to modify the time.Duration.
138-
Interval int
139-
140-
// ScalingFactor is a value between -1 and 1 that is used to modify the
141-
// time.Duration of a ticker or timer. The value is multiplied by
142-
// the ScalingFactor is multiplied by the duration for scaling.
143-
//
144-
// For example, if the ScalingFactor is 0.5, then the duration will be
145-
// multiplied by 0.5. If the ScalingFactor is -0.5, then the duration will
146-
// be divided by 0.5. If the ScalingFactor is 0, then the duration will
147-
// not be modified.
148-
//
149-
// A negative ScalingFactor will cause the duration to decrease as the
150-
// step value increases causing the ticker or timer to fire more often
151-
// and create more routines. A positive ScalingFactor will cause the
152-
// duration to increase as the step value increases causing the ticker
153-
// or timer to fire less often and create less routines.
154-
ScalingFactor float64
144+
// Interval is the number the current step must be divisible by in order
145+
// to modify the time.Duration.
146+
Interval int
147+
148+
// ScalingFactor is a value between -1 and 1 that is used to modify the
149+
// time.Duration of a ticker or timer. The value is multiplied by
150+
// the ScalingFactor is multiplied by the duration for scaling.
151+
//
152+
// For example, if the ScalingFactor is 0.5, then the duration will be
153+
// multiplied by 0.5. If the ScalingFactor is -0.5, then the duration will
154+
// be divided by 0.5. If the ScalingFactor is 0, then the duration will
155+
// not be modified.
156+
//
157+
// A negative ScalingFactor will cause the duration to decrease as the
158+
// step value increases causing the ticker or timer to fire more often
159+
// and create more routines. A positive ScalingFactor will cause the
160+
// duration to increase as the step value increases causing the ticker
161+
// or timer to fire less often and create less routines.
162+
ScalingFactor float64
155163
}
156164
```
157165

@@ -164,19 +172,18 @@ a configured step value and modifier (between -1 and 1) value.
164172
type InterceptFunc[T, U any] func(context.Context, T) (U, bool)
165173
```
166174

167-
168175
#### type Scaler
169176

170177
```go
171178
type Scaler[T, U any] struct {
172-
Wait time.Duration
173-
Life time.Duration
174-
Fn InterceptFunc[T, U]
175-
176-
// WaitModifier is used to modify the Wait time based on the number of
177-
// times the Scaler has scaled up. This is useful for systems
178-
// that are CPU bound and need to scale up more/less quickly.
179-
WaitModifier DurationScaler
179+
Wait time.Duration
180+
Life time.Duration
181+
Fn InterceptFunc[T, U]
182+
183+
// WaitModifier is used to modify the Wait time based on the number of
184+
// times the Scaler has scaled up. This is useful for systems
185+
// that are CPU bound and need to scale up more/less quickly.
186+
WaitModifier DurationScaler
180187
}
181188
```
182189

@@ -209,6 +216,7 @@ successful send occurs. (This should only loop twice).
209216
```go
210217
func (s Scaler[T, U]) Exec(ctx context.Context, in <-chan T) (<-chan U, error)
211218
```
219+
212220
Exec starts the internal Scaler routine (the first layer of processing) and
213221
returns the output channel where the resulting data from the Fn function will be
214222
sent.

0 commit comments

Comments
 (0)