Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modules/{id} endpoint #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix modules/{id} endpoint #23

wants to merge 1 commit into from

Conversation

MaryAnn99
Copy link
Collaborator

What: search the object ID in the database instead of the id
as a string
Why: the GET of modules by ID was returning 404

What: search the object ID in the database instead of the id
as a string
Why: the GET of modules by ID was returning 404
@github-actions
Copy link

⚠ golint Failed

Found 66 lint suggestions; failing.

Show Detail
app/api-gateway/router/authorizer.go:16:6: exported type AuthorizerType should have comment or be unexported
app/api-gateway/router/authorizer.go:19:2: exported const AuthorizerTypeJWT should have comment (or a comment on this block) or be unexported
app/api-gateway/router/authorizer.go:23:2: comment on exported var ErrMissingRoleName should be of the form "ErrMissingRoleName ..."
app/api-gateway/router/authorizer.go:31:6: exported type AuthorizeResult should have comment or be unexported
app/api-gateway/router/authorizer.go:33:1: comment on exported type Authorizer should be of the form "Authorizer ..." (with optional leading article)
app/api-gateway/router/authorizer.go:38:1: exported function NewAuthorizer should have comment or be unexported
app/api-gateway/router/endpoint.go:50:6: exported type Endpoints should have comment or be unexported
app/api-gateway/router/endpoint.go:55:6: exported type EndpointOptions should have comment or be unexported
app/api-gateway/router/endpoint.go:60:6: exported type AuthorizerOptions should have comment or be unexported
app/api-gateway/router/endpoint.go:67:6: exported type RouterOptions should have comment or be unexported
app/api-gateway/router/endpoint.go:67:6: type name will be used as router.RouterOptions by other packages, and that stutters; consider calling this Options
app/api-gateway/router/http_router.go:16:6: func newHttpRouter should be newHTTPRouter
app/api-gateway/router/models.go:24:2: comment on exported var ErrInvalidTransportMode should be of the form "ErrInvalidTransportMode ..."
app/api-gateway/router/models.go:28:1: comment on exported type Router should be of the form "Router ..." (with optional leading article)
app/api-gateway/router/models.go:33:6: exported type Gateway should have comment or be unexported
app/api-gateway/router/proxy.go:11:1: comment on exported type Proxy should be of the form "Proxy ..." (with optional leading article)
app/api-gateway/router/proxy.go:17:1: exported method Proxy.HandleEndpoints should have comment or be unexported
app/cmd/data-sender-simulator/main.go:16:6: exported type Range should have comment or be unexported
app/cmd/data-sender-simulator/main.go:88:6: exported type Module should have comment or be unexported
app/cmd/data-sender-simulator/main.go:93:6: exported type MessageRequestBody should have comment or be unexported
app/cmd/data-sender-simulator/main.go:98:6: exported type Measurement should have comment or be unexported
app/reporting/handlers/http/handlers.go:13:6: exported type HTTPHandler should have comment or be unexported
app/reporting/handlers/http/handlers.go:25:1: exported function New should have comment or be unexported
app/reporting/handlers/http/utils.go:12:2: exported var ErrInvalidDate should have comment or be unexported
app/reporting/models/report.go:9:6: exported type Report should have comment or be unexported
app/reporting/models/report.go:16:6: exported type Data should have comment or be unexported
app/reporting/models/report.go:24:6: exported type Parameter should have comment or be unexported
app/reporting/models/report.go:29:6: exported type Location should have comment or be unexported
app/reporting/models/search_options.go:12:6: exported type SearchOptions should have comment or be unexported
app/reporting/models/search_options.go:20:1: exported function IsValidAggregationType should have comment or be unexported
app/reporting/repositories/reports/repository.go:9:6: exported type Parameter should have comment or be unexported
app/reporting/repositories/reports/repository.go:14:6: exported type Repository should have comment or be unexported
app/reporting/repositories/reports/influx/repository.go:25:1: exported function New should have comment or be unexported
app/reporting/repositories/reports/influx/repository.go:242:14: should omit 2nd value from range; this loop is equivalent to `for index := range ...`
app/reporting/service/interface.go:9:6: exported type Service should have comment or be unexported
app/reporting/service/service.go:20:1: exported function New should have comment or be unexported
app/river-management/handlers/grpc/grpc.go:14:6: exported type Handler should have comment or be unexported
app/river-management/handlers/grpc/grpc.go:23:1: exported function NewHandler should have comment or be unexported
app/river-management/models/module.go:51:6: exported type ModuleUpdateOptions should have comment or be unexported
app/river-management/models/module.go:56:1: exported function IsValidModulestate should have comment or be unexported
app/shared/grpc-clients/river-management/client.go:11:6: exported type Client should have comment or be unexported
app/shared/grpc-clients/river-management/client.go:15:1: comment on exported function InitClient should be of the form "InitClient ..."
app/shared/grpc-clients/river-management/client.go:26:1: exported method Client.GetServiceClient should have comment or be unexported
app/shared/rabbit/rabbit.go:10:6: exported type RabbitClient should have comment or be unexported
app/shared/rabbit/rabbit.go:10:6: type name will be used as rabbit.RabbitClient by other packages, and that stutters; consider calling this Client
app/shared/rabbit/rabbit.go:22:1: exported function InitRabbitClient should have comment or be unexported
app/shared/wqi-calculator/calculator.go:7:6: exported type IndexType should have comment or be unexported
app/shared/wqi-calculator/calculator.go:15:2: exported var ErrInvalidIndexType should have comment or be unexported
app/shared/wqi-calculator/calculator.go:35:6: exported type Calculator should have comment or be unexported
app/shared/wqi-calculator/calculator.go:40:1: exported function NewCalculator should have comment or be unexported
app/shared/wqi-calculator/models.go:3:6: exported type ParameterType should have comment or be unexported
app/shared/wqi-calculator/models.go:32:6: exported type Parameter should have comment or be unexported
app/shared/wqi-calculator/models.go:37:1: exported function IsValidParamType should have comment or be unexported
app/telemetry/handlers/rabbitmq/handlers.go:13:6: exported type Handler should have comment or be unexported
app/telemetry/handlers/rabbitmq/handlers.go:22:1: exported function NewRabbitHandler should have comment or be unexported
app/telemetry/models/measurement.go:3:6: exported type MeasurementType should have comment or be unexported
app/telemetry/models/measurement.go:6:2: comment on exported const MeasurementTypePH should be of the form "MeasurementTypePH ..."
app/telemetry/models/measurement.go:23:6: exported type Measurement should have comment or be unexported
app/telemetry/models/message.go:5:6: exported type MessageType should have comment or be unexported
app/telemetry/models/message.go:8:2: exported const MessageTypeMeasurement should have comment (or a comment on this block) or be unexported
app/telemetry/models/message.go:11:6: exported type Message should have comment or be unexported
app/telemetry/repositories/measurements/repository.go:9:6: exported type Repository should have comment or be unexported
app/telemetry/repositories/measurements/influx/repository.go:20:1: exported function New should have comment or be unexported
app/telemetry/repositories/measurements/influx/repository.go:27:2: var writeApi should be writeAPI
app/telemetry/service/interfaces.go:9:6: exported type Service should have comment or be unexported
app/telemetry/service/service.go:24:1: exported function New should have comment or be unexported

@github-actions
Copy link

⚠ errcheck Failed

app/shared/rabbit/rabbit.go:84:19:	client.conn.Close()

@github-actions
Copy link

⚠ goimports Failed

app/accounts/config/config.go
 	DatabaseConfig struct {
 		DatabaseType string `yaml:"databaseType" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASETYPE,required"`
 		Connection   string `yaml:"connection" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_CONNECTION,required"`
-		DatabaseName  string `yaml:"databaseName" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASENAME,required"`
+		DatabaseName string `yaml:"databaseName" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASENAME,required"`
 	} `yaml:"databaseConfig"`
 }
 
app/cmd/data-sender-simulator/main.go
 }
 
 func randFloat(randRange Range) float32 {
-	return randRange.Min + rand.Float32() * (randRange.Max - randRange.Min)
+	return randRange.Min + rand.Float32()*(randRange.Max-randRange.Min)
 }
 
 func getPh(quality string) float32 {
 	switch quality {
-		case "good":
-			return randFloat(rangeGoodMeasurementTypePH)
-		case "normal":
-			return randFloat(rangeNormalMeasurementTypePH)
-		case "bad":
-			return randFloat(rangeBadMeasurementTypePH)
+	case "good":
+		return randFloat(rangeGoodMeasurementTypePH)
+	case "normal":
+		return randFloat(rangeNormalMeasurementTypePH)
+	case "bad":
+		return randFloat(rangeBadMeasurementTypePH)
 	}
 
 	return 0
 
 func getTDS(quality string) float32 {
 	switch quality {
-		case "good":
-			return randFloat(rangeGoodMeasurementTypeTDS)
-		case "normal":
-			return randFloat(rangeNormalMeasurementTypeTDS)
-		case "bad":
-			return randFloat(rangeBadMeasurementTypeTDS)
+	case "good":
+		return randFloat(rangeGoodMeasurementTypeTDS)
+	case "normal":
+		return randFloat(rangeNormalMeasurementTypeTDS)
+	case "bad":
+		return randFloat(rangeBadMeasurementTypeTDS)
 	}
 
 	return 0
app/river-management/handlers/grpc/grpchandler/service.pb.go
 
 import (
 	context "context"
+	reflect "reflect"
+	sync "sync"
+
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	emptypb "google.golang.org/protobuf/types/known/emptypb"
-	reflect "reflect"
-	sync "sync"
 )
 
 const (
app/river-management/models/module.go
 
 // Module represents a device on the river, the entity that is going to take the measurements
 type Module struct {
-	ModuleID     string      `json:"moduleID" bson:"_id"`
-	PhoneNumber  string      `json:"phoneNumber" bson:"phoneNumber"`
-	Alias        string      `json:"alias" bson:"alias"`
+	ModuleID    string `json:"moduleID" bson:"_id"`
+	PhoneNumber string `json:"phoneNumber" bson:"phoneNumber"`
+	Alias       string `json:"alias" bson:"alias"`
 	// TODO: RiverID should be WaterBodyID
-	RiverID      string      `json:"riverID" bson:"riverID"`
+	RiverID string `json:"riverID" bson:"riverID"`
 	// TODO: RiverName should be WaterBodyName
 	RiverName    string      `json:"riverName" bson:"riverName"`
 	UserID       string      `json:"userID" bson:"userID"`
app/shared/config/config.go
 	DatabaseConfig struct {
 		DatabaseType string `yaml:"databaseType" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASETYPE,required"`
 		Connection   string `yaml:"connection" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_CONNECTION,required"`
-		DatabaseName  string `yaml:"databaseName" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASENAME,required"`
+		DatabaseName string `yaml:"databaseName" validate:"required" env:"APPCONFIG_REPOSITORYCONFIG_DATABASENAME,required"`
 	} `yaml:"databaseConfig"`
 }
 
app/shared/wqi-calculator/calculator.go
 	standardValues = map[ParameterType]float64{
 		ParameterTypePH:  7.5,
 		ParameterTypeTDS: 500, // measured in mg/litre
-		ParameterTypeTDY: 10, // measured in NTUs
-		ParameterTypeDO:  5, // measured in mg/litre
+		ParameterTypeTDY: 10,  // measured in NTUs
+		ParameterTypeDO:  5,   // measured in mg/litre
 	}
 
 	idealValues = map[ParameterType]float64{
app/shared/wqi-calculator/wai_calculator.go
 			continue
 		}
 
-		qi := ( math.Abs(param.Value - idealValues[param.Name]) ) / ( math.Abs(standardValues[param.Name] - idealValues[param.Name]) ) * 100.0
+		qi := (math.Abs(param.Value - idealValues[param.Name])) / (math.Abs(standardValues[param.Name] - idealValues[param.Name])) * 100.0
 		wi := k / standardValues[param.Name]
 
 		OverallWQI += (wi * qi)
app/telemetry/models/measurement.go
 	// MeasurementTypePH is a MeasurementType for the pH level of the water.
 	MeasurementTypePH MeasurementType = "ph"
 	// MeasurementTypeDO is a MeasurementType for the concentration of oxygen that is dissolved in the water (Dissolved Oxygen).
-	MeasurementTypeDO  MeasurementType = "do"
+	MeasurementTypeDO MeasurementType = "do"
 	// MeasurementTypeTMP is a MeasurementType for the temperature of the water.
 	MeasurementTypeTMP MeasurementType = "tmp"
 	// MeasurementTypeTDY is a MeasurementType for the turbidity of the water.

@github-actions
Copy link

⚠ staticcheck Failed

app/reporting/repositories/reports/influx/repository.go:242:14: unnecessary assignment to the blank identifier (S1005)

Checks Document

@github-actions
Copy link

⚠ gosec Failed

Summary:
   Files: 67
   Lines: 5971
   Nosec: 0
  Issues: 1
Show Detail
Results:


[/github/workspace/app/cmd/river-management/main.go:75] - G102 (CWE-200): Binds to all network interfaces (Confidence: HIGH, Severity: MEDIUM)
  > net.Listen("tcp", ":8080")


Summary:
   Files: 67
   Lines: 5971
   Nosec: 0
  Issues: 1

Code Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant