horizoncd/horizon

View on GitHub

Showing 676 of 677 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (c *controller) GetByName(ctx context.Context, name string) (*Environment, error) {
environment, err := c.envMgr.GetByName(ctx, name)
if err != nil {
return nil, err
}
Severity: Minor
Found in core/controller/environment/controller.go and 1 other location - About 35 mins to fix
core/controller/environment/controller.go on lines 59..66

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func (a *API) ListAll(c *gin.Context) {
registries, err := a.registryCtl.ListAll(c)
if err != nil {
response.AbortWithRPCError(c, rpcerror.InternalError.WithErrMsg(err.Error()))
return
Severity: Minor
Found in core/http/api/v2/registry/apis.go and 2 other locations - About 35 mins to fix
core/http/api/v2/idp/apis.go on lines 67..74
core/http/api/v2/tag/apis.go on lines 139..146

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func (a *API) GetMetatagKeys(c *gin.Context) {
keys, err := a.tagCtl.GetMetatagKeys(c)
if err != nil {
response.AbortWithRPCError(c, rpcerror.InternalError.WithErrMsg(err.Error()))
return
Severity: Minor
Found in core/http/api/v2/tag/apis.go and 2 other locations - About 35 mins to fix
core/http/api/v2/idp/apis.go on lines 67..74
core/http/api/v2/registry/apis.go on lines 42..49

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func (a *API) ListIDPs(c *gin.Context) {
idps, err := a.idpCtrl.List(c)
if err != nil {
response.AbortWithRPCError(c, rpcerror.InternalError.WithErrMsg(err.Error()))
return
Severity: Minor
Found in core/http/api/v2/idp/apis.go and 2 other locations - About 35 mins to fix
core/http/api/v2/registry/apis.go on lines 42..49
core/http/api/v2/tag/apis.go on lines 139..146

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if resp.StatusCode != 201 && resp.StatusCode != 202 {
var b []byte
b, err = ioutil.ReadAll(resp.Body)
if err != nil {
return perror.Wrap(herrors.ErrReadFailed,
Severity: Minor
Found in pkg/templaterepo/chartmuseumbase/repo.go and 1 other location - About 30 mins to fix
pkg/templaterepo/chartmuseumbase/repo.go on lines 170..179

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if resp.StatusCode != 200 {
var b []byte
b, err = ioutil.ReadAll(resp.Body)
if err != nil {
return perror.Wrap(herrors.ErrReadFailed,
Severity: Minor
Found in pkg/templaterepo/chartmuseumbase/repo.go and 1 other location - About 30 mins to fix
pkg/templaterepo/chartmuseumbase/repo.go on lines 148..157

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (d *dao) CreateWebhookLogs(ctx context.Context,
wls []*models.WebhookLog) ([]*models.WebhookLog, error) {
d.db.WithContext(ctx).Commit().Callback()
if result := d.db.WithContext(ctx).Create(wls); result.Error != nil {
return nil, herrors.NewErrInsertFailed(herrors.WebhookLogInDB, result.Error.Error())
Severity: Minor
Found in pkg/webhook/dao/dao.go and 1 other location - About 30 mins to fix
pkg/webhook/dao/dao.go on lines 157..164

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (d *dao) CreateWebhookLog(ctx context.Context,
wl *models.WebhookLog) (*models.WebhookLog, error) {
d.db.WithContext(ctx).Commit().Callback()
if result := d.db.WithContext(ctx).Create(wl); result.Error != nil {
return nil, herrors.NewErrInsertFailed(herrors.WebhookLogInDB, result.Error.Error())
Severity: Minor
Found in pkg/webhook/dao/dao.go and 1 other location - About 30 mins to fix
pkg/webhook/dao/dao.go on lines 166..173

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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
Severity: Minor
Found in core/controller/group/controller.go and 1 other location - About 30 mins to fix
core/controller/group/controller.go on lines 452..457

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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
Severity: Minor
Found in core/controller/group/controller.go and 1 other location - About 30 mins to fix
core/controller/group/controller.go on lines 391..396

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if r.Git != nil {
gitURL, gitSubFolder, gitRefType, gitRef = r.Git.URL,
r.Git.Subfolder, r.Git.RefType(), r.Git.Ref()
} else {
gitURL = cluster.GitURL
Severity: Minor
Found in core/controller/cluster/models_basic_v2.go and 1 other location - About 30 mins to fix
core/controller/cluster/models_basic.go on lines 140..148

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if r.Git != nil {
gitURL, gitSubfolder, gitRefType, gitRef = r.Git.URL,
r.Git.Subfolder, r.Git.RefType(), r.Git.Ref()
} else {
gitURL = cluster.GitURL
Severity: Minor
Found in core/controller/cluster/models_basic.go and 1 other location - About 30 mins to fix
core/controller/cluster/models_basic_v2.go on lines 167..175

Method service.IsHealthy has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func (s *service) IsHealthy(node *v1alpha1.ResourceNode,
client *kube.Client) (bool, error) {
instance, err := s.getServiceByNode(node, client)
if err != nil {
return true, err
Severity: Minor
Found in pkg/workload/kservice/kservice.go - About 25 mins to fix

Method controller.handleJibBuild has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func (c *controller) handleJibBuild(ctx context.Context, result *tekton.PipelineResults,
data *global.HorizonMetaData) error {
clusterID := data.ClusterID
cluster, err := c.clusterMgr.GetByID(ctx, clusterID)
if err != nil {
Severity: Minor
Found in core/controller/cloudevent/controller.go - About 25 mins to fix

Function getScope has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func getScope(c *gin.Context, mgr *managerparam.Manager, resourceType,
resourceName string) (string, error) {
var (
resourceID uint
cluster *clustermodels.Cluster
Severity: Minor
Found in core/middleware/scope/scope.go - About 25 mins to fix

Function akskAuthn has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func akskAuthn(c *gin.Context, keys authenticate.KeysConfig, userMgr usermanager.Manager) (*models.User, error) {
r := c.Request
log.Infof(c, "request url path: %v", r.URL)
 
operator := r.Header.Get(HTTPHeaderOperator)
Severity: Minor
Found in core/middleware/user/user.go - About 25 mins to fix
Severity
Category
Status
Source
Language