Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyze dead code and ensure it can be cleaned up or deleted #420

Open
patrickdappollonio opened this issue Sep 3, 2024 · 0 comments
Open

Comments

@patrickdappollonio
Copy link
Member

Several functions today are unused by the current application, as reported by Go's tool deadcode:

$ deadcode .
configs/config.go:122:6: unreachable func: ReadConfig
configs/kubefirstDirectory.go:17:6: unreachable func: CheckKubefirstDir
configs/kubefirstFile.go:17:6: unreachable func: CheckKubefirstConfigFile
configs/viperConfig.go:55:6: unreachable func: InitializeViperConfig
configs/viperConfig.go:95:6: unreachable func: bindFlags
internal/helpers.go:41:6: unreachable func: RemoveSubdomainV2
internal/helpers.go:89:6: unreachable func: CreateFile
internal/helpers.go:103:6: unreachable func: CreateFullPath
internal/helpers.go:142:6: unreachable func: RemoveSubDomain
internal/helpers.go:185:6: unreachable func: IsValidURL
internal/helpers.go:202:6: unreachable func: ValidateK1Folder
internal/helpers.go:238:6: unreachable func: AwaitHostNTimes
internal/helpers.go:279:6: unreachable func: UpdateTerraformS3BackendForK8sAddress
internal/helpers.go:318:6: unreachable func: UpdateTerraformS3BackendForLocalhostAddress
internal/helpers.go:359:6: unreachable func: InformUser
internal/helpers.go:401:6: unreachable func: IsConsoleUIAvailable
internal/helpers.go:471:6: unreachable func: GetFileContent
internal/helpers.go:491:6: unreachable func: GetCertificateAppList
internal/log.go:20:6: unreachable func: ZerologSetup
internal/log.go:35:6: unreachable func: shortCallerMarshalFunc
internal/log.go:63:6: unreachable func: GetLogLevelByString
internal/mocks.go:17:26: unreachable func: HTTPMock.Do
internal/mocks.go:23:36: unreachable func: SegmentIOMock.Close
internal/mocks.go:27:36: unreachable func: SegmentIOMock.Enqueue
internal/progress_bar.go:36:6: unreachable func: GetTrackers
internal/progress_bar.go:45:6: unreachable func: CreateTracker
internal/progress_bar.go:59:6: unreachable func: SetupProgress
internal/shell.go:43:6: unreachable func: ExecShellReturnStringsV2
internal/shell.go:64:6: unreachable func: ExecShellWithVars
internal/shell.go:123:6: unreachable func: reader
internal/argocd/applications.go:123:6: unreachable func: RefreshApplication
internal/argocd/argocd.go:116:6: unreachable func: GetArgoCDApplication
internal/aws/aws.go:89:31: unreachable func: AWSConfiguration.Route53ListARecords
internal/aws/destroy.go:34:31: unreachable func: AWSConfiguration.GetLoadBalancersForDeletion
internal/aws/destroy.go:96:31: unreachable func: AWSConfiguration.DeleteEKSSecurityGroups
internal/aws/destroy.go:158:31: unreachable func: AWSConfiguration.DeleteSecurityGroup
internal/aws/destroy.go:221:31: unreachable func: AWSConfiguration.DeleteElasticLoadBalancer
internal/aws/eksClient.go:20:6: unreachable func: NewClientset
internal/aws/eksClient.go:52:6: unreachable func: NewRestConfig
internal/aws/iam.go:16:31: unreachable func: AWSConfiguration.GetIamRole
internal/aws/quota.go:23:31: unreachable func: AWSConfiguration.GetServiceQuotas
internal/aws/route53.go:149:31: unreachable func: AWSConfiguration.GetHostedZone
internal/aws/route53.go:180:31: unreachable func: AWSConfiguration.GetHostedZoneNameServers
internal/aws/s3.go:70:31: unreachable func: AWSConfiguration.DeleteBucket
internal/aws/s3.go:87:31: unreachable func: AWSConfiguration.ListBuckets
internal/aws/servicequotas.go:16:31: unreachable func: AWSConfiguration.ListQuotas
internal/civo/objectStorage.go:34:29: unreachable func: CivoConfiguration.DeleteStorageBucket
internal/civo/objectStorage.go:99:29: unreachable func: CivoConfiguration.DeleteAccessCredentials
internal/cloudflare/cloudflare.go:37:35: unreachable func: CloudflareConfiguration.GetDNSRecord
internal/controller/kubefirst.go:32:6: unreachable func: ReadKubefirstAPITokenFromSecret
internal/controller/kubefirst.go:100:34: unreachable func: ClusterController.CreateVirtualClusters
internal/digitalocean/client.go:23:37: unreachable func: DigitaloceanConfiguration.ValidateRegion
internal/digitalocean/dns.go:153:37: unreachable func: DigitaloceanConfiguration.DeleteDNSRecords
internal/dns/dns.go:30:6: unreachable func: VerifyProviderDNS
internal/downloadManager/download.go:55:6: unreachable func: ExtractFileFromTarGz
internal/downloadManager/download.go:143:6: unreachable func: createDirIfDontExist
internal/downloadManager/download.go:153:6: unreachable func: DownloadTarGz
internal/downloadManager/download.go:180:6: unreachable func: DownloadZip
internal/gitClient/fileFilter.go:20:6: unreachable func: AppendFile
internal/gitClient/fileFilter.go:50:6: unreachable func: GitAddWithFilter
internal/gitClient/git.go:164:6: unreachable func: Pull
internal/gitShim/gitopsCatalog.go:24:25: unreachable func: GitHubClient.GetGitopsCatalogRepo
internal/gitShim/gitopsCatalog.go:55:25: unreachable func: GitHubClient.ReadGitopsCatalogRepoDirectory
internal/gitShim/gitopsCatalog.go:90:25: unreachable func: GitHubClient.ReadGitopsCatalogAppDirectory
internal/github/github.go:43:24: unreachable func: GithubSession.CreateWebhookRepo
internal/github/github.go:67:24: unreachable func: GithubSession.CreatePrivateRepo
internal/github/github.go:87:24: unreachable func: GithubSession.RemoveRepo
internal/github/github.go:104:24: unreachable func: GithubSession.RemoveTeam
internal/github/github.go:117:24: unreachable func: GithubSession.GetRepo
internal/github/github.go:131:24: unreachable func: GithubSession.AddSSHKey
internal/github/github.go:141:24: unreachable func: GithubSession.RemoveSSHKey
internal/github/github.go:151:24: unreachable func: GithubSession.RemoveSSHKeyByPublicKey
internal/github/github.go:181:24: unreachable func: GithubSession.IsRepoInUse
internal/github/github.go:186:24: unreachable func: GithubSession.CreatePR
internal/github/github.go:217:24: unreachable func: GithubSession.CommentPR
internal/github/github.go:240:24: unreachable func: GithubSession.SearchWordInPullRequestComment
internal/github/github.go:269:24: unreachable func: GithubSession.RetrySearchPullRequestComment
internal/github/github.go:302:24: unreachable func: GithubSession.DeleteRepositoryWebhook
internal/github/github.go:328:24: unreachable func: GithubSession.ListRepoWebhooks
internal/gitlab/gitlab.go:323:26: unreachable func: GitLabWrapper.CreateProjectDeployToken
internal/gitlab/gitlab.go:381:26: unreachable func: GitLabWrapper.ListProjectDeployTokens
internal/gitlab/gitlab.go:406:26: unreachable func: GitLabWrapper.DeleteProjectWebhook
internal/gitlab/gitlab.go:436:26: unreachable func: GitLabWrapper.ListProjectWebhooks
internal/gitlab/gitlab.go:457:26: unreachable func: GitLabWrapper.ListGroupRunners
internal/gitlab/gitlab.go:477:26: unreachable func: GitLabWrapper.DeleteGroupRunners
internal/gitopsCatalog/gitopsCatalog.go:44:6: unreachable func: ReadApplicationDirectory
internal/helpers/destroy.go:18:6: unreachable func: EvalDestroy
internal/k3d/adjustContent.go:23:6: unreachable func: AdjustGitopsRepo
internal/k3d/adjustContent.go:96:6: unreachable func: AdjustMetaphorRepo
internal/k3d/config.go:72:6: unreachable func: GetConfig
internal/k3d/create.go:27:6: unreachable func: ClusterCreate
internal/k3d/create.go:71:6: unreachable func: ClusterCreateConsoleAPI
internal/k3d/create.go:107:6: unreachable func: PrepareGitRepositories
internal/k3d/create.go:186:6: unreachable func: PostRunPrepareGitopsRepository
internal/k3d/destroy.go:22:6: unreachable func: DeleteK3dCluster
internal/k3d/destroy.go:41:6: unreachable func: ResolveMinioLocal
internal/k3d/destroy.go:52:6: unreachable func: resolveMinioLocal
internal/k3d/detokenize.go:21:6: unreachable func: detokenizeGitGitops
internal/k3d/detokenize.go:31:6: unreachable func: detokenizeGitops
internal/k3d/detokenize.go:103:6: unreachable func: postRunDetokenizeGitGitops
internal/k3d/detokenize.go:113:6: unreachable func: postRunDetokenizeGitops
internal/k3d/detokenize.go:148:6: unreachable func: detokenizeGitMetaphor
internal/k3d/detokenize.go:158:6: unreachable func: detokenize
internal/k3d/download.go:17:6: unreachable func: DownloadTools
internal/k3d/secrets.go:21:6: unreachable func: AddK3DSecrets
internal/k3d/ssl.go:23:6: unreachable func: GenerateTLSSecrets
internal/k3d/ssl.go:103:6: unreachable func: GenerateSingleTLSSecret
internal/k3d/terraform.go:13:6: unreachable func: GetGithubTerraformEnvs
internal/k3d/terraform.go:23:6: unreachable func: GetUsersTerraformEnvs
internal/k3d/terraform.go:35:6: unreachable func: GetVaultTerraformEnvs
internal/k8s/apply.go:120:29: unreachable func: KubernetesClient.ReadYAMLFile
internal/k8s/exec.go:44:6: unreachable func: ReadConfigMapV2
internal/k8s/exec.go:79:6: unreachable func: ReadService
internal/k8s/exec.go:95:6: unreachable func: PodExecSession
internal/k8s/exec.go:113:6: unreachable func: podExec
internal/k8s/exec.go:209:6: unreachable func: ReturnPodObject
internal/k8s/exec.go:355:6: unreachable func: WaitForPodReady
internal/k8s/kubernetes.go:58:6: unreachable func: GetClientConfig
internal/k8s/kubernetes.go:68:6: unreachable func: WaitForNamespaceandPods
internal/progressPrinter/progress.go:44:6: unreachable func: GetInstance
internal/progressPrinter/progress.go:57:6: unreachable func: SetupProgress
internal/progressPrinter/progress.go:95:6: unreachable func: CreateTracker
internal/progressPrinter/progress.go:110:6: unreachable func: LogMessage
internal/progressPrinter/progress.go:121:6: unreachable func: AddTracker
internal/progressPrinter/progress.go:127:6: unreachable func: TotalOfTrackers
internal/progressPrinter/progress.go:136:6: unreachable func: IncrementTracker
internal/services/github.go:39:30: unreachable func: GitHubService.CheckUserCodeConfirmation
internal/ssl/ssl.go:67:6: unreachable func: Backup
internal/utils/utils.go:56:6: unreachable func: ReadFileContents
internal/utils/utils.go:65:6: unreachable func: ReadFileContentType
internal/utils/utils.go:90:6: unreachable func: RemoveFromSlice
internal/vault/terraform.go:24:33: unreachable func: VaultConfiguration.IterSecrets
internal/vultr/objectStorage.go:75:30: unreachable func: VultrConfiguration.DeleteObjectStorage
internal/vultr/objectStorage.go:98:30: unreachable func: VultrConfiguration.GetObjectStorage
pkg/google/dns.go:28:34: unreachable func: GoogleConfiguration.TestHostedZoneLiveness
pkg/google/gcs.go:55:34: unreachable func: GoogleConfiguration.DeleteBucket
pkg/google/gcs.go:79:34: unreachable func: GoogleConfiguration.ListBuckets
pkg/google/gke.go:26:34: unreachable func: GoogleConfiguration.ListContainerClusters
pkg/google/gke.go:43:34: unreachable func: GoogleConfiguration.GetContainerCluster
pkg/handlers/github.go:57:30: unreachable func: GitHubHandler.AuthenticateUser
pkg/handlers/github.go:178:30: unreachable func: GitHubHandler.CheckGithubOrganizationPermissions
pkg/handlers/github.go:224:6: unreachable func: printGitHubAuthToken
pkg/providerConfigs/detokenize.go:220:6: unreachable func: DetokenizeAdditionalPath
pkg/providerConfigs/detokenize.go:230:6: unreachable func: detokenizeAdditionalPath
pkg/reports/aws.go:21:6: unreachable func: AwsHandoffScreen
pkg/reports/civo.go:20:6: unreachable func: CivoHandoffScreen
pkg/reports/command-summary.go:40:16: unreachable func: Model.Init
pkg/reports/command-summary.go:44:16: unreachable func: Model.Update
pkg/reports/command-summary.go:91:16: unreachable func: Model.View
pkg/reports/command-summary.go:98:16: unreachable func: Model.headerView
pkg/reports/command-summary.go:104:16: unreachable func: Model.footerView
pkg/reports/command-summary.go:110:6: unreachable func: max
pkg/reports/command-summary.go:118:6: unreachable func: CommandSummary
pkg/reports/command-summary.go:131:6: unreachable func: getStyle
pkg/reports/command-summary.go:148:6: unreachable func: StyleMessage
pkg/reports/command-summary.go:154:6: unreachable func: StyleMessageBlackAndWhite
pkg/reports/create.go:46:6: unreachable func: BuildCreateHandOffReport
pkg/reports/create.go:113:6: unreachable func: BuildSection
pkg/reports/digitalocean.go:20:6: unreachable func: DigitaloceanHandoffScreen
pkg/reports/google.go:20:6: unreachable func: GoogleHandoffScreen
pkg/reports/local.go:23:6: unreachable func: LocalHandoffScreenV2
pkg/reports/vultr.go:20:6: unreachable func: VultrHandoffScreen
pkg/utils/cluster.go:24:6: unreachable func: PutClusterObject
pkg/utils/cluster.go:71:6: unreachable func: ExportCluster
pkg/utils/helpers.go:11:6: unreachable func: randSeq
pkg/utils/helpers.go:20:6: unreachable func: Random
pkg/utils/ssh.go:45:6: unreachable func: EvalSSHKey
providers/akamai/delete.go:34:6: unreachable func: DeleteAkamaiCluster

I'm wary of deleting them right away since some of them are publicly accessible and they might be used by other software in our inventory (like api-ee or the CLI) but I'm sure at least some of these can be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant