Showing 900 of 900 total issues
Function GetStorageLockManager
has 5 return statements (exceeds 4 allowed). Open
Open
func GetStorageLockManager(ctx context.Context, synchronization *SynchronizationParams) (storage.LockManager, error) {
switch synchronization.SynchronizationType {
case LocalSynchronization:
return storage.NewGenericLockManager(werf.GetHostLocker()), nil
case KubernetesSynchronization:
Function createNamespace
has 5 return statements (exceeds 4 allowed). Open
Open
func createNamespace(ctx context.Context, namespace string) error {
if *commonCmdData.DryRun {
return nil
}
Function NewExportCmd
has 5 return statements (exceeds 4 allowed). Open
Open
func NewExportCmd(ctx context.Context) *cobra.Command {
var tagTemplateList []string
var addLabelArray []string
ctx = common.NewContextWithCmdData(ctx, &commonCmdData)
Function validateCopyTo
has 5 return statements (exceeds 4 allowed). Open
Open
func validateCopyTo() error {
rawCopyTo := getCopyToRaw()
for _, copyTo := range rawCopyTo {
parts := strings.Split(copyTo, ":")
Function run
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func run(ctx context.Context, imageName string) error {
if err := werf.Init(*commonCmdData.TmpDir, *commonCmdData.HomeDir); err != nil {
return fmt.Errorf("initialization error: %w", 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 deleteCustomTags
has 5 return statements (exceeds 4 allowed). Open
Open
func deleteCustomTags(ctx context.Context, storageManager manager.StorageManagerInterface, customTagList []string, dryRun bool) error {
if dryRun {
for _, customTag := range customTagList {
logboek.Context(ctx).Default().LogFDetails(" tag: %s\n", customTag)
logboek.Context(ctx).Default().LogOptionalLn()
Method KubernetesStagesStorageCache.changeCacheData
has 5 return statements (exceeds 4 allowed). Open
Open
func (cache *KubernetesStagesStorageCache) changeCacheData(ctx context.Context, projectName string, changeFunc func(obj *v1.ConfigMap, cacheData *KubernetesStagesStorageCacheData) error) error {
RETRY_CHANGE:
obj, err := kubeutils.GetOrCreateConfigMapWithNamespaceIfNotExists(cache.KubeClient, cache.Namespace, cache.GetConfigMapNameFunc(projectName))
if err != nil {
Method StorageManager.SelectSuitableStage
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *StorageManager) SelectSuitableStage(ctx context.Context, c stage.Conveyor, stg stage.Interface, stages []*image.StageDescription) (*image.StageDescription, error) {
if len(stages) == 0 {
return nil, nil
}
Method purgeManager.deleteCustomTags
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *purgeManager) deleteCustomTags(ctx context.Context) error {
stageIDCustomTagList, err := stage_manager.GetCustomTagsMetadata(ctx, m.StorageManager)
if err != nil {
return err
}
Method BundleArchiveFileReader.ReadChartArchive
has 5 return statements (exceeds 4 allowed). Open
Open
func (reader *BundleArchiveFileReader) ReadChartArchive() ([]byte, error) {
treader, closer, err := reader.openForReading()
defer closer()
if err != nil {
Method RepoStagesStorage.CopyFromStorage
has 5 return statements (exceeds 4 allowed). Open
Open
func (storage *RepoStagesStorage) CopyFromStorage(ctx context.Context, src StagesStorage, projectName string, stageID image.StageID, opts CopyFromStorageOptions) (*image.StageDescription, error) {
desc, err := storage.GetStageDescription(ctx, projectName, stageID)
if err != nil {
return nil, fmt.Errorf("unable to get stage %s description: %w", stageID, err)
}
Function doFetchStage
has 5 return statements (exceeds 4 allowed). Open
Open
func doFetchStage(ctx context.Context, projectName string, stagesStorage storage.StagesStorage, stageID image.StageID, img container_backend.LegacyImageInterface) error {
err := logboek.Context(ctx).Info().LogProcess("Check manifest availability").DoError(func() error {
freshStageDescription, err := stagesStorage.GetStageDescription(ctx, projectName, stageID)
if err != nil {
return fmt.Errorf("unable to get stage description: %w", err)
Function GetRequiredSecretKey
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func GetRequiredSecretKey(workingDir string) ([]byte, error) {
var secretKey []byte
var werfSecretKeyPaths []string
var notFoundIn []string
- 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 readBundleJsonMap
has 5 return statements (exceeds 4 allowed). Open
Open
func readBundleJsonMap(path string) (map[string]string, error) {
var res map[string]string
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, nil
} else if err != nil {
Function GetCustomTagsMetadata
has 5 return statements (exceeds 4 allowed). Open
Open
func GetCustomTagsMetadata(ctx context.Context, storageManager manager.StorageManagerInterface) (map[string][]string, error) {
stageCustomTagMetadataIDs, err := storageManager.GetStagesStorage().GetStageCustomTagMetadataIDs(ctx, storage.WithCache())
if err != nil {
return nil, fmt.Errorf("unable to get stage custom tag metadata IDs: %w", err)
}
Method StorageManager.CopySuitableByDigestStage
has 5 return statements (exceeds 4 allowed). Open
Open
func (m *StorageManager) CopySuitableByDigestStage(ctx context.Context, stageDesc *image.StageDescription, sourceStagesStorage, destinationStagesStorage storage.StagesStorage, containerBackend container_backend.ContainerBackend, targetPlatform string) (*image.StageDescription, error) {
img := container_backend.NewLegacyStageImage(nil, stageDesc.Info.Name, containerBackend, targetPlatform)
logboek.Context(ctx).Info().LogF("Fetching %s\n", img.Name())
if err := sourceStagesStorage.FetchImage(ctx, img); err != nil {
Method BundleArchiveFileReader.ReadImageArchive
has 5 return statements (exceeds 4 allowed). Open
Open
func (reader *BundleArchiveFileReader) ReadImageArchive(imageTag string) (*ImageArchiveReadCloser, error) {
treader, closer, err := reader.openForReading()
if err != nil {
defer closer()
return nil, fmt.Errorf("unable to open bundle archive: %w", err)
Function doRequest
has 5 return statements (exceeds 4 allowed). Open
Open
func doRequest(ctx context.Context, client *http.Client, method, url string, body io.Reader, options doRequestOptions) (*http.Response, []byte, error) {
req, err := http.NewRequestWithContext(ctx, method, url, body)
if err != nil {
return nil, nil, err
}
Function GetRequiredSecretKey
has 5 return statements (exceeds 4 allowed). Open
Open
func GetRequiredSecretKey(workingDir string) ([]byte, error) {
var secretKey []byte
var werfSecretKeyPaths []string
var notFoundIn []string
Method api.PullImageArchive
has 5 return statements (exceeds 4 allowed). Open
Open
func (api *api) PullImageArchive(ctx context.Context, archiveWriter io.Writer, reference string) error {
ref, err := name.ParseReference(reference, api.parseReferenceOptions()...)
if err != nil {
return fmt.Errorf("unable to parse reference %q: %w", reference, err)
}