Showing 95 of 150 total issues
Method Reconciler.deployment
has 223 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Reconciler) deployment() (resources.Resource, error) {
labels := resources.Labels()
dep := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Method Agent.streamRulesToGateway
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (a *Agent) streamRulesToGateway(ctx context.Context) error {
lg := a.logger
updateC, err := a.streamRuleGroupUpdates(ctx)
if err != nil {
a.logger.With(
- 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 BuildBootstrapCmd
has 122 lines of code (exceeds 50 allowed). Consider refactoring. Open
func BuildBootstrapCmd() *cobra.Command {
lg := logger.New()
var namespace, kubeconfig, gatewayAddress, token string
var pins []string
Function BuildGatewayCmd
has 102 lines of code (exceeds 50 allowed). Consider refactoring. Open
func BuildGatewayCmd() *cobra.Command {
lg := logger.New()
var configLocation string
run := func() error {
Method MultiTenantRuleAggregator.Handle
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func (a *MultiTenantRuleAggregator) Handle(c *fiber.Ctx) error {
ids := rbac.AuthorizedClusterIDs(c)
a.logger.With(
"request", c.Path(),
).Debugf("aggregating query over %d tenants", len(ids))
- 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 ServerConfig.handleBootstrapAuth
has 96 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (h ServerConfig) handleBootstrapAuth(c *fiber.Ctx) error {
lg := c.Context().Logger()
authHeader := strings.TrimSpace(c.Get("Authorization"))
if strings.TrimSpace(authHeader) == "" {
return c.SendStatus(fiber.StatusUnauthorized)
Function init
has 94 lines of code (exceeds 50 allowed). Consider refactoring. Open
func init() {
build.Deps(Generate)
docker.Deps(build.Build)
test.Deps(testbin.Testbin, build.Build)
Function labelSelectorMatches
has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring. Open
func labelSelectorMatches(selector *core.LabelSelector, labels map[string]string) bool {
for key, value := range selector.MatchLabels {
if labels[key] != value {
return false
}
- 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 NewAPIServer
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewAPIServer(
ctx context.Context,
cfg *v1beta1.GatewayConfigSpec,
lg *zap.SugaredLogger,
opts ...APIServerOption,
Method Server.WatchClusters
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (m *Server) WatchClusters(
in *WatchClustersRequest,
stream Management_WatchClustersServer,
) error {
if err := validation.Validate(in); err != nil {
- 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 MultiTenantRuleAggregator.Handle
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (a *MultiTenantRuleAggregator) Handle(c *fiber.Ctx) error {
ids := rbac.AuthorizedClusterIDs(c)
a.logger.With(
"request", c.Path(),
).Debugf("aggregating query over %d tenants", len(ids))
Method WebUIServer.ListenAndServe
has 83 lines of code (exceeds 50 allowed). Consider refactoring. 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)
Method Reconciler.rbac
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Reconciler) rbac() ([]resources.Resource, error) {
serviceAccount := &corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Name: "opni-monitoring",
Namespace: r.gateway.Namespace,
Function BuildAgentCmd
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
func BuildAgentCmd() *cobra.Command {
lg := logger.New()
var configLocation string
agentCmd := &cobra.Command{
Method Reconciler.configMap
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *Reconciler) configMap() (resources.Resource, error) {
gatewayConf := &cfgv1beta1.GatewayConfig{
TypeMeta: cfgmeta.TypeMeta{
Kind: "GatewayConfig",
APIVersion: "v1beta1",
Method Server.configureApiExtensionDirector
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *Server) configureApiExtensionDirector(ctx context.Context) StreamDirector {
lg := m.logger
lg.Infof("loading api extensions from %d plugins", len(m.apiExtPlugins))
methodTable := map[string]*UnknownStreamMetadata{}
for _, plugin := range m.apiExtPlugins {
Function New
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func New(ctx context.Context, conf *v1beta1.AgentConfig, opts ...AgentOption) (*Agent, error) {
lg := logger.New().Named("agent")
options := AgentOptions{}
options.Apply(opts...)
Method ClientConfig.Bootstrap
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *ClientConfig) Bootstrap(
ctx context.Context,
ident ident.Provider,
) (keyring.Keyring, error) {
if c.Token == nil {
Function DecodeAuthHeader
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. 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"))
- 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 Reconciler.optionalContainerPorts
has 64 lines of code (exceeds 50 allowed). Consider refactoring. 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, ":")