Showing 1,516 of 3,440 total issues
Function KubernetesResourcePoolService
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function KubernetesResourcePoolService(
$async,
EndpointService,
KubernetesNamespaceService,
KubernetesResourceQuotaService,
Function buildChanges
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function buildChanges(service) {
var config = convertServiceToConfig(service.Model);
config.Name = service.Name;
config.Labels = LabelHelper.fromKeyValueToLabelHash(service.ServiceLabels);
config.TaskTemplate.ContainerSpec.Env = envVarsUtils.convertToArrayOfStrings(service.EnvironmentVariables);
Function toViewModel
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function toViewModel(portBindings: PortMap): Values {
const parsedPorts = parsePorts(portBindings);
const sortedPorts = sortPorts(parsedPorts);
return [
Function CreateView
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function CreateView() {
const initialValues = useMemo<FormValues>(
() => ({
name: '',
groupIds: [],
Function EnvironmentCreationView
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function EnvironmentCreationView() {
const {
params: { localEndpointId: localEndpointIdParam, referrer },
} = useCurrentStateAndParams();
Function getUpdatedApplicationResources
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getUpdatedApplicationResources(
newFormValues: ApplicationFormValues,
oldFormValues: ApplicationFormValues
) {
// app summaries
Transport
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
Open
Transport struct {
HTTPTransport *http.Transport
endpoint *portainer.Endpoint
dataStore dataservices.DataStore
signatureService portainer.DigitalSignatureService
Function ApplicationDetailsView
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function ApplicationDetailsView() {
const stateAndParams = useCurrentStateAndParams();
const {
params: { namespace, name },
} = stateAndParams;
File createStackController.js
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import angular from 'angular';
import { AccessControlFormData } from '@/portainer/components/accessControlForm/porAccessControlFormModel';
import { STACK_NAME_VALIDATION_REGEX } from '@/react/constants';
import { RepositoryMechanismTypes } from '@/kubernetes/models/deploy';
Method PluginWrapper.WaitForStatus
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
Open
func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, status libstack.Status) <-chan libstack.WaitResult {
waitResultCh := make(chan libstack.WaitResult)
waitResult := libstack.WaitResult{
Status: status,
}
- 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 patchAsync
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
Open
async patchAsync(oldFormValues, newFormValues, originalServicePorts) {
const [oldApp, oldHeadlessService, oldServices, , oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
const [newApp, newHeadlessService, newServices, , newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
const oldApiService = this._getApplicationApiService(oldApp);
const newApiService = this._getApplicationApiService(newApp);
- 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 staggerConfigValidation
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function staggerConfigValidation(): SchemaOf<StaggerConfig> {
return object({
StaggerOption: number()
.oneOf([StaggerOption.AllAtOnce, StaggerOption.Parallel])
.required('Stagger option is required'),
File application.js
has 321 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import _ from 'lodash-es';
import filesizeParser from 'filesize-parser';
import { KubernetesApplicationDataAccessPolicies, KubernetesApplicationDeploymentTypes, KubernetesApplicationTypes } from 'Kubernetes/models/application/models/appConstants';
import {
File containerController.js
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import moment from 'moment';
import _ from 'lodash-es';
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
import { confirmContainerDeletion } from '@/react/docker/containers/common/confirm-container-delete-modal';
import { FeatureId } from '@/react/portainer/feature-flags/enums';
Function patchAsync
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async patchAsync(oldFormValues, newFormValues, originalServicePorts) {
const [oldApp, oldHeadlessService, oldServices, , oldClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(oldFormValues);
const [newApp, newHeadlessService, newServices, , newClaims] = KubernetesApplicationConverter.applicationFormValuesToApplication(newFormValues);
const oldApiService = this._getApplicationApiService(oldApp);
const newApiService = this._getApplicationApiService(newApp);
Function DeploymentOptionsSection
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function DeploymentOptionsSection() {
const {
values: { globalDeploymentOptions: values },
setFieldValue,
} = useFormikContext<FormValues>();
DbConnection
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type DbConnection struct {
Path string
MaxBatchSize int
MaxBatchDelay time.Duration
InitialMmapSize int
Method Handler.stackGitRedeploy
has 116 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (handler *Handler) stackGitRedeploy(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)
}
File services.go
has 568 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package datastore
import (
"fmt"
"os"
File endpointController.js
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import _ from 'lodash-es';
import uuidv4 from 'uuid/v4';
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
import EndpointHelper from '@/portainer/helpers/endpointHelper';