Showing 1,516 of 3,440 total issues
File ApplicationSummaryWidget.tsx
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { User, Clock, Info } from 'lucide-react';
import moment from 'moment';
import { useEffect, useState } from 'react';
import { Pod } from 'kubernetes-types/core/v1';
import { useCurrentStateAndParams } from '@uirouter/react';
Method Handler.userUpdate
has a Cognitive Complexity of 40 (exceeds 20 allowed). Consider refactoring. Open
func (handler *Handler) userUpdate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
userID, err := request.RetrieveNumericRouteVariableValue(r, "id")
if err != nil {
return httperror.BadRequest("Invalid user identifier route variable", err)
}
- 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 Handler.updateSettings
has 114 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *Handler) updateSettings(tx dataservices.DataStoreTx, payload settingsUpdatePayload) (*portainer.Settings, error) {
settings, err := tx.Settings().Settings()
if err != nil {
return nil, httperror.InternalServerError("Unable to retrieve the settings from the database", err)
}
Method Handler.updateEdgeSchedule
has 113 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *Handler) updateEdgeSchedule(tx dataservices.DataStoreTx, edgeJob *portainer.EdgeJob, payload *edgeJobUpdatePayload) error {
if payload.Name != nil {
edgeJob.Name = *payload.Name
}
Function AccessServiceFactory
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AccessServiceFactory($q, $async, UserService, TeamService) {
'use strict';
return {
accesses,
generateAccessPolicies,
File authorizations.go
has 560 lines of code (exceeds 500 allowed). Consider refactoring. Open
package authorization
import (
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
Method Handler.updateKubernetesIngressControllersByNamespace
has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring. Open
func (handler *Handler) updateKubernetesIngressControllersByNamespace(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
endpoint, err := middlewares.FetchEndpoint(r)
if err != nil {
return httperror.NotFound("Unable to find an environment on request context", err)
}
- 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 ContainerStatsViewModel
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
export function ContainerStatsViewModel(data) {
this.read = data.read;
this.preread = data.preread;
if (data.memory_stats.privateworkingset !== undefined) {
// Windows
- 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 AccessServiceFactory
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
function AccessServiceFactory($q, $async, UserService, TeamService) {
'use strict';
return {
accesses,
generateAccessPolicies,
- 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 DeploymentSyncOptions
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function DeploymentSyncOptions() {
const settingsQuery = useSettings();
const settingsMutation = useUpdateSettingsMutation();
const [formKey, resetForm] = useReducer((state) => state + 1, 0);
Function HomeView
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function HomeView() {
const localEnvironmentAdded = useConnectLocalEnvironment();
const { trackEvent } = useAnalytics();
return (
<>
Method Handler.stackUpdateGit
has 109 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
stackID, err := request.RetrieveNumericRouteVariableValue(r, "id")
if err != nil {
return httperror.BadRequest("Invalid stack identifier route variable", err)
}
Function PublishingExplaination
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function PublishingExplaination() {
return (
<FormSection title="Explanation" isFoldable titleSize="sm">
<div className="mb-4 flex flex-col items-start lg:flex-row">
<img
Store
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
type Store struct {
connection portainer.Connection
fileService portainer.FileService
CustomTemplateService *customtemplate.Service
Function config
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
function config($stateRegistryProvider: StateRegistry) {
$stateRegistryProvider.register({
name: 'docker.containers',
url: '/containers',
views: {
Function CreateNamespaceForm
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function CreateNamespaceForm() {
const router = useRouter();
const environmentId = useEnvironmentId();
const { data: environment, ...environmentQuery } = useCurrentEnvironment();
const resourceLimitsQuery = useClusterResourceLimitsQuery(environmentId);
File useCreateMutation.tsx
has 304 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { useMutation, useQueryClient } from '@tanstack/react-query';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import {
Environment,
Method Handler.deleteEndpoint
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *Handler) deleteEndpoint(tx dataservices.DataStoreTx, endpointID portainer.EndpointID, deleteCluster bool) error {
endpoint, err := tx.Endpoint().Endpoint(portainer.EndpointID(endpointID))
if tx.IsErrObjectNotFound(err) {
return httperror.NotFound("Unable to find an environment with the specified identifier inside the database", err)
} else if err != nil {
Method Handler.updateRelations
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (handler *Handler) updateRelations(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
payload, err := request.GetPayload[endpointUpdateRelationsPayload](r)
if err != nil {
return httperror.BadRequest("Invalid request payload", err)
- 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 Handler.stackUpdateGit
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func (handler *Handler) stackUpdateGit(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
stackID, err := request.RetrieveNumericRouteVariableValue(r, "id")
if err != nil {
return httperror.BadRequest("Invalid stack identifier route variable", err)
}
- 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"