auto-staging/builder

View on GitHub
model/cw-update.go

Summary

Maintainability
A
1 hr
Test Coverage

Method CloudWatchEventsModel.removeRulesWithTarget has 5 return statements (exceeds 4 allowed).
Open

func (CloudWatchEventsModel *CloudWatchEventsModel) removeRulesWithTarget(repository, branch, action string) error {
    helper.Logger.Log(errors.New("Removing "+action+" schedules for repo = "+repository+" and branch = "+branch), map[string]string{"module": "model/removeRuleWithTarget", "operation": "info/removeRules"}, 3)

    client := CloudWatchEventsModel.CloudWatchEventsAPI

Severity: Major
Found in model/cw-update.go - About 35 mins to fix

    Method CloudWatchEventsModel.removeRulesWithTarget has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
    Open

    func (CloudWatchEventsModel *CloudWatchEventsModel) removeRulesWithTarget(repository, branch, action string) error {
        helper.Logger.Log(errors.New("Removing "+action+" schedules for repo = "+repository+" and branch = "+branch), map[string]string{"module": "model/removeRuleWithTarget", "operation": "info/removeRules"}, 3)
    
        client := CloudWatchEventsModel.CloudWatchEventsAPI
    
    
    Severity: Minor
    Found in model/cw-update.go - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method CloudWatchEventsModel.UpdateCloudWatchEvents has 5 return statements (exceeds 4 allowed).
    Open

    func (CloudWatchEventsModel *CloudWatchEventsModel) UpdateCloudWatchEvents(event types.Event) error {
        // Adapt branch name to only contain allowed characters for CodeBuild name
        reg, err := regexp.Compile("[^a-zA-Z0-9]+")
        if err != nil {
            helper.Logger.Log(err, map[string]string{"module": "model/UpdateCloudWatchEventsForEnvironment", "operation": "regex/compile"}, 0)
    Severity: Major
    Found in model/cw-update.go - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status