Showing 22 of 27 total issues
Method K8sProvider.createSecretData
has a Cognitive Complexity of 50 (exceeds 20 allowed). Consider refactoring. Open
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
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
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
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
Open
func startSecretsProviderWithDeps(
annotationsFilePath string,
secretsBasePath string,
templatesBasePath string,
retrieverFactory conjur.RetrieverFactory,
Function secretsProvider
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
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
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
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
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
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
Open
annotationsFilePath string,
secretsBasePath string,
templatesBasePath string,
retrieverFactory conjur.RetrieverFactory,
providerFactory secrets.ProviderFactory,
Function RunCommandInSecretsProviderPod
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
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
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
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
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
Open
func ScaleDeployment(client klient.Client, deploymentName string, namespace string, labelSelector string, replicas int32) error {
Method secretRetriever.Retrieve
has 5 return statements (exceeds 4 allowed). Open
Open
func (retriever secretRetriever) Retrieve(variableIDs []string, traceContext context.Context) (map[string][]byte, error) {
authn := retriever.authn
err := authn.AuthenticateWithContext(traceContext)
if err != nil {
Function collectTemplate
has 5 return statements (exceeds 4 allowed). Open
Open
func collectTemplate(groupName string, annotations map[string]string, c Config) (string, error) {
annotationTemplate := annotations[secretGroupFileTemplatePrefix+groupName]
configmapTemplate, err := readTemplateFromFile(groupName, annotations, c)
if os.IsNotExist(err) {
Method ConjurMockClient.Resources
has 5 return statements (exceeds 4 allowed). Open
Open
func (mc *ConjurMockClient) Resources(filter *conjurapi.ResourceFilter) (resources []map[string]interface{}, err error) {
if mc.ReturnNoSecrets {
return []map[string]interface{}{}, nil
}
Function startSecretsProviderWithDeps
has 5 return statements (exceeds 4 allowed). Open
Open
func startSecretsProviderWithDeps(
annotationsFilePath string,
secretsBasePath string,
templatesBasePath string,
retrieverFactory conjur.RetrieverFactory,