Showing 1,519 of 3,462 total issues
File NonGitStackForm.tsx
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Form, Formik, useFormikContext } from 'formik';
import { useState, useEffect } from 'react';
import { array, boolean, number, object, SchemaOf, string } from 'yup';
import { useRouter } from '@uirouter/react';
import _ from 'lodash';
Method Handler.deleteEndpoint
has a Cognitive Complexity of 49 (exceeds 20 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 {
- 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 snapshotContainers
has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring. Open
func snapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Client) error {
containers, err := cli.ContainerList(context.Background(), container.ListOptions{All: true})
if err != nil {
return 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 LocalStorageFactory
has 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
function LocalStorageFactory(localStorageService) {
return {
storeLoginStateUUID: function (uuid) {
localStorageService.set('LOGIN_STATE_UUID', uuid);
},
Function CreateForm
has 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
function CreateForm() {
const environmentId = useEnvironmentId();
const router = useRouter();
const isWindows = useIsWindows(environmentId);
const { trackEvent } = useAnalytics();
testDatastore
has 38 methods (exceeds 20 allowed). Consider refactoring. Open
type testDatastore struct {
customTemplate dataservices.CustomTemplateService
edgeGroup dataservices.EdgeGroupService
edgeJob dataservices.EdgeJobService
edgeStack dataservices.EdgeStackService
File applicationService.js
has 374 lines of code (exceeds 250 allowed). Consider refactoring. Open
import _ from 'lodash-es';
import angular from 'angular';
import PortainerError from 'Portainer/error';
import { KubernetesApplicationDeploymentTypes, KubernetesApplicationTypes } from 'Kubernetes/models/application/models/appConstants';
Function AuthenticationFactory
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
function AuthenticationFactory($async, $state, Auth, OAuth, LocalStorage, StateManager, EndpointProvider, ThemeManager) {
'use strict';
var user = {};
if (process.env.NODE_ENV === 'development') {
File index.ts
has 366 lines of code (exceeds 250 allowed). Consider refactoring. Open
import angular from 'angular';
import { r2a } from '@/react-tools/react2angular';
import { IngressClassDatatableAngular } from '@/react/kubernetes/cluster/ingressClass/IngressClassDatatable/IngressClassDatatableAngular';
import { NamespacesSelector } from '@/react/kubernetes/cluster/RegistryAccessView/NamespacesSelector';
Function $onInit
has 119 lines of code (exceeds 25 allowed). Consider refactoring. Open
$onInit() {
return this.$async(async () => {
try {
this.endpoint = await this.EndpointService.endpoint(this.endpoint.Id);
await this.StateManager.updateEndpointState(this.endpoint);
Function getUpdatedApplicationResources
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
export function getUpdatedApplicationResources(oldFormValues, newFormValues) {
const resources = [];
const [oldApp, oldHeadlessService, oldServices, oldService, oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
const [newApp, newHeadlessService, newServices, newService, newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
- 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 isConfigurationFormValid
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
export function isConfigurationFormValid(alreadyExist, isDataValid, formValues) {
const uniqueCheck = !alreadyExist && isDataValid;
let secretWarningMessage = '';
let isFormValid = 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 UserService
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function UserService($q, Users, TeamService, TeamMembershipService) {
'use strict';
var service = {};
service.users = async function (includeAdministrators, environmentId) {
Method Store.initServices
has 142 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (store *Store) initServices() error {
authorizationsetService, err := role.NewService(store.connection)
if err != nil {
return err
}
Consider simplifying this complex logical expression. Open
if (
(matchExpression.operator === 'Exists' && exists) ||
(matchExpression.operator === 'DoesNotExist' && !exists) ||
(matchExpression.operator === 'In' && isIn) ||
(matchExpression.operator === 'NotIn' && !isIn) ||
File EnvironmentList.tsx
has 358 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { ReactNode, useEffect, useState } from 'react';
import { HardDrive, RefreshCcw } from 'lucide-react';
import _ from 'lodash';
import { useStore } from 'zustand';
Function ServiceHelperFactory
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
function ServiceHelperFactory() {
'use strict';
var helper = {};
- 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 ApplicationDetailsWidget
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function ApplicationDetailsWidget() {
const stateAndParams = useCurrentStateAndParams();
const {
params: {
namespace,
Function SSLSettingsPanel
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SSLSettingsPanel() {
const settingsQuery = useSSLSettings();
const [reloadingPage, setReloadingPage] = useState(false);
const mutation = useUpdateSSLConfigMutation();
Function constructor
has 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(data: Service & { Portainer?: PortainerMetadata }) {
this.Model = data;
this.Id = data.ID || '';
this.Tasks = [];
this.Name = data.Spec?.Name || '';