Showing 900 of 900 total issues
Method KubernetesStagesStorageCache.GetStagesByDigest
has 5 return statements (exceeds 4 allowed). Open
Open
func (cache *KubernetesStagesStorageCache) GetStagesByDigest(ctx context.Context, projectName, digest string) (bool, []image.StageID, error) {
if obj, err := kubeutils.GetOrCreateConfigMapWithNamespaceIfNotExists(cache.KubeClient, cache.Namespace, cache.GetConfigMapNameFunc(projectName)); err != nil {
return false, nil, err
} else if cacheData, err := cache.extractCacheData(ctx, obj); err != nil {
return false, nil, err
Method cleanupManager.deleteUnusedCustomTags
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *cleanupManager) deleteUnusedCustomTags(ctx context.Context) error {
stageIDCustomTagList := m.stageManager.GetCustomTagsMetadata()
if len(stageIDCustomTagList) == 0 {
return nil
}
Function getDigestAndUniqueIDFromRepoStageImageTag
has 5 return statements (exceeds 4 allowed). Open
Open
func getDigestAndUniqueIDFromRepoStageImageTag(repoStageImageTag string) (string, int64, error) {
parts := strings.SplitN(repoStageImageTag, "-", 2)
if len(parts) == 1 {
if len(parts[0]) != 56 {
Method SecretsManager.GetYamlEncoder
has 5 return statements (exceeds 4 allowed). Open
Open
func (manager *SecretsManager) GetYamlEncoder(ctx context.Context, workingDir string) (*secret.YamlEncoder, error) {
if manager.DisableSecretsDecryption {
logboek.Context(ctx).Default().LogLnDetails("Secrets decryption disabled")
return secret.NewYamlEncoder(nil), nil
}
Function detectImplementation
has 5 return statements (exceeds 4 allowed). Open
Open
func detectImplementation(accountOrRepositoryAddress string) (string, error) {
var parsedResource authn.Resource
var err error
parts := strings.SplitN(accountOrRepositoryAddress, "/", 2)
Function parsePrivateSSHKey
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func parsePrivateSSHKey(cfg sshKeyConfig) (sshKey, error) {
keyData, err := ioutil.ReadFile(cfg.FilePath)
if err != nil {
return sshKey{}, fmt.Errorf("error reading key file %q: %w", cfg.FilePath, 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 parsePrivateSSHKey
has 5 return statements (exceeds 4 allowed). Open
Open
func parsePrivateSSHKey(cfg sshKeyConfig) (sshKey, error) {
keyData, err := ioutil.ReadFile(cfg.FilePath)
if err != nil {
return sshKey{}, fmt.Errorf("error reading key file %q: %w", cfg.FilePath, err)
}
Method Copy.Apply
has 5 return statements (exceeds 4 allowed). Open
Open
func (i *Copy) Apply(ctx context.Context, containerName string, drv buildah.Buildah, drvOpts buildah.CommonOpts, buildContextArchive container_backend.BuildContextArchiver) error {
var contextDir string
if i.UsesBuildContext() {
var err error
contextDir, err = buildContextArchive.ExtractOrGetExtractedDir(ctx)
Function RemovePathWithEmptyParentDirsInsideScope
has 5 return statements (exceeds 4 allowed). Open
Open
func RemovePathWithEmptyParentDirsInsideScope(scopeDir, path string) error {
if !util.IsSubpathOfBasePath(scopeDir, path) {
return nil
}
Method harbor.GetRepoImage
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *harbor) GetRepoImage(ctx context.Context, reference string) (*image.Info, error) {
var info *image.Info
operation := func() error {
var err error
info, err = r.api.GetRepoImage(ctx, reference)
Method Local.validateStatusResultSubmodules
has 5 return statements (exceeds 4 allowed). Open
Open
func (repo *Local) validateStatusResultSubmodules(_ context.Context, pathMatcher path_matcher.PathMatcher, scope status.Scope) error {
// No changes related to submodules.
if len(scope.Submodules()) == 0 {
return nil
}
Function revertExcludedChangesInServiceWorktreeIndex
has 5 return statements (exceeds 4 allowed). Open
Open
func revertExcludedChangesInServiceWorktreeIndex(ctx context.Context, sourceWorktreeDir, serviceWorktreeDir, sourceCommit, serviceBranchHeadCommit string, globExcludeList []string) (bool, error) {
if len(globExcludeList) == 0 || serviceBranchHeadCommit == sourceCommit {
return false, nil
}
Function HashContentsAndPathsRecurse
has 5 return statements (exceeds 4 allowed). Open
Open
func HashContentsAndPathsRecurse(path string) (string, error) {
path = filepath.Clean(path)
fi, err := os.Stat(path)
if err != nil {
Method excludePathMatcher.shouldGoThrough
has 5 return statements (exceeds 4 allowed). Open
Open
func (m excludePathMatcher) shouldGoThrough(path string) bool {
if len(m.excludeGlobs) == 0 {
return false
}
Method dockerHubApi.getToken
has 5 return statements (exceeds 4 allowed). Open
Open
func (api *dockerHubApi) getToken(ctx context.Context, username, password string) (string, *http.Response, error) {
url := "https://hub.docker.com/v2/users/login/"
body, err := json.Marshal(map[string]string{
"username": username,
"password": password,
Method Result.walkWithResult
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *Result) walkWithResult(f func(r *Result, sr *SubmoduleResult, lsTreeEntry *LsTreeEntry) error) error {
if err := r.lsTreeEntriesWalkWithResult(f); err != nil {
return err
}
Method includePathMatcher.shouldGoThrough
has 5 return statements (exceeds 4 allowed). Open
Open
func (m includePathMatcher) shouldGoThrough(path string) bool {
if len(m.includeGlobs) == 0 {
return false
}
Method NativeBuildah.Pull
has 5 return statements (exceeds 4 allowed). Open
Open
func (b *NativeBuildah) Pull(ctx context.Context, ref string, opts PullOpts) error {
sysCtx, err := b.getSystemContext(opts.TargetPlatform)
if err != nil {
return err
}
Function NewConfig
has 5 return statements (exceeds 4 allowed). Open
Open
func NewConfig(ctx context.Context, fileReader fileReader, configRelPath string) (c Config, err error) {
exist, err := fileReader.IsGiterminismConfigExistAnywhere(ctx, configRelPath)
if err != nil {
return c, err
}
Function runSSHAgent
has 5 return statements (exceeds 4 allowed). Open
Open
func runSSHAgent(ctx context.Context) (string, error) {
sockPath := filepath.Join(werf.GetTmpDir(), "werf-ssh-agent", uuid.NewString())
tmpSockPath = sockPath
err := os.MkdirAll(filepath.Dir(sockPath), os.ModePerm)