Showing 22 of 32 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
func GetSingleEnvironmentStatusInformationController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
obj := types.EnvironmentStatus{}
branch, err := url.PathUnescape(request.PathParameters["branch"])
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/GetSingleEnvironmentStatusInformationController", "operation": "pathUnescape"}, 0)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 279.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function AddEnvironmentForRepository
has 101 lines of code (exceeds 50 allowed). Consider refactoring. Open
func AddEnvironmentForRepository(environment types.EnvironmentPost, name string) (types.Environment, error) {
svc := getDynamoDbClient()
creation := time.Now().UTC()
Function UpdateEnvironment
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
func UpdateEnvironment(environment *types.EnvironmentPut, name string, branch string) (types.Environment, error) {
svc := getDynamoDbClient()
updateStruct := types.EnvironmentUpdate{
InfrastructureRepoURL: environment.InfrastructureRepoURL,
Function Handler
has 22 return statements (exceeds 4 allowed). Open
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
if request.Resource == "/configuration" && request.HTTPMethod == http.MethodGet {
return controller.GetConfigurationController(request)
}
Function Handler
has 64 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
if request.Resource == "/configuration" && request.HTTPMethod == http.MethodGet {
return controller.GetConfigurationController(request)
}
Function GitHubWebhookCreateController
has 11 return statements (exceeds 4 allowed). Open
func GitHubWebhookCreateController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
if !verifyHMAC(request.Body, request.Headers["X-Hub-Signature"]) {
return events.APIGatewayProxyResponse{Body: "{ \"message\" : \"HMAC validation failed\" }", StatusCode: 400}, nil
}
Function TriggerEnvironemtStatusChangeController
has 10 return statements (exceeds 4 allowed). Open
func TriggerEnvironemtStatusChangeController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
trigger := types.TriggerSchedulePost{}
err := json.Unmarshal([]byte(request.Body), &trigger)
if err != nil {
return types.InvalidRequestBodyResponse, nil
Function PutSinglEnvironmentForRepositoryController
has 9 return statements (exceeds 4 allowed). Open
func PutSinglEnvironmentForRepositoryController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
status := types.EnvironmentStatus{}
branch, err := url.PathUnescape(request.PathParameters["branch"])
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/PutSinglEnvironmentForRepositoryController", "operation": "pathUnescape"}, 0)
Function UpdateEnvironment
has 8 return statements (exceeds 4 allowed). Open
func UpdateEnvironment(environment *types.EnvironmentPut, name string, branch string) (types.Environment, error) {
svc := getDynamoDbClient()
updateStruct := types.EnvironmentUpdate{
InfrastructureRepoURL: environment.InfrastructureRepoURL,
Function GitHubWebhookDeleteController
has 8 return statements (exceeds 4 allowed). Open
func GitHubWebhookDeleteController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
if !verifyHMAC(request.Body, request.Headers["X-Hub-Signature"]) {
return events.APIGatewayProxyResponse{Body: "{ \"message\" : \"HMAC validation failed\" }", StatusCode: 400}, nil
}
Function AddEnvironmentForRepository
has 8 return statements (exceeds 4 allowed). Open
func AddEnvironmentForRepository(environment types.EnvironmentPost, name string) (types.Environment, error) {
svc := getDynamoDbClient()
creation := time.Now().UTC()
Function AddEnvironmentForRepositoryController
has 7 return statements (exceeds 4 allowed). Open
func AddEnvironmentForRepositoryController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
env := types.EnvironmentPost{}
err := json.Unmarshal([]byte(request.Body), &env)
if err != nil {
return types.InvalidRequestBodyResponse, nil
Function AddRepositoryController
has 6 return statements (exceeds 4 allowed). Open
func AddRepositoryController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
repo := types.Repository{}
err := json.Unmarshal([]byte(request.Body), &repo)
if err != nil {
return types.InvalidRequestBodyResponse, nil
Function DeleteSingleEnvironmentController
has 6 return statements (exceeds 4 allowed). Open
func DeleteSingleEnvironmentController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
status := types.EnvironmentStatus{}
branch, err := url.PathUnescape(request.PathParameters["branch"])
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/DeleteSingleEnvironmentController", "operation": "pathUnescape"}, 0)
Function PutSingleRepositoryController
has 6 return statements (exceeds 4 allowed). Open
func PutSingleRepositoryController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
repository := types.Repository{}
err := json.Unmarshal([]byte(request.Body), &repository)
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/PutSingleRepositoryController", "operation": "unmarshal"}, 4)
Similar blocks of code found in 2 locations. Consider refactoring. Open
if status.Status != "running" && status.Status != "stopped" && status.Status != "initiating failed" && status.Status != "destroying failed" {
config.Logger.Log(errors.New("Can't delete environment in status = "+status.Status), map[string]string{"module": "controller/GitHubWebhookDeleteController", "operation": "statusCheck"}, 0)
return types.InvalidEnvironmentStatusResponse, nil
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 108.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if status.Status != "running" && status.Status != "stopped" && status.Status != "initiating failed" && status.Status != "destroying failed" {
config.Logger.Log(errors.New("Can't delete environment in status = "+status.Status), map[string]string{"module": "controller/DeleteSingleEnvironmentController", "operation": "statusCheck"}, 0)
return types.InvalidEnvironmentStatusResponse, nil
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 108.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function GetSingleEnvironmentStatusInformationController
has 5 return statements (exceeds 4 allowed). Open
func GetSingleEnvironmentStatusInformationController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
obj := types.EnvironmentStatus{}
branch, err := url.PathUnescape(request.PathParameters["branch"])
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/GetSingleEnvironmentStatusInformationController", "operation": "pathUnescape"}, 0)
Function GetSingleEnvironmentForRepositoryController
has 5 return statements (exceeds 4 allowed). Open
func GetSingleEnvironmentForRepositoryController(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
obj := types.Environment{}
branch, err := url.PathUnescape(request.PathParameters["branch"])
if err != nil {
config.Logger.Log(err, map[string]string{"module": "controller/GetSingleEnvironmentForRepositoryController", "operation": "pathUnescape"}, 0)
Function DeleteSingleEnvironment
has 5 return statements (exceeds 4 allowed). Open
func DeleteSingleEnvironment(name string, branch string) error {
// Invoke Builder Lambda to delete schedules
event := types.BuilderEvent{
Operation: "DELETE_SCHEDULE",
Branch: branch,