Showing 95 of 150 total issues
Method Server.handleAuthorizeRequest
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Server) handleAuthorizeRequest(w http.ResponseWriter, r *http.Request) {
lg := s.Logger.With(
"remote_addr", r.RemoteAddr,
"request", r.RequestURI,
)
Function BuildBootstrapCmd
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func BuildBootstrapCmd() *cobra.Command {
lg := logger.New()
var namespace, kubeconfig, gatewayAddress, token string
var pins []string
- 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
Function New
has 9 return statements (exceeds 4 allowed). Open
func New(ctx context.Context, conf *v1beta1.AgentConfig, opts ...AgentOption) (*Agent, error) {
lg := logger.New().Named("agent")
options := AgentOptions{}
options.Apply(opts...)
Function extractOptions
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func extractOptions(options ...string) ([]OptionSpec, []string, error) {
var optionSpecs []OptionSpec
var remaining []string
for _, option := range options {
if option != "" && option[0] == '+' {
- 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
Function BuildClustersLabelCmd
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func BuildClustersLabelCmd() *cobra.Command {
overwrite := false
cmd := &cobra.Command{
Use: "label [--overwrite] <cluster-id> <label>=<value> [<label>=<value>...]",
Short: "Add labels to a cluster",
- 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
Function DecodeAuthHeader
has 9 return statements (exceeds 4 allowed). Open
func DecodeAuthHeader(header string) (id []byte, nonce uuid.UUID, mac []byte, err error) {
if !strings.HasPrefix(header, "MAC ") {
return nil, uuid.Nil, nil, errors.New("incorrect authorization type")
}
trimmed := strings.TrimSpace(strings.TrimPrefix(header, "MAC"))
Function fetchWellKnownConfig
has 9 return statements (exceeds 4 allowed). Open
func fetchWellKnownConfig(dc *DiscoverySpec) (*WellKnownConfiguration, error) {
client := http.Client{
// Do not redirect when fetching the openid configuration.
// The issuer URL must be the exact URL at which the discovery
// endpoint is located. The only valid status code is 200.
Method Reconciler.Reconcile
has 9 return statements (exceeds 4 allowed). Open
func (r *Reconciler) Reconcile() (*reconcile.Result, error) {
allResources := []resources.Resource{}
configMap, err := r.configMap()
if err != nil {
return nil, err
Method OpenidMiddleware.Handle
has 8 return statements (exceeds 4 allowed). Open
func (m *OpenidMiddleware) Handle(c *fiber.Ctx) error {
m.lock.Lock()
if m.wellKnownConfig == nil {
c.Status(http.StatusServiceUnavailable)
m.lock.Unlock()
Function NewGatewayHTTPClient
has 8 return statements (exceeds 4 allowed). Open
func NewGatewayHTTPClient(
address string,
ip ident.Provider,
kr keyring.Keyring,
) (GatewayHTTPClient, error) {
Method Reconciler.optionalContainerPorts
has 8 return statements (exceeds 4 allowed). Open
func (r *Reconciler) optionalContainerPorts() ([]corev1.ContainerPort, error) {
lg := r.logger
var ports []corev1.ContainerPort
if addr := r.gateway.Spec.Management.GRPCListenAddress; strings.HasPrefix(addr, "tcp://") {
parts := strings.Split(addr, ":")
Function labelSelectorMatches
has 8 return statements (exceeds 4 allowed). Open
func labelSelectorMatches(selector *core.LabelSelector, labels map[string]string) bool {
for key, value := range selector.MatchLabels {
if labels[key] != value {
return false
}
Function ControllerGen
has 8 return statements (exceeds 4 allowed). Open
func ControllerGen() error {
cmd := exec.Command(mg.GoCmd(), "run", "sigs.k8s.io/controller-tools/cmd/controller-gen",
"crd:maxDescLen=0", "object", "paths=./pkg/sdk/api/...", "output:crd:artifacts:config=pkg/sdk/crd",
)
buf := new(bytes.Buffer)
Method WebUIServer.ListenAndServe
has 7 return statements (exceeds 4 allowed). Open
func (ws *WebUIServer) ListenAndServe() error {
ws.mu.Lock()
defer ws.mu.Unlock()
lg := ws.logger
listener, err := net.Listen("tcp4", ws.config.Spec.Management.WebListenAddress)
Function LoadServingCertBundle
has 7 return statements (exceeds 4 allowed). Open
func LoadServingCertBundle(certsSpec v1beta1.CertsSpec) (*tls.Certificate, *x509.CertPool, error) {
var caCertData, servingCertData, servingKeyData []byte
switch {
case certsSpec.CACert != nil:
data, err := os.ReadFile(*certsSpec.CACert)
Avoid deeply nested control flow statements. Open
goto RETRY
Method ClientConfig.bootstrapJoin
has 7 return statements (exceeds 4 allowed). Open
func (c *ClientConfig) bootstrapJoin() (*BootstrapJoinResponse, *x509.Certificate, error) {
url, err := c.bootstrapJoinURL()
if err != nil {
return nil, nil, err
}
Method Plugin.Install
has 7 return statements (exceeds 4 allowed). Open
func (p *Plugin) Install(cluster *core.Reference) error {
labels := map[string]string{
resources.OpniClusterID: cluster.Id,
}
loggingClusterList := &opniv1beta2.LoggingClusterList{}
Avoid deeply nested control flow statements. Open
goto RETRY
Method ObjectList.Visit
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (l ObjectList) Visit(visitors ...ObjectVisitorFunc) {
// For each object in the list, call each visitor if its argument type
// matches the concrete type of the object.
for _, vf := range visitors {
// get the type of the first arg
- 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"