Method controller.GetByFullPath
has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
func (c *controller) GetByFullPath(ctx context.Context,
resourcePath string, resourceType string) (*service.Child, error) {
const op = "get record by fullPath"
defer wlog.Start(ctx, op).StopPrint()
Method controller.GetByFullPath
has 124 lines of code (exceeds 50 allowed). Consider refactoring.
func (c *controller) GetByFullPath(ctx context.Context,
resourcePath string, resourceType string) (*service.Child, error) {
const op = "get record by fullPath"
defer wlog.Start(ctx, op).StopPrint()
File controller.go
has 535 lines of code (exceeds 500 allowed). Consider refactoring.
Method controller.GetByFullPath
has 24 return statements (exceeds 4 allowed).
func (c *controller) GetByFullPath(ctx context.Context,
resourcePath string, resourceType string) (*service.Child, error) {
const op = "get record by fullPath"
defer wlog.Start(ctx, op).StopPrint()
Method controller.SearchChildren
has 7 return statements (exceeds 4 allowed).
func (c *controller) SearchChildren(ctx context.Context, params *SearchParams) ([]*service.Child, int64, error) {
if params.Filter == "" {
return c.GetChildren(ctx, params.GroupID, params.PageNumber, params.PageSize)
}
Method controller.SearchGroups
has 6 return statements (exceeds 4 allowed).
func (c *controller) SearchGroups(ctx context.Context, params *SearchParams) ([]*service.Child, int64, error) {
if params.Filter == "" {
return c.GetSubGroups(ctx, params.GroupID, params.PageNumber, params.PageSize)
}
Method controller.GetChildren
has 5 return statements (exceeds 4 allowed).
func (c *controller) GetChildren(ctx context.Context, id uint, pageNumber, pageSize int) (
[]*service.Child, int64, error) {
var parent *models.Group
var full *service.Full
if id > 0 {
Method controller.GetSubGroups
has 5 return statements (exceeds 4 allowed).
func (c *controller) GetSubGroups(ctx context.Context, id uint, pageNumber, pageSize int) (
[]*service.Child, int64, error) {
var parent *models.Group
var full *service.Full
if id > 0 {
Similar blocks of code found in 2 locations. Consider refactoring.
for i, s := range subGroups {
var fName, fPath string
if id == 0 {
fName = s.Name
fPath = fmt.Sprintf("/%s", s.Path)
Similar blocks of code found in 2 locations. Consider refactoring.
for i, val := range children {
var fName, fPath string
if id == 0 {
fName = val.Name
fPath = fmt.Sprintf("/%s", val.Path)
Similar blocks of code found in 2 locations. Consider refactoring.
if ok && fmt.Sprintf("%s/%s", appParentFull.FullPath, app.Name) == resourcePath {
return service.ConvertApplicationToChild(app, &service.Full{
FullName: fmt.Sprintf("%s/%s", appParentFull.FullName, app.Name),
FullPath: fmt.Sprintf("%s/%s", appParentFull.FullPath, app.Name),
}), nil
Similar blocks of code found in 2 locations. Consider refactoring.
if ok && fmt.Sprintf("%s/%s", full.FullPath, template.Name) == resourcePath {
return service.ConvertTemplateToChild(template, &service.Full{
FullName: fmt.Sprintf("%s/%s", full.FullName, template.Name),
FullPath: fmt.Sprintf("%s/%s", full.FullPath, template.Name),
}), nil
There are no issues that match your filters.