Showing 8 of 16 total issues
Method CodeBuildModel.AdaptCodeBildJobForUpdate
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (CodeBuildModel *CodeBuildModel) AdaptCodeBildJobForUpdate(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/CreateCodeBuildJob", "operation": "regex/compile"}, 0)
Method CodeBuildModel.CreateCodeBuildJob
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (CodeBuildModel *CodeBuildModel) CreateCodeBuildJob(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/CreateCodeBuildJob", "operation": "regex/compile"}, 0)
Method CodeBuildModel.AdaptCodeBildJobForDelete
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (CodeBuildModel *CodeBuildModel) AdaptCodeBildJobForDelete(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/AdaptingCodeBildJobForDelete", "operation": "regex/compile"}, 0)
Method CloudWatchEventsModel.removeRulesWithTarget
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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
- Read upRead up
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 CodeBuildModel.AdaptCodeBildJobForDelete
has 5 return statements (exceeds 4 allowed). Open
Open
func (CodeBuildModel *CodeBuildModel) AdaptCodeBildJobForDelete(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/AdaptingCodeBildJobForDelete", "operation": "regex/compile"}, 0)
Method CloudWatchEventsModel.removeRulesWithTarget
has 5 return statements (exceeds 4 allowed). Open
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
Method CodeBuildModel.AdaptCodeBildJobForUpdate
has 5 return statements (exceeds 4 allowed). Open
Open
func (CodeBuildModel *CodeBuildModel) AdaptCodeBildJobForUpdate(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/CreateCodeBuildJob", "operation": "regex/compile"}, 0)
Method CloudWatchEventsModel.UpdateCloudWatchEvents
has 5 return statements (exceeds 4 allowed). Open
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)