Passed
Pull Request — master (#52)
by Stefano
02:05
created

pkg/scan/producer/dictionary.go   A

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 27
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A producer.*DictionaryProducer.Produce 0 18 4
A producer.NewDictionaryProducer 0 9 1
1
package producer
2
3
import (
4
	"github.com/stefanoj3/dirstalk/pkg/scan"
5
)
6
7
func NewDictionaryProducer(
0 ignored issues
show
introduced by
exported function NewDictionaryProducer should have comment or be unexported
Loading history...
8
	methods []string,
9
	dictionary []string,
10
	depth int,
11
) *DictionaryProducer {
12
	return &DictionaryProducer{
13
		methods:    methods,
14
		dictionary: dictionary,
15
		depth:      depth,
16
	}
17
18
}
19
20
type DictionaryProducer struct {
0 ignored issues
show
introduced by
exported type DictionaryProducer should have comment or be unexported
Loading history...
21
	methods    []string
22
	dictionary []string
23
	depth      int
24
}
25
26
func (p *DictionaryProducer) Produce() <-chan scan.Target {
0 ignored issues
show
introduced by
exported method DictionaryProducer.Produce should have comment or be unexported
Loading history...
27
	targets := make(chan scan.Target, 10)
28
29
	go func() {
30
		defer close(targets)
31
32
		for _, entry := range p.dictionary {
33
			for _, method := range p.methods {
34
				targets <- scan.Target{
35
					Path:   entry,
36
					Method: method,
37
					Depth:  p.depth,
38
				}
39
			}
40
		}
41
	}()
42
43
	return targets
44
}
45