Showing 440 of 677 total issues
File gitrepo_cluster.go
has 1601 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Function Init
has 392 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Init(ctx context.Context, flags *Flags, coreConfig *config.Config) {
// init roles
file, err := os.OpenFile(flags.RoleConfigFile, os.O_RDONLY, 0644)
if err != nil {
panic(err)
File controller_basic.go
has 917 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Method clusterGitopsRepo.UpgradeCluster
has 314 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
param *UpgradeValuesParam) (string, error) {
const op = "cluster git repo: upgrade cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpgradeCluster
has a Cognitive Complexity of 72 (exceeds 20 allowed). Consider refactoring. Open
func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
param *UpgradeValuesParam) (string, error) {
const op = "cluster git repo: upgrade cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
- 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 cd.GetClusterStateV1
has a Cognitive Complexity of 70 (exceeds 20 allowed). Consider refactoring. Open
func (c *cd) GetClusterStateV1(ctx context.Context,
params *GetClusterStateParams) (clusterState *ClusterState, err error) {
const op = "cd: get cluster status"
defer wlog.Start(ctx, op).StopPrint()
- 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
File controller.go
has 774 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
File controller.go
has 768 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Method controller.UpdateClusterV2
has a Cognitive Complexity of 64 (exceeds 20 allowed). Consider refactoring. Open
func (c *controller) UpdateClusterV2(ctx context.Context, clusterID uint,
r *UpdateClusterRequestV2, mergePatch bool) error {
const op = "cluster controller: update cluster v2"
defer wlog.Start(ctx, op).StopPrint()
- 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 controller.ListV2
has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring. Open
func (c *controller) ListV2(ctx context.Context, query *q.Query, withFullPath bool) (Templates, error) {
var (
groupIDs []uint
err error
)
- 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 eventHandlerService.Start
has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring. Open
func (e *eventHandlerService) Start() {
go func() {
defer func() {
if err := recover(); err != nil {
log.Errorf(e.ctx, "event handler service panic: %s", string(debug.Stack()))
- 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 controller.GetByFullPath
has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring. Open
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()
- 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
File controller.go
has 695 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
File controller_basic_v2.go
has 685 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
File cmd.go
has 664 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Copyright © 2023 Horizoncd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Method controller.UpdateCluster
has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring. Open
func (c *controller) UpdateCluster(ctx context.Context, clusterID uint,
r *UpdateClusterRequest, mergePatch bool) (_ *GetClusterResponse, err error) {
const op = "cluster controller: update cluster"
defer wlog.Start(ctx, op).StopPrint()
- 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 API.RegisterRoute
has 150 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (api *API) RegisterRoute(engine *gin.Engine) {
apiV2Group := engine.Group("/apis/core/v2")
apiV2Routes := route.Routes{
{
Method: http.MethodPost,
Method controller.UpdateClusterV2
has 149 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *controller) UpdateClusterV2(ctx context.Context, clusterID uint,
r *UpdateClusterRequestV2, mergePatch bool) error {
const op = "cluster controller: update cluster v2"
defer wlog.Start(ctx, op).StopPrint()
Method controller.DeleteCluster
has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring. Open
func (c *controller) DeleteCluster(ctx context.Context, clusterID uint, hard bool) (err error) {
const op = "cluster controller: delete cluster"
defer wlog.Start(ctx, op).StopPrint()
// get some relevant models
- 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 cd.GetClusterStateV1
has 141 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *cd) GetClusterStateV1(ctx context.Context,
params *GetClusterStateParams) (clusterState *ClusterState, err error) {
const op = "cd: get cluster status"
defer wlog.Start(ctx, op).StopPrint()