fix: golangci-lint and gosec warnings

This commit is contained in:
2021-05-16 23:02:46 +02:00
parent f7bb283784
commit ffbc8a793c
22 changed files with 228 additions and 157 deletions

View File

@ -21,7 +21,6 @@ type BME280 struct {
// Read measured values
func (bme280 *BME280) Read() ([]*types.MeasuredValue, error) {
// Lock multiple access
bme280.mutex.Lock()
defer bme280.mutex.Unlock()

View File

@ -18,7 +18,6 @@ type DHT11 struct {
// Read measured values
func (dht11 *DHT11) Read() ([]*types.MeasuredValue, error) {
// Lock multiple access
dht11.mutex.Lock()
defer dht11.mutex.Unlock()

View File

@ -18,7 +18,6 @@ type DHT22 struct {
// Read measured values
func (dht22 *DHT22) Read() ([]*types.MeasuredValue, error) {
// Lock multiple access
dht22.mutex.Lock()
defer dht22.mutex.Unlock()

View File

@ -22,7 +22,6 @@ type DS18B20 struct {
// Read measured values
func (ds18b20 *DS18B20) Read() ([]*types.MeasuredValue, error) {
// Lock multiple access
ds18b20.mutex.Lock()
defer ds18b20.mutex.Unlock()
@ -36,6 +35,7 @@ func (ds18b20 *DS18B20) Read() ([]*types.MeasuredValue, error) {
return nil, fmt.Errorf("Socket path not found: %v", socketPath)
}
/* #nosec */
data, err := ioutil.ReadFile(socketPath)
if err != nil {
return nil, fmt.Errorf("Can not read data from sensor %v", ds18b20.Name)

View File

@ -14,7 +14,7 @@ var (
// FilterMeasuredValuesByTypes filters measured values by type
func FilterMeasuredValuesByTypes(ctx context.Context, inChannel <-chan *types.MeasuredValue, measuredValueTypes ...types.MeasuredValueType) <-chan *types.MeasuredValue {
outChannel := make(chan *types.MeasuredValue, 0)
outChannel := make(chan *types.MeasuredValue, 1)
go func() {
LOOP:
for {
@ -40,7 +40,7 @@ func FilterMeasuredValuesByTypes(ctx context.Context, inChannel <-chan *types.Me
// FilterMeasuredValuesBySensorIDs filters measured values by sensor id
func FilterMeasuredValuesBySensorIDs(ctx context.Context, inChannel <-chan *types.MeasuredValue, sensorIDs ...string) <-chan *types.MeasuredValue {
outChannel := make(chan *types.MeasuredValue, 0)
outChannel := make(chan *types.MeasuredValue, 1)
go func() {
LOOP:
for {
@ -68,8 +68,8 @@ func FilterMeasuredValuesBySensorIDs(ctx context.Context, inChannel <-chan *type
// closed. The returned channels will be closed
func ReadPipeline(ctx context.Context, sensors ...Sensor) (<-chan *types.MeasuredValue, <-chan error) {
var (
errorChannel = make(chan error, 0)
measuredValueChannel = make(chan *types.MeasuredValue, 0)
errorChannel = make(chan error, 1)
measuredValueChannel = make(chan *types.MeasuredValue, 1)
)
go func() {
@ -102,8 +102,8 @@ func ReadPipeline(ctx context.Context, sensors ...Sensor) (<-chan *types.Measure
// the context has been closed
func ReadTickingPipeline(ctx context.Context, sensors ...Sensor) (<-chan *types.MeasuredValue, <-chan error) {
var (
errorChannel = make(chan error, 0)
measuredValueChannel = make(chan *types.MeasuredValue, 0)
errorChannel = make(chan error, 1)
measuredValueChannel = make(chan *types.MeasuredValue, 1)
)
for i := range sensors {