Showing 27 of 27 total issues
Method K8sProvider.createSecretData
has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring. Open
func (p *K8sProvider) createSecretData(conjurSecrets map[string][]byte) map[string]map[string][]byte {
_, isFetchAll := p.secretsState.updateDestinations["*"]
secretData := map[string]map[string][]byte{}
for variableID, secretValue := range conjurSecrets {
- 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 DeployTestAppWithHelm
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func DeployTestAppWithHelm(client klient.Client, id string) error {
// create Deployment
var replicas int32 = 1
deployment := appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Function CreateK8sRole
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func CreateK8sRole(client klient.Client, id string) error {
// create ServiceAccount
serviceAccount := corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Method K8sProvider.createSecretData
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *K8sProvider) createSecretData(conjurSecrets map[string][]byte) map[string]map[string][]byte {
_, isFetchAll := p.secretsState.updateDestinations["*"]
secretData := map[string]map[string][]byte{}
for variableID, secretValue := range conjurSecrets {
Function startSecretsProviderWithDeps
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func startSecretsProviderWithDeps(
annotationsFilePath string,
secretsBasePath string,
templatesBasePath string,
retrieverFactory conjur.RetrieverFactory,
Function secretsProvider
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
ctx context.Context,
tracer trace.Tracer,
secretsBasePath string,
templatesBasePath string,
secretRetriever conjur.RetrieveSecretsFunc,
Function FetchSecretsForGroups
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func FetchSecretsForGroups(
depRetrieveSecrets conjur.RetrieveSecretsFunc,
secretGroups []*SecretGroup,
traceContext context.Context,
) (map[string][]*Secret, error) {
- 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 DeploySecretsProviderJobWithHelm
has 7 return statements (exceeds 4 allowed). Open
func DeploySecretsProviderJobWithHelm(cfg *envconf.Config, id string, chartPaths ...string) error {
// set conjur cert to file
err := CreateConjurCertFile(cfg.Client())
if err != nil {
return err
Function CopyFileIntoPod
has 7 return statements (exceeds 4 allowed). Open
func CopyFileIntoPod(client klient.Client, podName string, namespace string, containerName string, src string, dst string) error {
// create client-go clientset
clientset, err := kubernetes.NewForConfig(client.RESTConfig())
if err != nil {
return fmt.Errorf("unable to initialize K8s client: %v", err)
Method ConjurMockClient.RetrieveBatchSecretsSafe
has 7 return statements (exceeds 4 allowed). Open
func (mc *ConjurMockClient) RetrieveBatchSecretsSafe(variableIDs []string) (map[string][]byte, error) {
if mc.ErrOnExecute != nil {
return nil, mc.ErrOnExecute
}
Function startSecretsProviderWithDeps
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
annotationsFilePath string,
secretsBasePath string,
templatesBasePath string,
retrieverFactory conjur.RetrieverFactory,
providerFactory secrets.ProviderFactory,
Function RunCommandInSecretsProviderPod
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func RunCommandInSecretsProviderPod(client klient.Client, labelSelector string, container string, command []string, stdout *bytes.Buffer, stderr *bytes.Buffer) error {
Function CopyFileIntoPod
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func CopyFileIntoPod(client klient.Client, podName string, namespace string, containerName string, src string, dst string) error {
Function ScaleDeployment
has 6 return statements (exceeds 4 allowed). Open
func ScaleDeployment(client klient.Client, deploymentName string, namespace string, labelSelector string, replicas int32) error {
mergePatch, err := json.Marshal(map[string]interface{}{
"spec": map[string]interface{}{
"replicas": replicas,
},
Function newSecretGroup
has 6 return statements (exceeds 4 allowed). Open
func newSecretGroup(groupName string, annotations map[string]string, c Config) (*SecretGroup, []error) {
groupSecrets := annotations[secretGroupPrefix+groupName]
filePath := annotations[secretGroupFilePathPrefix+groupName]
fileFormat := annotations[secretGroupFileFormatPrefix+groupName]
Function ScaleDeployment
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func ScaleDeployment(client klient.Client, deploymentName string, namespace string, labelSelector string, replicas int32) error {
Similar blocks of code found in 5 locations. Consider refactoring. Open
func GetSecret(client klient.Client, secretName string) (*corev1.Secret, error) {
var secret corev1.Secret
err := client.Resources().Get(context.TODO(), secretName, SecretsProviderNamespace(), &secret)
if err != nil {
return &secret, err
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
func GetConfigMap(client klient.Client, configMapName string) (*corev1.ConfigMap, error) {
var configMap corev1.ConfigMap
err := client.Resources().Get(context.TODO(), configMapName, SecretsProviderNamespace(), &configMap)
if err != nil {
return &configMap, err
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
func GetDeployment(client klient.Client, deploymentName string) (*appsv1.Deployment, error) {
var deployment appsv1.Deployment
err := client.Resources().Get(context.TODO(), deploymentName, SecretsProviderNamespace(), &deployment)
if err != nil {
return &deployment, err
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 5 locations. Consider refactoring. Open
func GetJob(client klient.Client, jobName string) (*batchv1.Job, error) {
var job batchv1.Job
err := client.Resources().Get(context.TODO(), jobName, SecretsProviderNamespace(), &job)
if err != nil {
return &job, err
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 107.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76